def lex(s)
    ts = []
    while s.length > 0
      typ, lexeme, val = tok(s)
      if typ == nil
        raise Error, "invalid character at #{s[0,10].inspect}"
      end
      if typ != :space
        ts << [typ, lexeme, val]
      end
      s = s[lexeme.length..-1]
    end
    ts
  end
def lex(s)
    ts = []
    while s.length > 0
      typ, lexeme, val = tok(s)
      if typ == nil
        raise Error, "invalid character at #{s[0,10].inspect}"
      end
      if typ != :space
        ts << [typ, lexeme, val]
      end
      s = s[lexeme.length..-1]
    end
    ts
  end
Scans s and returns a list of json tokens,
 excluding white space (as defined in RFC 4627).