aslakhellesoy-cucumber 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/License.txt +1 -1
- data/Manifest.txt +38 -24
- data/README.textile +31 -0
- data/TODO.txt +30 -0
- data/config/hoe.rb +6 -7
- data/examples/java/README.textile +52 -0
- data/examples/java/Rakefile +12 -0
- data/examples/java/features/hello.feature +11 -0
- data/examples/java/features/steps/hello_steps.rb +25 -0
- data/examples/java/features/steps/tree_steps.rb +14 -0
- data/examples/java/features/tree.feature +9 -0
- data/examples/java/src/cucumber/demo/Hello.java +15 -0
- data/examples/pure_ruby/Rakefile +6 -0
- data/examples/pure_ruby/features/addition.rb +23 -0
- data/examples/pure_ruby/{steps → features/steps}/addition_steps.rb +0 -0
- data/examples/simple_norwegian/Rakefile +6 -0
- data/examples/simple_norwegian/{steg → features/steps}/matte_steg.rb.rb +0 -0
- data/examples/simple_norwegian/{summering.story → features/summering.feature} +4 -1
- data/examples/web/Rakefile +6 -0
- data/examples/web/features/search.feature +9 -0
- data/examples/web/features/steps/stories_steps.rb +51 -0
- data/gem_tasks/treetop.rake +8 -14
- data/lib/cucumber.rb +10 -3
- data/lib/cucumber/cli.rb +29 -19
- data/lib/cucumber/core_ext/proc.rb +13 -5
- data/lib/cucumber/executor.rb +8 -10
- data/lib/cucumber/formatters/ansicolor.rb +2 -2
- data/lib/cucumber/formatters/html_formatter.rb +6 -6
- data/lib/cucumber/formatters/pretty_formatter.rb +68 -15
- data/lib/cucumber/{parser/languages.yml → languages.yml} +0 -4
- data/lib/cucumber/rake/task.rb +24 -26
- data/lib/cucumber/step_mother.rb +3 -3
- data/lib/cucumber/tree.rb +8 -117
- data/lib/cucumber/tree/feature.rb +45 -0
- data/lib/cucumber/tree/features.rb +21 -0
- data/lib/cucumber/tree/scenario.rb +79 -0
- data/lib/cucumber/tree/step.rb +133 -0
- data/lib/cucumber/tree/table.rb +26 -0
- data/lib/cucumber/{parser → tree}/top_down_visitor.rb +5 -8
- data/lib/cucumber/treetop_parser/feature.treetop.erb +98 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +923 -0
- data/lib/cucumber/treetop_parser/feature_fr.rb +923 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +923 -0
- data/lib/cucumber/treetop_parser/feature_parser.rb +32 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +923 -0
- data/lib/cucumber/version.rb +2 -2
- data/script/console +1 -1
- data/spec/cucumber/executor_spec.rb +9 -9
- data/spec/cucumber/formatters/{stories.html → features.html} +9 -9
- data/spec/cucumber/formatters/html_formatter_spec.rb +11 -11
- data/spec/cucumber/{sell_cucumbers.story → sell_cucumbers.feature} +1 -1
- data/spec/spec_helper.rb +8 -1
- metadata +61 -30
- data/README.txt +0 -78
- data/examples/Rakefile +0 -7
- data/examples/pure_ruby/addition.rb +0 -16
- data/examples/simple/addition.story +0 -12
- data/examples/simple/division.story +0 -17
- data/examples/simple/steps/addition_steps.rb +0 -43
- data/examples/web/run_stories.story +0 -10
- data/examples/web/steps/stories_steps.rb +0 -39
- data/lib/cucumber/parser/nodes.rb +0 -88
- data/lib/cucumber/parser/story_parser.rb +0 -13
- data/lib/cucumber/parser/story_parser.treetop.erb +0 -41
- data/lib/cucumber/parser/story_parser_en.rb +0 -554
- data/lib/cucumber/parser/story_parser_fr.rb +0 -554
- data/lib/cucumber/parser/story_parser_no.rb +0 -554
- data/lib/cucumber/parser/story_parser_pt.rb +0 -554
- data/lib/cucumber/ruby_tree.rb +0 -14
- data/lib/cucumber/ruby_tree/nodes.rb +0 -68
@@ -0,0 +1,923 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module TreetopParser
|
3
|
+
|
4
|
+
module Feature
|
5
|
+
include Treetop::Runtime
|
6
|
+
|
7
|
+
def root
|
8
|
+
@root || :root
|
9
|
+
end
|
10
|
+
|
11
|
+
module Root0
|
12
|
+
def header
|
13
|
+
elements[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def scenarios
|
17
|
+
elements[1]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module Root1
|
22
|
+
|
23
|
+
def feature
|
24
|
+
f = Tree::Feature.new(header.text_value.strip)
|
25
|
+
scenarios.populate(f)
|
26
|
+
f
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def _nt_root
|
31
|
+
start_index = index
|
32
|
+
if node_cache[:root].has_key?(index)
|
33
|
+
cached = node_cache[:root][index]
|
34
|
+
@index = cached.interval.end if cached
|
35
|
+
return cached
|
36
|
+
end
|
37
|
+
|
38
|
+
i0, s0 = index, []
|
39
|
+
r1 = _nt_header
|
40
|
+
s0 << r1
|
41
|
+
if r1
|
42
|
+
r2 = _nt_scenarios
|
43
|
+
s0 << r2
|
44
|
+
end
|
45
|
+
if s0.last
|
46
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
47
|
+
r0.extend(Root0)
|
48
|
+
r0.extend(Root1)
|
49
|
+
else
|
50
|
+
self.index = i0
|
51
|
+
r0 = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
node_cache[:root][start_index] = r0
|
55
|
+
|
56
|
+
return r0
|
57
|
+
end
|
58
|
+
|
59
|
+
module Header0
|
60
|
+
end
|
61
|
+
|
62
|
+
def _nt_header
|
63
|
+
start_index = index
|
64
|
+
if node_cache[:header].has_key?(index)
|
65
|
+
cached = node_cache[:header][index]
|
66
|
+
@index = cached.interval.end if cached
|
67
|
+
return cached
|
68
|
+
end
|
69
|
+
|
70
|
+
s0, i0 = [], index
|
71
|
+
loop do
|
72
|
+
i1, s1 = index, []
|
73
|
+
i2 = index
|
74
|
+
r3 = _nt_step_scenario
|
75
|
+
if r3
|
76
|
+
r2 = nil
|
77
|
+
else
|
78
|
+
self.index = i2
|
79
|
+
r2 = SyntaxNode.new(input, index...index)
|
80
|
+
end
|
81
|
+
s1 << r2
|
82
|
+
if r2
|
83
|
+
if index < input_length
|
84
|
+
r4 = (SyntaxNode).new(input, index...(index + 1))
|
85
|
+
@index += 1
|
86
|
+
else
|
87
|
+
terminal_parse_failure("any character")
|
88
|
+
r4 = nil
|
89
|
+
end
|
90
|
+
s1 << r4
|
91
|
+
end
|
92
|
+
if s1.last
|
93
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
94
|
+
r1.extend(Header0)
|
95
|
+
else
|
96
|
+
self.index = i1
|
97
|
+
r1 = nil
|
98
|
+
end
|
99
|
+
if r1
|
100
|
+
s0 << r1
|
101
|
+
else
|
102
|
+
break
|
103
|
+
end
|
104
|
+
end
|
105
|
+
r0 = SyntaxNode.new(input, i0...index, s0)
|
106
|
+
|
107
|
+
node_cache[:header][start_index] = r0
|
108
|
+
|
109
|
+
return r0
|
110
|
+
end
|
111
|
+
|
112
|
+
module Scenarios0
|
113
|
+
def step_scenario
|
114
|
+
elements[0]
|
115
|
+
end
|
116
|
+
|
117
|
+
def more
|
118
|
+
elements[1]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
module Scenarios1
|
123
|
+
def populate(feature)
|
124
|
+
step_scenario.populate(feature)
|
125
|
+
more.elements.each { |m| m.populate(feature) }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def _nt_scenarios
|
130
|
+
start_index = index
|
131
|
+
if node_cache[:scenarios].has_key?(index)
|
132
|
+
cached = node_cache[:scenarios][index]
|
133
|
+
@index = cached.interval.end if cached
|
134
|
+
return cached
|
135
|
+
end
|
136
|
+
|
137
|
+
i0, s0 = index, []
|
138
|
+
r1 = _nt_step_scenario
|
139
|
+
s0 << r1
|
140
|
+
if r1
|
141
|
+
s2, i2 = [], index
|
142
|
+
loop do
|
143
|
+
i3 = index
|
144
|
+
r4 = _nt_table
|
145
|
+
if r4
|
146
|
+
r3 = r4
|
147
|
+
else
|
148
|
+
r5 = _nt_step_scenario
|
149
|
+
if r5
|
150
|
+
r3 = r5
|
151
|
+
else
|
152
|
+
self.index = i3
|
153
|
+
r3 = nil
|
154
|
+
end
|
155
|
+
end
|
156
|
+
if r3
|
157
|
+
s2 << r3
|
158
|
+
else
|
159
|
+
break
|
160
|
+
end
|
161
|
+
end
|
162
|
+
r2 = SyntaxNode.new(input, i2...index, s2)
|
163
|
+
s0 << r2
|
164
|
+
end
|
165
|
+
if s0.last
|
166
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
167
|
+
r0.extend(Scenarios0)
|
168
|
+
r0.extend(Scenarios1)
|
169
|
+
else
|
170
|
+
self.index = i0
|
171
|
+
r0 = nil
|
172
|
+
end
|
173
|
+
|
174
|
+
node_cache[:scenarios][start_index] = r0
|
175
|
+
|
176
|
+
return r0
|
177
|
+
end
|
178
|
+
|
179
|
+
module StepScenario0
|
180
|
+
end
|
181
|
+
|
182
|
+
module StepScenario1
|
183
|
+
def scenario_keyword
|
184
|
+
elements[1]
|
185
|
+
end
|
186
|
+
|
187
|
+
def name
|
188
|
+
elements[4]
|
189
|
+
end
|
190
|
+
|
191
|
+
def steps
|
192
|
+
elements[6]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
module StepScenario2
|
197
|
+
def populate(feature)
|
198
|
+
sc = feature.add_scenario(name.text_value)
|
199
|
+
steps.elements.each{|s| s.populate(sc)}
|
200
|
+
Feature.last_scenario = sc
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def _nt_step_scenario
|
205
|
+
start_index = index
|
206
|
+
if node_cache[:step_scenario].has_key?(index)
|
207
|
+
cached = node_cache[:step_scenario][index]
|
208
|
+
@index = cached.interval.end if cached
|
209
|
+
return cached
|
210
|
+
end
|
211
|
+
|
212
|
+
i0, s0 = index, []
|
213
|
+
s1, i1 = [], index
|
214
|
+
loop do
|
215
|
+
r2 = _nt_whitespace
|
216
|
+
if r2
|
217
|
+
s1 << r2
|
218
|
+
else
|
219
|
+
break
|
220
|
+
end
|
221
|
+
end
|
222
|
+
r1 = SyntaxNode.new(input, i1...index, s1)
|
223
|
+
s0 << r1
|
224
|
+
if r1
|
225
|
+
r3 = _nt_scenario_keyword
|
226
|
+
s0 << r3
|
227
|
+
if r3
|
228
|
+
if input.index(":", index) == index
|
229
|
+
r4 = (SyntaxNode).new(input, index...(index + 1))
|
230
|
+
@index += 1
|
231
|
+
else
|
232
|
+
terminal_parse_failure(":")
|
233
|
+
r4 = nil
|
234
|
+
end
|
235
|
+
s0 << r4
|
236
|
+
if r4
|
237
|
+
s5, i5 = [], index
|
238
|
+
loop do
|
239
|
+
r6 = _nt_whitespace
|
240
|
+
if r6
|
241
|
+
s5 << r6
|
242
|
+
else
|
243
|
+
break
|
244
|
+
end
|
245
|
+
end
|
246
|
+
r5 = SyntaxNode.new(input, i5...index, s5)
|
247
|
+
s0 << r5
|
248
|
+
if r5
|
249
|
+
s7, i7 = [], index
|
250
|
+
loop do
|
251
|
+
i8, s8 = index, []
|
252
|
+
i9 = index
|
253
|
+
r10 = _nt_newline
|
254
|
+
if r10
|
255
|
+
r9 = nil
|
256
|
+
else
|
257
|
+
self.index = i9
|
258
|
+
r9 = SyntaxNode.new(input, index...index)
|
259
|
+
end
|
260
|
+
s8 << r9
|
261
|
+
if r9
|
262
|
+
if index < input_length
|
263
|
+
r11 = (SyntaxNode).new(input, index...(index + 1))
|
264
|
+
@index += 1
|
265
|
+
else
|
266
|
+
terminal_parse_failure("any character")
|
267
|
+
r11 = nil
|
268
|
+
end
|
269
|
+
s8 << r11
|
270
|
+
end
|
271
|
+
if s8.last
|
272
|
+
r8 = (SyntaxNode).new(input, i8...index, s8)
|
273
|
+
r8.extend(StepScenario0)
|
274
|
+
else
|
275
|
+
self.index = i8
|
276
|
+
r8 = nil
|
277
|
+
end
|
278
|
+
if r8
|
279
|
+
s7 << r8
|
280
|
+
else
|
281
|
+
break
|
282
|
+
end
|
283
|
+
end
|
284
|
+
r7 = SyntaxNode.new(input, i7...index, s7)
|
285
|
+
s0 << r7
|
286
|
+
if r7
|
287
|
+
s12, i12 = [], index
|
288
|
+
loop do
|
289
|
+
r13 = _nt_newline
|
290
|
+
if r13
|
291
|
+
s12 << r13
|
292
|
+
else
|
293
|
+
break
|
294
|
+
end
|
295
|
+
end
|
296
|
+
r12 = SyntaxNode.new(input, i12...index, s12)
|
297
|
+
s0 << r12
|
298
|
+
if r12
|
299
|
+
s14, i14 = [], index
|
300
|
+
loop do
|
301
|
+
r15 = _nt_step
|
302
|
+
if r15
|
303
|
+
s14 << r15
|
304
|
+
else
|
305
|
+
break
|
306
|
+
end
|
307
|
+
end
|
308
|
+
if s14.empty?
|
309
|
+
self.index = i14
|
310
|
+
r14 = nil
|
311
|
+
else
|
312
|
+
r14 = SyntaxNode.new(input, i14...index, s14)
|
313
|
+
end
|
314
|
+
s0 << r14
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
if s0.last
|
322
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
323
|
+
r0.extend(StepScenario1)
|
324
|
+
r0.extend(StepScenario2)
|
325
|
+
else
|
326
|
+
self.index = i0
|
327
|
+
r0 = nil
|
328
|
+
end
|
329
|
+
|
330
|
+
node_cache[:step_scenario][start_index] = r0
|
331
|
+
|
332
|
+
return r0
|
333
|
+
end
|
334
|
+
|
335
|
+
module Step0
|
336
|
+
end
|
337
|
+
|
338
|
+
module Step1
|
339
|
+
def step_keyword
|
340
|
+
elements[1]
|
341
|
+
end
|
342
|
+
|
343
|
+
def name
|
344
|
+
elements[3]
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
module Step2
|
350
|
+
def populate(scenario)
|
351
|
+
line = input.line_of(interval.first)
|
352
|
+
scenario.add_step(step_keyword.text_value, name.text_value, line)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
def _nt_step
|
357
|
+
start_index = index
|
358
|
+
if node_cache[:step].has_key?(index)
|
359
|
+
cached = node_cache[:step][index]
|
360
|
+
@index = cached.interval.end if cached
|
361
|
+
return cached
|
362
|
+
end
|
363
|
+
|
364
|
+
i0, s0 = index, []
|
365
|
+
s1, i1 = [], index
|
366
|
+
loop do
|
367
|
+
r2 = _nt_whitespace
|
368
|
+
if r2
|
369
|
+
s1 << r2
|
370
|
+
else
|
371
|
+
break
|
372
|
+
end
|
373
|
+
end
|
374
|
+
r1 = SyntaxNode.new(input, i1...index, s1)
|
375
|
+
s0 << r1
|
376
|
+
if r1
|
377
|
+
r3 = _nt_step_keyword
|
378
|
+
s0 << r3
|
379
|
+
if r3
|
380
|
+
s4, i4 = [], index
|
381
|
+
loop do
|
382
|
+
r5 = _nt_whitespace
|
383
|
+
if r5
|
384
|
+
s4 << r5
|
385
|
+
else
|
386
|
+
break
|
387
|
+
end
|
388
|
+
end
|
389
|
+
r4 = SyntaxNode.new(input, i4...index, s4)
|
390
|
+
s0 << r4
|
391
|
+
if r4
|
392
|
+
s6, i6 = [], index
|
393
|
+
loop do
|
394
|
+
i7, s7 = index, []
|
395
|
+
i8 = index
|
396
|
+
r9 = _nt_newline
|
397
|
+
if r9
|
398
|
+
r8 = nil
|
399
|
+
else
|
400
|
+
self.index = i8
|
401
|
+
r8 = SyntaxNode.new(input, index...index)
|
402
|
+
end
|
403
|
+
s7 << r8
|
404
|
+
if r8
|
405
|
+
if index < input_length
|
406
|
+
r10 = (SyntaxNode).new(input, index...(index + 1))
|
407
|
+
@index += 1
|
408
|
+
else
|
409
|
+
terminal_parse_failure("any character")
|
410
|
+
r10 = nil
|
411
|
+
end
|
412
|
+
s7 << r10
|
413
|
+
end
|
414
|
+
if s7.last
|
415
|
+
r7 = (SyntaxNode).new(input, i7...index, s7)
|
416
|
+
r7.extend(Step0)
|
417
|
+
else
|
418
|
+
self.index = i7
|
419
|
+
r7 = nil
|
420
|
+
end
|
421
|
+
if r7
|
422
|
+
s6 << r7
|
423
|
+
else
|
424
|
+
break
|
425
|
+
end
|
426
|
+
end
|
427
|
+
r6 = SyntaxNode.new(input, i6...index, s6)
|
428
|
+
s0 << r6
|
429
|
+
if r6
|
430
|
+
s11, i11 = [], index
|
431
|
+
loop do
|
432
|
+
r12 = _nt_newline
|
433
|
+
if r12
|
434
|
+
s11 << r12
|
435
|
+
else
|
436
|
+
break
|
437
|
+
end
|
438
|
+
end
|
439
|
+
r11 = SyntaxNode.new(input, i11...index, s11)
|
440
|
+
s0 << r11
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|
445
|
+
if s0.last
|
446
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
447
|
+
r0.extend(Step1)
|
448
|
+
r0.extend(Step2)
|
449
|
+
else
|
450
|
+
self.index = i0
|
451
|
+
r0 = nil
|
452
|
+
end
|
453
|
+
|
454
|
+
node_cache[:step][start_index] = r0
|
455
|
+
|
456
|
+
return r0
|
457
|
+
end
|
458
|
+
|
459
|
+
def _nt_step_keyword
|
460
|
+
start_index = index
|
461
|
+
if node_cache[:step_keyword].has_key?(index)
|
462
|
+
cached = node_cache[:step_keyword][index]
|
463
|
+
@index = cached.interval.end if cached
|
464
|
+
return cached
|
465
|
+
end
|
466
|
+
|
467
|
+
i0 = index
|
468
|
+
if input.index('Soit', index) == index
|
469
|
+
r1 = (SyntaxNode).new(input, index...(index + 4))
|
470
|
+
@index += 4
|
471
|
+
else
|
472
|
+
terminal_parse_failure('Soit')
|
473
|
+
r1 = nil
|
474
|
+
end
|
475
|
+
if r1
|
476
|
+
r0 = r1
|
477
|
+
else
|
478
|
+
if input.index('Quand', index) == index
|
479
|
+
r2 = (SyntaxNode).new(input, index...(index + 5))
|
480
|
+
@index += 5
|
481
|
+
else
|
482
|
+
terminal_parse_failure('Quand')
|
483
|
+
r2 = nil
|
484
|
+
end
|
485
|
+
if r2
|
486
|
+
r0 = r2
|
487
|
+
else
|
488
|
+
if input.index('Alors', index) == index
|
489
|
+
r3 = (SyntaxNode).new(input, index...(index + 5))
|
490
|
+
@index += 5
|
491
|
+
else
|
492
|
+
terminal_parse_failure('Alors')
|
493
|
+
r3 = nil
|
494
|
+
end
|
495
|
+
if r3
|
496
|
+
r0 = r3
|
497
|
+
else
|
498
|
+
if input.index('Et', index) == index
|
499
|
+
r4 = (SyntaxNode).new(input, index...(index + 2))
|
500
|
+
@index += 2
|
501
|
+
else
|
502
|
+
terminal_parse_failure('Et')
|
503
|
+
r4 = nil
|
504
|
+
end
|
505
|
+
if r4
|
506
|
+
r0 = r4
|
507
|
+
else
|
508
|
+
self.index = i0
|
509
|
+
r0 = nil
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
node_cache[:step_keyword][start_index] = r0
|
516
|
+
|
517
|
+
return r0
|
518
|
+
end
|
519
|
+
|
520
|
+
def _nt_scenario_keyword
|
521
|
+
start_index = index
|
522
|
+
if node_cache[:scenario_keyword].has_key?(index)
|
523
|
+
cached = node_cache[:scenario_keyword][index]
|
524
|
+
@index = cached.interval.end if cached
|
525
|
+
return cached
|
526
|
+
end
|
527
|
+
|
528
|
+
if input.index('Scenario', index) == index
|
529
|
+
r0 = (SyntaxNode).new(input, index...(index + 8))
|
530
|
+
@index += 8
|
531
|
+
else
|
532
|
+
terminal_parse_failure('Scenario')
|
533
|
+
r0 = nil
|
534
|
+
end
|
535
|
+
|
536
|
+
node_cache[:scenario_keyword][start_index] = r0
|
537
|
+
|
538
|
+
return r0
|
539
|
+
end
|
540
|
+
|
541
|
+
module Table0
|
542
|
+
def newline
|
543
|
+
elements[0]
|
544
|
+
end
|
545
|
+
|
546
|
+
def table_line
|
547
|
+
elements[1]
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
module Table1
|
552
|
+
def table_line
|
553
|
+
elements[0]
|
554
|
+
end
|
555
|
+
|
556
|
+
def more
|
557
|
+
elements[1]
|
558
|
+
end
|
559
|
+
|
560
|
+
end
|
561
|
+
|
562
|
+
module Table2
|
563
|
+
def populate(feature)
|
564
|
+
Feature.last_scenario.table_header = table_line.values
|
565
|
+
more.elements.each do |e|
|
566
|
+
feature.add_row_scenario(Feature.last_scenario, e.table_line.values, e.table_line.line)
|
567
|
+
end
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
def _nt_table
|
572
|
+
start_index = index
|
573
|
+
if node_cache[:table].has_key?(index)
|
574
|
+
cached = node_cache[:table][index]
|
575
|
+
@index = cached.interval.end if cached
|
576
|
+
return cached
|
577
|
+
end
|
578
|
+
|
579
|
+
i0, s0 = index, []
|
580
|
+
r1 = _nt_table_line
|
581
|
+
s0 << r1
|
582
|
+
if r1
|
583
|
+
s2, i2 = [], index
|
584
|
+
loop do
|
585
|
+
i3, s3 = index, []
|
586
|
+
r4 = _nt_newline
|
587
|
+
s3 << r4
|
588
|
+
if r4
|
589
|
+
r5 = _nt_table_line
|
590
|
+
s3 << r5
|
591
|
+
end
|
592
|
+
if s3.last
|
593
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
594
|
+
r3.extend(Table0)
|
595
|
+
else
|
596
|
+
self.index = i3
|
597
|
+
r3 = nil
|
598
|
+
end
|
599
|
+
if r3
|
600
|
+
s2 << r3
|
601
|
+
else
|
602
|
+
break
|
603
|
+
end
|
604
|
+
end
|
605
|
+
if s2.empty?
|
606
|
+
self.index = i2
|
607
|
+
r2 = nil
|
608
|
+
else
|
609
|
+
r2 = SyntaxNode.new(input, i2...index, s2)
|
610
|
+
end
|
611
|
+
s0 << r2
|
612
|
+
if r2
|
613
|
+
s6, i6 = [], index
|
614
|
+
loop do
|
615
|
+
r7 = _nt_newline
|
616
|
+
if r7
|
617
|
+
s6 << r7
|
618
|
+
else
|
619
|
+
break
|
620
|
+
end
|
621
|
+
end
|
622
|
+
r6 = SyntaxNode.new(input, i6...index, s6)
|
623
|
+
s0 << r6
|
624
|
+
end
|
625
|
+
end
|
626
|
+
if s0.last
|
627
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
628
|
+
r0.extend(Table1)
|
629
|
+
r0.extend(Table2)
|
630
|
+
else
|
631
|
+
self.index = i0
|
632
|
+
r0 = nil
|
633
|
+
end
|
634
|
+
|
635
|
+
node_cache[:table][start_index] = r0
|
636
|
+
|
637
|
+
return r0
|
638
|
+
end
|
639
|
+
|
640
|
+
module TableLine0
|
641
|
+
def cell_value
|
642
|
+
elements[1]
|
643
|
+
end
|
644
|
+
|
645
|
+
def separator
|
646
|
+
elements[3]
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
650
|
+
module TableLine1
|
651
|
+
def separator
|
652
|
+
elements[1]
|
653
|
+
end
|
654
|
+
|
655
|
+
def cells
|
656
|
+
elements[2]
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
660
|
+
module TableLine2
|
661
|
+
def values
|
662
|
+
cells.elements.map { |cell| cell.cell_value.text_value }
|
663
|
+
end
|
664
|
+
|
665
|
+
def line
|
666
|
+
input.line_of(interval.first)
|
667
|
+
end
|
668
|
+
end
|
669
|
+
|
670
|
+
def _nt_table_line
|
671
|
+
start_index = index
|
672
|
+
if node_cache[:table_line].has_key?(index)
|
673
|
+
cached = node_cache[:table_line][index]
|
674
|
+
@index = cached.interval.end if cached
|
675
|
+
return cached
|
676
|
+
end
|
677
|
+
|
678
|
+
i0, s0 = index, []
|
679
|
+
s1, i1 = [], index
|
680
|
+
loop do
|
681
|
+
r2 = _nt_whitespace
|
682
|
+
if r2
|
683
|
+
s1 << r2
|
684
|
+
else
|
685
|
+
break
|
686
|
+
end
|
687
|
+
end
|
688
|
+
r1 = SyntaxNode.new(input, i1...index, s1)
|
689
|
+
s0 << r1
|
690
|
+
if r1
|
691
|
+
r3 = _nt_separator
|
692
|
+
s0 << r3
|
693
|
+
if r3
|
694
|
+
s4, i4 = [], index
|
695
|
+
loop do
|
696
|
+
i5, s5 = index, []
|
697
|
+
s6, i6 = [], index
|
698
|
+
loop do
|
699
|
+
r7 = _nt_whitespace
|
700
|
+
if r7
|
701
|
+
s6 << r7
|
702
|
+
else
|
703
|
+
break
|
704
|
+
end
|
705
|
+
end
|
706
|
+
r6 = SyntaxNode.new(input, i6...index, s6)
|
707
|
+
s5 << r6
|
708
|
+
if r6
|
709
|
+
r8 = _nt_cell_value
|
710
|
+
s5 << r8
|
711
|
+
if r8
|
712
|
+
s9, i9 = [], index
|
713
|
+
loop do
|
714
|
+
r10 = _nt_whitespace
|
715
|
+
if r10
|
716
|
+
s9 << r10
|
717
|
+
else
|
718
|
+
break
|
719
|
+
end
|
720
|
+
end
|
721
|
+
r9 = SyntaxNode.new(input, i9...index, s9)
|
722
|
+
s5 << r9
|
723
|
+
if r9
|
724
|
+
r11 = _nt_separator
|
725
|
+
s5 << r11
|
726
|
+
end
|
727
|
+
end
|
728
|
+
end
|
729
|
+
if s5.last
|
730
|
+
r5 = (SyntaxNode).new(input, i5...index, s5)
|
731
|
+
r5.extend(TableLine0)
|
732
|
+
else
|
733
|
+
self.index = i5
|
734
|
+
r5 = nil
|
735
|
+
end
|
736
|
+
if r5
|
737
|
+
s4 << r5
|
738
|
+
else
|
739
|
+
break
|
740
|
+
end
|
741
|
+
end
|
742
|
+
if s4.empty?
|
743
|
+
self.index = i4
|
744
|
+
r4 = nil
|
745
|
+
else
|
746
|
+
r4 = SyntaxNode.new(input, i4...index, s4)
|
747
|
+
end
|
748
|
+
s0 << r4
|
749
|
+
end
|
750
|
+
end
|
751
|
+
if s0.last
|
752
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
753
|
+
r0.extend(TableLine1)
|
754
|
+
r0.extend(TableLine2)
|
755
|
+
else
|
756
|
+
self.index = i0
|
757
|
+
r0 = nil
|
758
|
+
end
|
759
|
+
|
760
|
+
node_cache[:table_line][start_index] = r0
|
761
|
+
|
762
|
+
return r0
|
763
|
+
end
|
764
|
+
|
765
|
+
module CellValue0
|
766
|
+
end
|
767
|
+
|
768
|
+
def _nt_cell_value
|
769
|
+
start_index = index
|
770
|
+
if node_cache[:cell_value].has_key?(index)
|
771
|
+
cached = node_cache[:cell_value][index]
|
772
|
+
@index = cached.interval.end if cached
|
773
|
+
return cached
|
774
|
+
end
|
775
|
+
|
776
|
+
s0, i0 = [], index
|
777
|
+
loop do
|
778
|
+
i1, s1 = index, []
|
779
|
+
i2 = index
|
780
|
+
i3 = index
|
781
|
+
r4 = _nt_separator
|
782
|
+
if r4
|
783
|
+
r3 = r4
|
784
|
+
else
|
785
|
+
r5 = _nt_newline
|
786
|
+
if r5
|
787
|
+
r3 = r5
|
788
|
+
else
|
789
|
+
r6 = _nt_whitespace
|
790
|
+
if r6
|
791
|
+
r3 = r6
|
792
|
+
else
|
793
|
+
self.index = i3
|
794
|
+
r3 = nil
|
795
|
+
end
|
796
|
+
end
|
797
|
+
end
|
798
|
+
if r3
|
799
|
+
r2 = nil
|
800
|
+
else
|
801
|
+
self.index = i2
|
802
|
+
r2 = SyntaxNode.new(input, index...index)
|
803
|
+
end
|
804
|
+
s1 << r2
|
805
|
+
if r2
|
806
|
+
if index < input_length
|
807
|
+
r7 = (SyntaxNode).new(input, index...(index + 1))
|
808
|
+
@index += 1
|
809
|
+
else
|
810
|
+
terminal_parse_failure("any character")
|
811
|
+
r7 = nil
|
812
|
+
end
|
813
|
+
s1 << r7
|
814
|
+
end
|
815
|
+
if s1.last
|
816
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
817
|
+
r1.extend(CellValue0)
|
818
|
+
else
|
819
|
+
self.index = i1
|
820
|
+
r1 = nil
|
821
|
+
end
|
822
|
+
if r1
|
823
|
+
s0 << r1
|
824
|
+
else
|
825
|
+
break
|
826
|
+
end
|
827
|
+
end
|
828
|
+
r0 = SyntaxNode.new(input, i0...index, s0)
|
829
|
+
|
830
|
+
node_cache[:cell_value][start_index] = r0
|
831
|
+
|
832
|
+
return r0
|
833
|
+
end
|
834
|
+
|
835
|
+
def _nt_separator
|
836
|
+
start_index = index
|
837
|
+
if node_cache[:separator].has_key?(index)
|
838
|
+
cached = node_cache[:separator][index]
|
839
|
+
@index = cached.interval.end if cached
|
840
|
+
return cached
|
841
|
+
end
|
842
|
+
|
843
|
+
if input.index('|', index) == index
|
844
|
+
r0 = (SyntaxNode).new(input, index...(index + 1))
|
845
|
+
@index += 1
|
846
|
+
else
|
847
|
+
terminal_parse_failure('|')
|
848
|
+
r0 = nil
|
849
|
+
end
|
850
|
+
|
851
|
+
node_cache[:separator][start_index] = r0
|
852
|
+
|
853
|
+
return r0
|
854
|
+
end
|
855
|
+
|
856
|
+
def _nt_newline
|
857
|
+
start_index = index
|
858
|
+
if node_cache[:newline].has_key?(index)
|
859
|
+
cached = node_cache[:newline][index]
|
860
|
+
@index = cached.interval.end if cached
|
861
|
+
return cached
|
862
|
+
end
|
863
|
+
|
864
|
+
i0 = index
|
865
|
+
if input.index("\r\n?", index) == index
|
866
|
+
r1 = (SyntaxNode).new(input, index...(index + 3))
|
867
|
+
@index += 3
|
868
|
+
else
|
869
|
+
terminal_parse_failure("\r\n?")
|
870
|
+
r1 = nil
|
871
|
+
end
|
872
|
+
if r1
|
873
|
+
r0 = r1
|
874
|
+
else
|
875
|
+
if input.index("\n", index) == index
|
876
|
+
r2 = (SyntaxNode).new(input, index...(index + 1))
|
877
|
+
@index += 1
|
878
|
+
else
|
879
|
+
terminal_parse_failure("\n")
|
880
|
+
r2 = nil
|
881
|
+
end
|
882
|
+
if r2
|
883
|
+
r0 = r2
|
884
|
+
else
|
885
|
+
self.index = i0
|
886
|
+
r0 = nil
|
887
|
+
end
|
888
|
+
end
|
889
|
+
|
890
|
+
node_cache[:newline][start_index] = r0
|
891
|
+
|
892
|
+
return r0
|
893
|
+
end
|
894
|
+
|
895
|
+
def _nt_whitespace
|
896
|
+
start_index = index
|
897
|
+
if node_cache[:whitespace].has_key?(index)
|
898
|
+
cached = node_cache[:whitespace][index]
|
899
|
+
@index = cached.interval.end if cached
|
900
|
+
return cached
|
901
|
+
end
|
902
|
+
|
903
|
+
if input.index(Regexp.new('[ \\v\\f\\t]'), index) == index
|
904
|
+
r0 = (SyntaxNode).new(input, index...(index + 1))
|
905
|
+
@index += 1
|
906
|
+
else
|
907
|
+
r0 = nil
|
908
|
+
end
|
909
|
+
|
910
|
+
node_cache[:whitespace][start_index] = r0
|
911
|
+
|
912
|
+
return r0
|
913
|
+
end
|
914
|
+
|
915
|
+
end
|
916
|
+
|
917
|
+
class FeatureParser < Treetop::Runtime::CompiledParser
|
918
|
+
include Feature
|
919
|
+
end
|
920
|
+
|
921
|
+
|
922
|
+
end
|
923
|
+
end
|