Module: Rattler::Compiler::ParserGenerator::OptionalGenerating

Defined in:
lib/rattler/compiler/parser_generator/optional_generating.rb

Instance Method Summary collapse

Instance Method Details

#gen_assert(optional, scope = ParserScope.empty) ⇒ Object

:nodoc:



7
8
9
# File 'lib/rattler/compiler/parser_generator/optional_generating.rb', line 7

def gen_assert(optional, scope = ParserScope.empty)
  @g << 'true'
end

#gen_disallow(optional, scope = ParserScope.empty) ⇒ Object



11
12
13
# File 'lib/rattler/compiler/parser_generator/optional_generating.rb', line 11

def gen_disallow(optional, scope = ParserScope.empty)
  @g << 'false'
end

#gen_skip(optional, scope = ParserScope.empty) ⇒ Object



22
23
24
25
26
27
# File 'lib/rattler/compiler/parser_generator/optional_generating.rb', line 22

def gen_skip(optional, scope = ParserScope.empty)
  expr :block do
    generate optional.child, :intermediate_skip, scope
    @g.newline << 'true'
  end
end

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



15
16
17
18
19
20
# File 'lib/rattler/compiler/parser_generator/optional_generating.rb', line 15

def gen_token(optional, scope = ParserScope.empty)
  expr :block do
    generate optional.child, :token, scope
    @g << " || ''"
  end
end