Class: Rattler::Compiler::ParserGenerator::GeneralRepeatGenerator
Class Method Summary
collapse
Instance Method Summary
collapse
#gen_nested, #gen_top_level, #generate
#gen_intermediate, #gen_intermediate_assert, #gen_intermediate_disallow, #gen_intermediate_skip, #initialize
Class Method Details
.top_level(*args) ⇒ Object
Instance Method Details
#gen_assert(repeat, scope = ParserScope.empty) ⇒ Object
17
18
19
|
# File 'lib/rattler/compiler/parser_generator/general_repeat_generator.rb', line 17
def gen_assert(repeat, scope = ParserScope.empty)
gen_predicate(repeat, scope) { gen_assert_result repeat }
end
|
#gen_basic(repeat, scope = ParserScope.empty) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/rattler/compiler/parser_generator/general_repeat_generator.rb', line 9
def gen_basic(repeat, scope = ParserScope.empty)
if repeat.capturing?
gen_capturing repeat, scope
else
gen_skip repeat, scope
end
end
|
#gen_disallow(repeat, scope = ParserScope.empty) ⇒ Object
21
22
23
|
# File 'lib/rattler/compiler/parser_generator/general_repeat_generator.rb', line 21
def gen_disallow(repeat, scope = ParserScope.empty)
gen_predicate(repeat, scope) { gen_disallow_result repeat }
end
|
#gen_skip(repeat, scope = ParserScope.empty) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/rattler/compiler/parser_generator/general_repeat_generator.rb', line 32
def gen_skip(repeat, scope = ParserScope.empty)
expr :block do
setup_skip_loop repeat
@g << 'while '
generate repeat.child, :intermediate_skip, scope
@g.block('') { gen_skip_loop_body repeat }.newline
gen_skip_result repeat
end
end
|
#gen_token(repeat, scope = ParserScope.empty) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/rattler/compiler/parser_generator/general_repeat_generator.rb', line 25
def gen_token(repeat, scope = ParserScope.empty)
expr :block do
gen_loop(repeat, scope) { |child| generate child, :token, scope }
gen_result repeat, "#{accumulator_name}.join"
end
end
|