Class: Rattler::Compiler::ParserGenerator::ExprGenerator

Inherits:
Object
  • Object
show all
Includes:
Parsers
Defined in:
lib/rattler/compiler/parser_generator/expr_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(g, choice_level = nil, sequence_level = nil, repeat_level = nil) ⇒ ExprGenerator

Returns a new instance of ExprGenerator.



10
11
12
13
14
15
# File 'lib/rattler/compiler/parser_generator/expr_generator.rb', line 10

def initialize(g, choice_level=nil, sequence_level=nil, repeat_level=nil)
  @g = g
  @choice_level = choice_level
  @sequence_level = sequence_level
  @repeat_level = repeat_level
end

Instance Method Details

#gen_intermediate(parser, scope = ParserScope.empty) ⇒ Object



26
27
28
# File 'lib/rattler/compiler/parser_generator/expr_generator.rb', line 26

def gen_intermediate(parser, scope = ParserScope.empty)
  gen_basic parser, scope
end

#gen_intermediate_assert(parser, scope = ParserScope.empty) ⇒ Object



30
31
32
# File 'lib/rattler/compiler/parser_generator/expr_generator.rb', line 30

def gen_intermediate_assert(parser, scope = ParserScope.empty)
  gen_assert parser, scope
end

#gen_intermediate_disallow(parser, scope = ParserScope.empty) ⇒ Object



34
35
36
# File 'lib/rattler/compiler/parser_generator/expr_generator.rb', line 34

def gen_intermediate_disallow(parser, scope = ParserScope.empty)
  gen_disallow parser, scope
end

#gen_intermediate_skip(parser, scope = ParserScope.empty) ⇒ Object



38
39
40
# File 'lib/rattler/compiler/parser_generator/expr_generator.rb', line 38

def gen_intermediate_skip(parser, scope = ParserScope.empty)
  gen_skip parser, scope
end

#gen_token(parser, scope = ParserScope.empty) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rattler/compiler/parser_generator/expr_generator.rb', line 17

def gen_token(parser, scope = ParserScope.empty)
  expr :block do
    (@g << "#{token_pos_name} = @scanner.pos").newline
    gen_intermediate_skip parser, scope
    (@g << ' &&').newline
    @g << "@scanner.string[#{token_pos_name}...(@scanner.pos)]"
  end
end