Module: Minjs::Lex::Program

Includes:
Minjs
Included in:
Parser
Defined in:
lib/minjs/lex/program.rb

Overview

14 Program

Constant Summary

Constants included from Minjs

VERSION

Instance Method Summary collapse

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.

Returns:

See Also:



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.

Returns:

See Also:



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