Module: Minjs::Lex::Program
Overview
14 Program
Constant Summary
Constants included from Minjs
Instance Method Summary collapse
-
#program(var_env) ⇒ ECMA262::Prog
Tests next literals sequence is Program or not.
-
#source_elements(var_env) ⇒ ECMA262::SourceElements
Tests next literals sequence is SourceElements or not.
Instance Method Details
#program(var_env) ⇒ ECMA262::Prog
Tests next literals sequence is Program or not.
If sequence is Program return ECMA262::Prog object and forward lexical parser position. Otherwise return nil and position is not changed.
18 19 20 21 22 23 24 25 |
# File 'lib/minjs/lex/program.rb', line 18 def program(var_env) prog = source_elements(var_env) if eof? return prog else raise ParseError.new("unexpceted token", self) end end |
#source_elements(var_env) ⇒ ECMA262::SourceElements
Tests next literals sequence is SourceElements or not.
If sequence is SourceElements return ECMA262::SourceElements object and forward lexical parser position. Otherwise return nil and position is not changed.
37 38 39 40 41 42 43 |
# File 'lib/minjs/lex/program.rb', line 37 def source_elements(var_env) prog = [] while t = source_element(var_env) prog.push(t) end ECMA262::Prog.new(var_env, ECMA262::SourceElements.new(prog)) end |