Class: Treetop::Compiler::Grammar
- Inherits:
-
Runtime::SyntaxNode
show all
- Defined in:
- lib/puppet_x/wildfly/gems/treetop-1.6.8/lib/treetop/compiler/node_classes/grammar.rb
Instance Attribute Summary
#input, #interval, #parent
Instance Method Summary
collapse
#<=>, #dot_id, #elements, #empty?, #extension_modules, #initialize, #inspect, #inspect_children, #inspect_self, #nonterminal?, #terminal?, #text_value, #write_dot, #write_dot_file
Instance Method Details
#compile ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/puppet_x/wildfly/gems/treetop-1.6.8/lib/treetop/compiler/node_classes/grammar.rb', line 4
def compile
builder = RubyBuilder.new
builder.module_declaration "#{grammar_name.text_value}" do
builder.in(indent_level) builder << "include Treetop::Runtime"
builder.newline
declaration_sequence.compile(builder)
end
builder.newline
builder.class_declaration "#{parser_name} < Treetop::Runtime::CompiledParser" do
builder << "include #{grammar_name.text_value}"
end
end
|
#indent_level ⇒ Object
19
20
21
|
# File 'lib/puppet_x/wildfly/gems/treetop-1.6.8/lib/treetop/compiler/node_classes/grammar.rb', line 19
def indent_level
input.column_of(interval.begin) - 1
end
|
#parser_name ⇒ Object
23
24
25
|
# File 'lib/puppet_x/wildfly/gems/treetop-1.6.8/lib/treetop/compiler/node_classes/grammar.rb', line 23
def parser_name
grammar_name.text_value + 'Parser'
end
|