Parse javascript and return an AST
# File lib/rkelly/parser.rb, line 39 def parse(javascript, filename = nil) @tokens = TOKENIZER.raw_tokens(javascript) @position = 0 @filename = filename ast = do_parse ast.comments = @comments if ast ast end
When parsing finishes without all tokens being parsed, returns the token at which the parsing stopped. Returns nil when parser reached to the very last token (but possibly still failed as it expeced more tokens).
Useful for pin-pointing the position of a syntax error.
# File lib/rkelly/parser.rb, line 58 def stopped_at if @position < @tokens.length @tokens[@position-1] else nil end end
Generated with the Darkfish Rdoc Generator 2.