Class: Rattler::BackEnd::ParserGenerator::GeneralListGenerator
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Parsers
define
#gen_intermediate, #gen_intermediate_assert, #gen_intermediate_disallow, #gen_intermediate_skip, #gen_token
Constructor Details
Returns a new instance of GeneralListGenerator.
9
10
11
12
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 9
def initialize(*args)
@init_args = args
super
end
|
Class Method Details
.top_level(*args) ⇒ Object
Instance Method Details
#gen_assert(list, scope = {}) ⇒ Object
34
35
36
37
38
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 34
def gen_assert(list, scope={})
gen_predicate(list, scope) do
@g.newline << "#{count_name} >= #{list.lower_bound}"
end
end
|
#gen_basic(list, scope = {}) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 14
def gen_basic(list, scope={})
if list.capturing?
gen_capturing list, scope
else
gen_skip list, scope
end
end
|
#gen_direct_action(list, code, scope = {}) ⇒ Object
28
29
30
31
32
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 28
def gen_direct_action(list, code, scope={})
gen_capturing list, scope do |a|
'(' + code.bind(scope, ["select_captures(#{a})"]) + ')'
end
end
|
#gen_disallow(list, scope = {}) ⇒ Object
40
41
42
43
44
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 40
def gen_disallow(list, scope={})
gen_predicate(list, scope) do
@g.newline << "#{count_name} < #{list.lower_bound}"
end
end
|
#gen_dispatch_action(list, code, scope = {}) ⇒ Object
22
23
24
25
26
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 22
def gen_dispatch_action(list, code, scope={})
gen_capturing list, scope do |a|
code.bind scope, "select_captures(#{a})"
end
end
|
#gen_skip(list, scope = {}) ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/rattler/back_end/parser_generator/general_list_generator.rb', line 46
def gen_skip(list, scope={})
expr :block do
(@g << "#{count_name} = 0").newline
(@g << "#{start_pos_name} = @scanner.pos").newline
gen_skipping(list, scope) { (@g << "#{count_name} += 1").newline }
gen_skipping_result list
end
end
|