Class: Rattler::BackEnd::ParserGenerator::GeneralRepeatGenerator
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Parsers
define
#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 = {}) ⇒ Object
17
18
19
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 17
def gen_assert(repeat, scope={})
gen_predicate(repeat, scope) { gen_assert_result repeat }
end
|
#gen_basic(repeat, scope = {}) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 9
def gen_basic(repeat, scope={})
if repeat.capturing?
gen_capturing repeat, scope
else
gen_skip repeat, scope
end
end
|
#gen_direct_action(repeat, code, scope = {}) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 32
def gen_direct_action(repeat, code, scope={})
expr :block do
gen_loop repeat, scope
gen_result(repeat, '(' + code.bind(scope, ["select_captures(#{accumulator_name})"]) + ')')
end
end
|
#gen_disallow(repeat, scope = {}) ⇒ Object
21
22
23
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 21
def gen_disallow(repeat, scope={})
gen_predicate(repeat, scope) { gen_disallow_result repeat }
end
|
#gen_dispatch_action(repeat, code, scope = {}) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 25
def gen_dispatch_action(repeat, code, scope={})
expr :block do
gen_loop repeat, scope
gen_result repeat, code.bind(scope, "select_captures(#{accumulator_name})")
end
end
|
#gen_skip(repeat, scope = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 46
def gen_skip(repeat, scope={})
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 = {}) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/rattler/back_end/parser_generator/general_repeat_generator.rb', line 39
def gen_token(repeat, scope={})
expr :block do
gen_loop(repeat, scope) { |child| generate child, :token, scope }
gen_result repeat, "#{accumulator_name}.join"
end
end
|