Class: Rattler::Compiler::ParserGenerator::SuperGenerator

Inherits:
ExprGenerator
  • Object
show all
Defined in:
lib/rattler/compiler/parser_generator/super_generator.rb

Direct Known Subclasses

NestedSuperGenerator, TopLevelSuperGenerator

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ExprGenerator

#gen_intermediate, #gen_intermediate_assert, #gen_intermediate_disallow, #gen_intermediate_skip, #initialize

Constructor Details

This class inherits a constructor from Rattler::Compiler::ParserGenerator::ExprGenerator

Class Method Details

.nested(*args) ⇒ Object



41
42
43
# File 'lib/rattler/compiler/parser_generator/super_generator.rb', line 41

def SuperGenerator.nested(*args)
  NestedSuperGenerator.new(*args)
end

.top_level(*args) ⇒ Object



50
51
52
# File 'lib/rattler/compiler/parser_generator/super_generator.rb', line 50

def SuperGenerator.top_level(*args)
  TopLevelSuperGenerator.new(*args)
end

Instance Method Details

#gen_assert(*_) ⇒ Object



12
13
14
15
16
17
# File 'lib/rattler/compiler/parser_generator/super_generator.rb', line 12

def gen_assert(*_)
  expr :block do
    lookahead { (@g << "#{result_name} = (super && true)").newline }
    @g << result_name
  end
end

#gen_basic(*_) ⇒ Object

:nodoc:



8
9
10
# File 'lib/rattler/compiler/parser_generator/super_generator.rb', line 8

def gen_basic(*_)
  @g << 'super'
end

#gen_disallow(*_) ⇒ Object



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

def gen_disallow(*_)
  expr :block do
    lookahead { (@g << "#{result_name} = !super").newline }
    @g << result_name
  end
end

#gen_skip(*_) ⇒ Object



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

def gen_skip(*_)
  expr { @g << 'super && true' }
end

#gen_token(*_) ⇒ Object



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

def gen_token(*_)
  @g << 'super.to_s'
end