Module: Minjs::Program

Included in:
Compressor
Defined in:
lib/minjs/program.rb

Overview

14 Program

Instance Method Summary collapse

Instance Method Details

#program(lex, context) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/minjs/program.rb', line 6

def program(lex, context)
  prog = source_elements(@lex, @global_context)
  if lex.eof?
    return prog
  else
    raise ParseError.new("unexpceted token", lex)
  end
end

#source_element(lex, context) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/minjs/program.rb', line 23

def source_element(lex, context)
  #lex.eval_lit{
  statement(lex, context)
  #} or lex.eval_lit{ => statement
  #  func_declaration(lex, context)
  #}
end

#source_elements(lex, context, options = {}) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/minjs/program.rb', line 15

def source_elements(lex, context, options = {})
  prog = []
  while t = source_element(lex, context)
    prog.push(t)
  end
  ECMA262::Prog.new(context, ECMA262::SourceElements.new(prog))
end