mail 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mail might be problematic. Click here for more details.
- data/Rakefile +1 -1
- data/lib/mail.rb +2 -1
- data/lib/mail/version.rb +1 -1
- data/lib/vendor/treetop-1.4.3/History.txt +18 -0
- data/lib/vendor/treetop-1.4.3/LICENSE +19 -0
- data/lib/vendor/treetop-1.4.3/README.md +164 -0
- data/lib/vendor/treetop-1.4.3/Rakefile +23 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +20 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +18 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +1524 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Support/syntax_tree_viewer.rb +117 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +251 -0
- data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/info.plist +10 -0
- data/lib/vendor/treetop-1.4.3/benchmark/seqpar.gnuplot +15 -0
- data/lib/vendor/treetop-1.4.3/benchmark/seqpar.treetop +16 -0
- data/lib/vendor/treetop-1.4.3/benchmark/seqpar_benchmark.rb +107 -0
- data/lib/vendor/treetop-1.4.3/bin/tt +112 -0
- data/lib/vendor/treetop-1.4.3/doc/contributing_and_planned_features.markdown +103 -0
- data/lib/vendor/treetop-1.4.3/doc/grammar_composition.markdown +65 -0
- data/lib/vendor/treetop-1.4.3/doc/index.markdown +90 -0
- data/lib/vendor/treetop-1.4.3/doc/pitfalls_and_advanced_techniques.markdown +51 -0
- data/lib/vendor/treetop-1.4.3/doc/semantic_interpretation.markdown +189 -0
- data/lib/vendor/treetop-1.4.3/doc/site.rb +112 -0
- data/lib/vendor/treetop-1.4.3/doc/sitegen.rb +65 -0
- data/lib/vendor/treetop-1.4.3/doc/syntactic_recognition.markdown +100 -0
- data/lib/vendor/treetop-1.4.3/doc/using_in_ruby.markdown +21 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic.rb +551 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic.treetop +97 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic_node_classes.rb +7 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic_test.rb +54 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus +0 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus.rb +718 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus.treetop +132 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus_node_classes.rb +5 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus_test.rb +89 -0
- data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/test_helper.rb +18 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop.rb +17 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/bootstrap_gen_1_metagrammar.rb +45 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler.rb +6 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/grammar_compiler.rb +44 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/lexical_address_space.rb +17 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/metagrammar.rb +3366 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/metagrammar.treetop +436 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes.rb +20 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/anything_symbol.rb +18 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/atomic_expression.rb +14 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/character_class.rb +28 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/choice.rb +31 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/grammar.rb +28 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/nonterminal.rb +13 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/optional.rb +19 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/parsing_expression.rb +146 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/parsing_rule.rb +58 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/predicate.rb +45 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/predicate_block.rb +16 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/repetition.rb +55 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/sequence.rb +71 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/terminal.rb +20 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/transient_prefix.rb +9 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/ruby_builder.rb +113 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/ruby_extensions.rb +2 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/ruby_extensions/string.rb +42 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime.rb +5 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/compiled_parser.rb +110 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list.rb +4 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list/head_node.rb +15 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +200 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list/node.rb +164 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/syntax_node.rb +114 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/terminal_parse_failure.rb +16 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/terminal_syntax_node.rb +17 -0
- data/lib/vendor/treetop-1.4.3/lib/treetop/version.rb +9 -0
- data/lib/vendor/treetop-1.4.3/script/generate_metagrammar.rb +14 -0
- data/lib/vendor/treetop-1.4.3/script/svnadd +11 -0
- data/lib/vendor/treetop-1.4.3/script/svnrm +11 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/and_predicate_spec.rb +36 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/anything_symbol_spec.rb +44 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/character_class_spec.rb +276 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/choice_spec.rb +80 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/circular_compilation_spec.rb +28 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/failure_propagation_functional_spec.rb +21 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/grammar_compiler_spec.rb +84 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/grammar_spec.rb +41 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/multibyte_chars_spec.rb +46 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/nonterminal_symbol_spec.rb +40 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/not_predicate_spec.rb +38 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/one_or_more_spec.rb +35 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/optional_spec.rb +37 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/parenthesized_expression_spec.rb +19 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/parsing_rule_spec.rb +61 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/repeated_subrule_spec.rb +29 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/semantic_predicate_spec.rb +175 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/sequence_spec.rb +115 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/terminal_spec.rb +81 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/terminal_symbol_spec.rb +37 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/test_grammar.treetop +7 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/test_grammar.tt +7 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/test_grammar_do.treetop +7 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/tt_compiler_spec.rb +216 -0
- data/lib/vendor/treetop-1.4.3/spec/compiler/zero_or_more_spec.rb +56 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/a.treetop +11 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/b.treetop +11 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/c.treetop +10 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/d.treetop +10 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/f.treetop +17 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/grammar_composition_spec.rb +40 -0
- data/lib/vendor/treetop-1.4.3/spec/composition/subfolder/e_includes_c.treetop +15 -0
- data/lib/vendor/treetop-1.4.3/spec/ruby_extensions/string_spec.rb +32 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/compiled_parser_spec.rb +101 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/delete_spec.rb +147 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/expire_range_spec.rb +349 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/insert_and_delete_node.rb +385 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/insert_spec.rb +660 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +6175 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +58 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/palindromic_fixture.rb +23 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +164 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/spec_helper.rb +84 -0
- data/lib/vendor/treetop-1.4.3/spec/runtime/syntax_node_spec.rb +77 -0
- data/lib/vendor/treetop-1.4.3/spec/spec_helper.rb +110 -0
- data/lib/vendor/treetop-1.4.3/spec/spec_suite.rb +4 -0
- data/lib/vendor/treetop-1.4.3/treetop.gemspec +18 -0
- data/lib/vendor/treetop.rb +5 -0
- metadata +126 -11
@@ -0,0 +1,436 @@
|
|
1
|
+
module Treetop
|
2
|
+
module Compiler
|
3
|
+
grammar Metagrammar
|
4
|
+
rule treetop_file
|
5
|
+
requires:(space? require_statement)* prefix:space? module_or_grammar:(module_declaration / grammar) suffix:space? {
|
6
|
+
def compile
|
7
|
+
requires.text_value + prefix.text_value + module_or_grammar.compile + suffix.text_value
|
8
|
+
end
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
rule require_statement
|
13
|
+
prefix:space? "require" [ \t]+ [^\n\r]+ [\n\r]
|
14
|
+
end
|
15
|
+
|
16
|
+
rule module_declaration
|
17
|
+
prefix:('module' space [A-Z] alphanumeric_char* space) module_contents:(module_declaration / grammar) suffix:(space 'end') {
|
18
|
+
def compile
|
19
|
+
prefix.text_value + module_contents.compile + suffix.text_value
|
20
|
+
end
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
rule grammar
|
25
|
+
'grammar' space grammar_name space ('do' space)? declaration_sequence space? 'end' <Grammar>
|
26
|
+
end
|
27
|
+
|
28
|
+
rule grammar_name
|
29
|
+
([A-Z] alphanumeric_char*)
|
30
|
+
end
|
31
|
+
|
32
|
+
rule declaration_sequence
|
33
|
+
head:declaration tail:(space declaration)* <DeclarationSequence> {
|
34
|
+
def declarations
|
35
|
+
[head] + tail
|
36
|
+
end
|
37
|
+
|
38
|
+
def tail
|
39
|
+
super.elements.map { |elt| elt.declaration }
|
40
|
+
end
|
41
|
+
}
|
42
|
+
/
|
43
|
+
'' {
|
44
|
+
def compile(builder)
|
45
|
+
end
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
rule declaration
|
50
|
+
parsing_rule / include_declaration
|
51
|
+
end
|
52
|
+
|
53
|
+
rule include_declaration
|
54
|
+
'include' space [A-Z] (alphanumeric_char / '::')* {
|
55
|
+
def compile(builder)
|
56
|
+
builder << text_value
|
57
|
+
end
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
rule parsing_rule
|
62
|
+
'rule' space nonterminal space ('do' space)? parsing_expression space 'end' <ParsingRule>
|
63
|
+
end
|
64
|
+
|
65
|
+
rule parsing_expression
|
66
|
+
choice / sequence / primary
|
67
|
+
end
|
68
|
+
|
69
|
+
rule choice
|
70
|
+
head:alternative tail:(space? '/' space? alternative)+ <Choice> {
|
71
|
+
def alternatives
|
72
|
+
[head] + tail
|
73
|
+
end
|
74
|
+
|
75
|
+
def tail
|
76
|
+
super.elements.map {|elt| elt.alternative}
|
77
|
+
end
|
78
|
+
|
79
|
+
def inline_modules
|
80
|
+
(alternatives.map {|alt| alt.inline_modules }).flatten
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
rule sequence
|
86
|
+
head:labeled_sequence_primary tail:(space labeled_sequence_primary)+ node_class_declarations <Sequence> {
|
87
|
+
def sequence_elements
|
88
|
+
[head] + tail
|
89
|
+
end
|
90
|
+
|
91
|
+
def tail
|
92
|
+
super.elements.map {|elt| elt.labeled_sequence_primary }
|
93
|
+
end
|
94
|
+
|
95
|
+
def inline_modules
|
96
|
+
(sequence_elements.map {|elt| elt.inline_modules}).flatten +
|
97
|
+
[sequence_element_accessor_module] +
|
98
|
+
node_class_declarations.inline_modules
|
99
|
+
end
|
100
|
+
|
101
|
+
def inline_module_name
|
102
|
+
node_class_declarations.inline_module_name
|
103
|
+
end
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
rule alternative
|
108
|
+
sequence / primary
|
109
|
+
end
|
110
|
+
|
111
|
+
rule primary
|
112
|
+
prefix atomic {
|
113
|
+
def compile(address, builder, parent_expression=nil)
|
114
|
+
prefix.compile(address, builder, self)
|
115
|
+
end
|
116
|
+
|
117
|
+
def prefixed_expression
|
118
|
+
atomic
|
119
|
+
end
|
120
|
+
|
121
|
+
def inline_modules
|
122
|
+
atomic.inline_modules
|
123
|
+
end
|
124
|
+
|
125
|
+
def inline_module_name
|
126
|
+
nil
|
127
|
+
end
|
128
|
+
}
|
129
|
+
/
|
130
|
+
prefix space? predicate_block {
|
131
|
+
def compile(address, builder, parent_expression=nil)
|
132
|
+
prefix.compile(address, builder, self)
|
133
|
+
end
|
134
|
+
def prefixed_expression
|
135
|
+
predicate_block
|
136
|
+
end
|
137
|
+
def inline_modules
|
138
|
+
[]
|
139
|
+
end
|
140
|
+
}
|
141
|
+
/
|
142
|
+
atomic suffix node_class_declarations {
|
143
|
+
def compile(address, builder, parent_expression=nil)
|
144
|
+
suffix.compile(address, builder, self)
|
145
|
+
end
|
146
|
+
|
147
|
+
def optional_expression
|
148
|
+
atomic
|
149
|
+
end
|
150
|
+
|
151
|
+
def node_class_name
|
152
|
+
node_class_declarations.node_class_name
|
153
|
+
end
|
154
|
+
|
155
|
+
def inline_modules
|
156
|
+
atomic.inline_modules + node_class_declarations.inline_modules
|
157
|
+
end
|
158
|
+
|
159
|
+
def inline_module_name
|
160
|
+
node_class_declarations.inline_module_name
|
161
|
+
end
|
162
|
+
}
|
163
|
+
/
|
164
|
+
atomic node_class_declarations {
|
165
|
+
def compile(address, builder, parent_expression=nil)
|
166
|
+
atomic.compile(address, builder, self)
|
167
|
+
end
|
168
|
+
|
169
|
+
def node_class_name
|
170
|
+
node_class_declarations.node_class_name
|
171
|
+
end
|
172
|
+
|
173
|
+
def inline_modules
|
174
|
+
atomic.inline_modules + node_class_declarations.inline_modules
|
175
|
+
end
|
176
|
+
|
177
|
+
def inline_module_name
|
178
|
+
node_class_declarations.inline_module_name
|
179
|
+
end
|
180
|
+
}
|
181
|
+
end
|
182
|
+
|
183
|
+
rule labeled_sequence_primary
|
184
|
+
label sequence_primary {
|
185
|
+
def compile(lexical_address, builder)
|
186
|
+
sequence_primary.compile(lexical_address, builder)
|
187
|
+
end
|
188
|
+
|
189
|
+
def inline_modules
|
190
|
+
sequence_primary.inline_modules
|
191
|
+
end
|
192
|
+
|
193
|
+
def label_name
|
194
|
+
if label.name
|
195
|
+
label.name
|
196
|
+
elsif sequence_primary.instance_of?(Nonterminal)
|
197
|
+
sequence_primary.text_value
|
198
|
+
else
|
199
|
+
nil
|
200
|
+
end
|
201
|
+
end
|
202
|
+
}
|
203
|
+
end
|
204
|
+
|
205
|
+
rule label
|
206
|
+
(alpha_char alphanumeric_char*) ':' {
|
207
|
+
def name
|
208
|
+
elements[0].text_value
|
209
|
+
end
|
210
|
+
}
|
211
|
+
/
|
212
|
+
'' {
|
213
|
+
def name
|
214
|
+
nil
|
215
|
+
end
|
216
|
+
}
|
217
|
+
end
|
218
|
+
|
219
|
+
rule sequence_primary
|
220
|
+
prefix atomic {
|
221
|
+
def compile(lexical_address, builder)
|
222
|
+
prefix.compile(lexical_address, builder, self)
|
223
|
+
end
|
224
|
+
|
225
|
+
def prefixed_expression
|
226
|
+
elements[1]
|
227
|
+
end
|
228
|
+
|
229
|
+
def inline_modules
|
230
|
+
atomic.inline_modules
|
231
|
+
end
|
232
|
+
|
233
|
+
def inline_module_name
|
234
|
+
nil
|
235
|
+
end
|
236
|
+
}
|
237
|
+
/
|
238
|
+
prefix space? predicate_block {
|
239
|
+
def compile(address, builder, parent_expression=nil)
|
240
|
+
prefix.compile(address, builder, self)
|
241
|
+
end
|
242
|
+
def prefixed_expression
|
243
|
+
predicate_block
|
244
|
+
end
|
245
|
+
def inline_modules
|
246
|
+
[]
|
247
|
+
end
|
248
|
+
}
|
249
|
+
/
|
250
|
+
atomic suffix {
|
251
|
+
def compile(lexical_address, builder)
|
252
|
+
suffix.compile(lexical_address, builder, self)
|
253
|
+
end
|
254
|
+
|
255
|
+
def node_class_name
|
256
|
+
nil
|
257
|
+
end
|
258
|
+
|
259
|
+
def inline_modules
|
260
|
+
atomic.inline_modules
|
261
|
+
end
|
262
|
+
|
263
|
+
def inline_module_name
|
264
|
+
nil
|
265
|
+
end
|
266
|
+
}
|
267
|
+
/
|
268
|
+
atomic
|
269
|
+
end
|
270
|
+
|
271
|
+
rule suffix
|
272
|
+
repetition_suffix / optional_suffix
|
273
|
+
end
|
274
|
+
|
275
|
+
rule optional_suffix
|
276
|
+
'?' <Optional>
|
277
|
+
end
|
278
|
+
|
279
|
+
rule node_class_declarations
|
280
|
+
node_class_expression trailing_inline_module {
|
281
|
+
def node_class_name
|
282
|
+
node_class_expression.node_class_name
|
283
|
+
end
|
284
|
+
|
285
|
+
def inline_modules
|
286
|
+
trailing_inline_module.inline_modules
|
287
|
+
end
|
288
|
+
|
289
|
+
def inline_module
|
290
|
+
trailing_inline_module.inline_module
|
291
|
+
end
|
292
|
+
|
293
|
+
def inline_module_name
|
294
|
+
inline_module.module_name if inline_module
|
295
|
+
end
|
296
|
+
}
|
297
|
+
end
|
298
|
+
|
299
|
+
rule repetition_suffix
|
300
|
+
'+' <OneOrMore> / '*' <ZeroOrMore>
|
301
|
+
end
|
302
|
+
|
303
|
+
rule prefix
|
304
|
+
'&' <AndPredicate> / '!' <NotPredicate> / '~' <TransientPrefix>
|
305
|
+
end
|
306
|
+
|
307
|
+
rule atomic
|
308
|
+
terminal
|
309
|
+
/
|
310
|
+
nonterminal
|
311
|
+
/
|
312
|
+
parenthesized_expression
|
313
|
+
end
|
314
|
+
|
315
|
+
rule parenthesized_expression
|
316
|
+
'(' space? parsing_expression space? ')' <ParenthesizedExpression> {
|
317
|
+
def inline_modules
|
318
|
+
parsing_expression.inline_modules
|
319
|
+
end
|
320
|
+
}
|
321
|
+
end
|
322
|
+
|
323
|
+
rule nonterminal
|
324
|
+
!keyword_inside_grammar (alpha_char alphanumeric_char*) <Nonterminal>
|
325
|
+
end
|
326
|
+
|
327
|
+
rule terminal
|
328
|
+
quoted_string / character_class / anything_symbol
|
329
|
+
end
|
330
|
+
|
331
|
+
rule quoted_string
|
332
|
+
(single_quoted_string / double_quoted_string) {
|
333
|
+
def string
|
334
|
+
super.text_value
|
335
|
+
end
|
336
|
+
}
|
337
|
+
end
|
338
|
+
|
339
|
+
rule double_quoted_string
|
340
|
+
'"' string:(!'"' ("\\\\" / '\"' / .))* '"' <Terminal>
|
341
|
+
end
|
342
|
+
|
343
|
+
rule single_quoted_string
|
344
|
+
"'" string:(!"'" ("\\\\" / "\\'" / .))* "'" <Terminal>
|
345
|
+
end
|
346
|
+
|
347
|
+
rule character_class
|
348
|
+
'[' characters:(!']' ('\\' . /!'\\' .))+ ']' <CharacterClass> {
|
349
|
+
def characters
|
350
|
+
super.text_value
|
351
|
+
end
|
352
|
+
}
|
353
|
+
end
|
354
|
+
|
355
|
+
rule anything_symbol
|
356
|
+
'.' <AnythingSymbol>
|
357
|
+
end
|
358
|
+
|
359
|
+
rule node_class_expression
|
360
|
+
space '<' (!'>' .)+ '>' {
|
361
|
+
def node_class_name
|
362
|
+
elements[2].text_value
|
363
|
+
end
|
364
|
+
}
|
365
|
+
/
|
366
|
+
'' {
|
367
|
+
def node_class_name
|
368
|
+
nil
|
369
|
+
end
|
370
|
+
}
|
371
|
+
end
|
372
|
+
|
373
|
+
rule trailing_inline_module
|
374
|
+
space inline_module {
|
375
|
+
def inline_modules
|
376
|
+
[inline_module]
|
377
|
+
end
|
378
|
+
|
379
|
+
def inline_module_name
|
380
|
+
inline_module.module_name
|
381
|
+
end
|
382
|
+
}
|
383
|
+
/
|
384
|
+
'' {
|
385
|
+
def inline_modules
|
386
|
+
[]
|
387
|
+
end
|
388
|
+
|
389
|
+
def inline_module
|
390
|
+
nil
|
391
|
+
end
|
392
|
+
|
393
|
+
def inline_module_name
|
394
|
+
nil
|
395
|
+
end
|
396
|
+
}
|
397
|
+
end
|
398
|
+
|
399
|
+
rule predicate_block
|
400
|
+
'' inline_module <PredicateBlock>
|
401
|
+
end
|
402
|
+
|
403
|
+
rule inline_module
|
404
|
+
'{' (inline_module / ![{}] .)* '}' <InlineModule>
|
405
|
+
end
|
406
|
+
|
407
|
+
rule keyword_inside_grammar
|
408
|
+
('rule' / 'end') !non_space_char
|
409
|
+
end
|
410
|
+
|
411
|
+
rule non_space_char
|
412
|
+
!space .
|
413
|
+
end
|
414
|
+
|
415
|
+
rule alpha_char
|
416
|
+
[A-Za-z_]
|
417
|
+
end
|
418
|
+
|
419
|
+
rule alphanumeric_char
|
420
|
+
alpha_char / [0-9]
|
421
|
+
end
|
422
|
+
|
423
|
+
rule space
|
424
|
+
(white / comment_to_eol)+
|
425
|
+
end
|
426
|
+
|
427
|
+
rule comment_to_eol
|
428
|
+
'#' (!"\n" .)*
|
429
|
+
end
|
430
|
+
|
431
|
+
rule white
|
432
|
+
[ \t\n\r]
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
require File.join(dir, *%w[node_classes parsing_expression])
|
3
|
+
require File.join(dir, *%w[node_classes atomic_expression])
|
4
|
+
require File.join(dir, *%w[node_classes inline_module])
|
5
|
+
require File.join(dir, *%w[node_classes predicate_block])
|
6
|
+
require File.join(dir, *%w[node_classes treetop_file])
|
7
|
+
require File.join(dir, *%w[node_classes grammar])
|
8
|
+
require File.join(dir, *%w[node_classes declaration_sequence])
|
9
|
+
require File.join(dir, *%w[node_classes parsing_rule])
|
10
|
+
require File.join(dir, *%w[node_classes parenthesized_expression])
|
11
|
+
require File.join(dir, *%w[node_classes nonterminal])
|
12
|
+
require File.join(dir, *%w[node_classes terminal])
|
13
|
+
require File.join(dir, *%w[node_classes anything_symbol])
|
14
|
+
require File.join(dir, *%w[node_classes character_class])
|
15
|
+
require File.join(dir, *%w[node_classes sequence])
|
16
|
+
require File.join(dir, *%w[node_classes choice])
|
17
|
+
require File.join(dir, *%w[node_classes repetition])
|
18
|
+
require File.join(dir, *%w[node_classes optional])
|
19
|
+
require File.join(dir, *%w[node_classes predicate])
|
20
|
+
require File.join(dir, *%w[node_classes transient_prefix])
|