Class: Rattler::Compiler::ParserGenerator::GeneralListGenerator
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, #gen_token
Constructor Details
Returns a new instance of GeneralListGenerator.
9
10
11
12
|
# File 'lib/rattler/compiler/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 = ParserScope.empty) ⇒ Object
22
23
24
25
26
|
# File 'lib/rattler/compiler/parser_generator/general_list_generator.rb', line 22
def gen_assert(list, scope = ParserScope.empty)
gen_predicate(list, scope) do
@g.newline << "#{count_name} >= #{list.lower_bound}"
end
end
|
#gen_basic(list, scope = ParserScope.empty) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/rattler/compiler/parser_generator/general_list_generator.rb', line 14
def gen_basic(list, scope = ParserScope.empty)
if list.capturing?
gen_capturing list, scope
else
gen_skip list, scope
end
end
|
#gen_disallow(list, scope = ParserScope.empty) ⇒ Object
28
29
30
31
32
|
# File 'lib/rattler/compiler/parser_generator/general_list_generator.rb', line 28
def gen_disallow(list, scope = ParserScope.empty)
gen_predicate(list, scope) do
@g.newline << "#{count_name} < #{list.lower_bound}"
end
end
|
#gen_skip(list, scope = ParserScope.empty) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/rattler/compiler/parser_generator/general_list_generator.rb', line 34
def gen_skip(list, scope = ParserScope.empty)
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
|