Class: Rattler::BackEnd::ParserGenerator::ExprGenerator
- Inherits:
-
Object
- Object
- Rattler::BackEnd::ParserGenerator::ExprGenerator
show all
- Includes:
- Parsers
- Defined in:
- lib/rattler/back_end/parser_generator/expr_generator.rb
Direct Known Subclasses
ApplyGenerator, AssertGenerator, BackReferenceGenerator, ChoiceGenerator, DelegatingGenerator, DirectActionGenerator, DisallowGenerator, DispatchActionGenerator, ESymbolGenerator, EofGenerator, FailGenerator, GeneralListGenerator, GeneralRepeatGenerator, GroupMatchGenerator, LabelGenerator, MatchGenerator, SequenceGenerator, SkipGenerator, TokenGenerator, TopLevelGenerator
Instance Method Summary
collapse
-
#gen_direct_action(parser, code, scope = {}) ⇒ Object
-
#gen_dispatch_action(parser, code, scope = {}) ⇒ Object
-
#gen_intermediate(parser, scope = {}) ⇒ Object
-
#gen_intermediate_assert(parser, scope = {}) ⇒ Object
-
#gen_intermediate_disallow(parser, scope = {}) ⇒ Object
-
#gen_intermediate_skip(parser, scope = {}) ⇒ Object
-
#gen_token(parser, scope = {}) ⇒ Object
-
#initialize(g, choice_level = nil, sequence_level = nil, repeat_level = nil) ⇒ ExprGenerator
constructor
A new instance of ExprGenerator.
Methods included from Parsers
define
Constructor Details
#initialize(g, choice_level = nil, sequence_level = nil, repeat_level = nil) ⇒ ExprGenerator
Returns a new instance of ExprGenerator.
10
11
12
13
14
15
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 10
def initialize(g, choice_level=nil, sequence_level=nil, repeat_level=nil)
@g = g
@choice_level = choice_level
@sequence_level = sequence_level
@repeat_level = repeat_level
end
|
Instance Method Details
#gen_direct_action(parser, code, scope = {}) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 24
def gen_direct_action(parser, code, scope={})
expr :block do
gen_capture { block_given? ? yield : gen_basic(parser, scope) }
(@g << ' &&').newline << '(' << code.bind(scope, direct_action_args) << ')'
end
end
|
#gen_dispatch_action(parser, code, scope = {}) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 17
def gen_dispatch_action(parser, code, scope={})
expr :block do
gen_capture { block_given? ? yield : gen_basic(parser, scope) }
(@g << ' &&').newline << code.bind(scope, dispatch_action_args)
end
end
|
40
41
42
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 40
def gen_intermediate(parser, scope={})
gen_basic parser, scope
end
|
44
45
46
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 44
def gen_intermediate_assert(parser, scope={})
gen_assert parser, scope
end
|
48
49
50
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 48
def gen_intermediate_disallow(parser, scope={})
gen_disallow parser, scope
end
|
52
53
54
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 52
def gen_intermediate_skip(parser, scope={})
gen_skip parser, scope
end
|
#gen_token(parser, scope = {}) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/rattler/back_end/parser_generator/expr_generator.rb', line 31
def gen_token(parser, scope={})
expr :block do
(@g << "#{token_pos_name} = @scanner.pos").newline
gen_intermediate_skip parser, scope
(@g << ' &&').newline
@g << "@scanner.string[#{token_pos_name}...(@scanner.pos)]"
end
end
|