Class: Rattler::BackEnd::ParserGenerator::ChoiceGenerator
Class Method Summary
collapse
Instance Method Summary
collapse
-
#gen_assert(choice, scope = {}) ⇒ Object
-
#gen_basic(choice, scope = {}) ⇒ Object
-
#gen_direct_action(choice, code, scope = {}) ⇒ Object
-
#gen_disallow(choice, scope = {}) ⇒ Object
-
#gen_dispatch_action(choice, code, scope = {}) ⇒ Object
-
#gen_intermediate_assert(choice, scope = {}) ⇒ Object
-
#gen_intermediate_skip(choice, scope = {}) ⇒ Object
-
#gen_skip(choice, scope = {}) ⇒ Object
-
#gen_token(choice, scope = {}) ⇒ Object
Methods included from Parsers
define
#gen_intermediate, #gen_intermediate_disallow, #initialize
Class Method Details
.top_level(*args) ⇒ Object
Instance Method Details
#gen_assert(choice, scope = {}) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 15
def gen_assert(choice, scope={})
expr do
gen_intermediate_assert choice, scope
@g << ' && true'
end
end
|
#gen_basic(choice, scope = {}) ⇒ Object
9
10
11
12
13
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 9
def gen_basic(choice, scope={})
expr :block do
@g.intersperse_nl(choice, ' ||') {|_| generate _, :basic, scope }
end
end
|
#gen_direct_action(choice, code, scope = {}) ⇒ Object
33
34
35
36
37
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 33
def gen_direct_action(choice, code, scope={})
expr :block do
gen_action_code(choice) { "(#{code.bind scope, [result_name]})" }
end
end
|
#gen_disallow(choice, scope = {}) ⇒ Object
22
23
24
25
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 22
def gen_disallow(choice, scope={})
@g << '!'
gen_intermediate_assert choice, scope
end
|
#gen_dispatch_action(choice, code, scope = {}) ⇒ Object
27
28
29
30
31
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 27
def gen_dispatch_action(choice, code, scope={})
expr :block do
gen_action_code(choice) { code.bind scope, "[#{result_name}]" }
end
end
|
52
53
54
55
56
57
58
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 52
def gen_intermediate_assert(choice, scope={})
@g.block 'begin' do
@g.intersperse_nl(choice, ' ||') do |_|
generate _, :intermediate_assert, scope
end
end
end
|
60
61
62
63
64
65
66
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 60
def gen_intermediate_skip(choice, scope={})
@g.block 'begin' do
@g.intersperse_nl(choice, ' ||') do |_|
generate _, :intermediate_skip, scope
end
end
end
|
#gen_skip(choice, scope = {}) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 45
def gen_skip(choice, scope={})
expr do
gen_intermediate_skip choice, scope
@g << ' && true'
end
end
|
#gen_token(choice, scope = {}) ⇒ Object
39
40
41
42
43
|
# File 'lib/rattler/back_end/parser_generator/choice_generator.rb', line 39
def gen_token(choice, scope={})
expr :block do
@g.intersperse_nl(choice, ' ||') {|_| generate _, :token, scope }
end
end
|