Class: RKelly::Parser
- Inherits:
-
GeneratedParser
- Object
- Racc::Parser
- GeneratedParser
- RKelly::Parser
- Defined in:
- lib/rkelly/parser.rb
Constant Summary collapse
Constants inherited from GeneratedParser
GeneratedParser::Racc_arg, GeneratedParser::Racc_debug_parser, GeneratedParser::Racc_token_to_s_table
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
-
#parse(javascript, filename = nil) ⇒ Object
Parse
javascript
and return an AST. - #yyabort ⇒ Object
Methods inherited from GeneratedParser
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
26 27 28 29 30 31 32 |
# File 'lib/rkelly/parser.rb', line 26 def initialize @tokens = [] @logger = nil @terminator = false @prev_token = nil @comments = [] end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
25 26 27 |
# File 'lib/rkelly/parser.rb', line 25 def logger @logger end |
Instance Method Details
#parse(javascript, filename = nil) ⇒ Object
Parse javascript
and return an AST
35 36 37 38 39 40 41 |
# File 'lib/rkelly/parser.rb', line 35 def parse(javascript, filename = nil) @tokens = TOKENIZER.raw_tokens(javascript) @position = 0 @filename = filename ast = do_parse apply_comments(ast) end |
#yyabort ⇒ Object
43 44 45 |
# File 'lib/rkelly/parser.rb', line 43 def yyabort raise "something bad happened, please report a bug with sample JavaScript" end |