Class: RKelly::Parser

Inherits:
GeneratedParser
  • Object
show all
Defined in:
lib/rkelly/parser.rb

Constant Summary collapse

TOKENIZER =
Tokenizer.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser



25
26
27
28
29
30
31
# File 'lib/rkelly/parser.rb', line 25

def initialize
  @tokens = []
  @logger = nil
  @terminator = false
  @prev_token = nil
  @comments = []
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



24
25
26
# File 'lib/rkelly/parser.rb', line 24

def logger
  @logger
end

Instance Method Details

#parse(javascript) ⇒ Object

Parse javascript and return an AST



34
35
36
37
38
39
# File 'lib/rkelly/parser.rb', line 34

def parse(javascript)
  @tokens = TOKENIZER.raw_tokens(javascript)
  @position = 0
  ast = do_parse
  apply_comments(ast)
end