Class: Rattler::Compiler::ParserGenerator::ChoiceGenerator
Class Method Summary
collapse
Instance Method Summary
collapse
#gen_nested, #gen_top_level, #generate
#gen_intermediate, #gen_intermediate_disallow, #initialize
Class Method Details
.top_level(*args) ⇒ Object
Instance Method Details
#gen_assert(choice, scope = ParserScope.empty) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 15
def gen_assert(choice, scope = ParserScope.empty)
expr do
gen_intermediate_assert choice, scope
@g << ' && true'
end
end
|
#gen_basic(choice, scope = ParserScope.empty) ⇒ Object
9
10
11
12
13
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 9
def gen_basic(choice, scope = ParserScope.empty)
expr :block do
@g.intersperse_nl(choice, ' ||') {|_| generate _, :basic, scope }
end
end
|
#gen_disallow(choice, scope = ParserScope.empty) ⇒ Object
22
23
24
25
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 22
def gen_disallow(choice, scope = ParserScope.empty)
@g << '!'
gen_intermediate_assert choice, scope
end
|
40
41
42
43
44
45
46
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 40
def gen_intermediate_assert(choice, scope = ParserScope.empty)
@g.block 'begin' do
@g.intersperse_nl(choice, ' ||') do |_|
generate _, :intermediate_assert, scope
end
end
end
|
48
49
50
51
52
53
54
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 48
def gen_intermediate_skip(choice, scope = ParserScope.empty)
@g.block 'begin' do
@g.intersperse_nl(choice, ' ||') do |_|
generate _, :intermediate_skip, scope
end
end
end
|
#gen_skip(choice, scope = ParserScope.empty) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 33
def gen_skip(choice, scope = ParserScope.empty)
expr do
gen_intermediate_skip choice, scope
@g << ' && true'
end
end
|
#gen_token(choice, scope = ParserScope.empty) ⇒ Object
27
28
29
30
31
|
# File 'lib/rattler/compiler/parser_generator/choice_generator.rb', line 27
def gen_token(choice, scope = ParserScope.empty)
expr :block do
@g.intersperse_nl(choice, ' ||') {|_| generate _, :token, scope }
end
end
|