gherkin_jruby 0.3.1.pre.jruby

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,403 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.10
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+ require_relative "lexer"
10
+ require_relative "../ast"
11
+
12
+ module GherkinRuby
13
+ class Parser < Racc::Parser
14
+
15
+ module_eval(<<'...end gherkin.y/module_eval...', 'gherkin.y', 104)
16
+
17
+ def parse(input)
18
+ @yydebug = true if ENV['DEBUG_RACC']
19
+ scan_str(input)
20
+ end
21
+ ...end gherkin.y/module_eval...
22
+ ##### State transition tables begin ###
23
+
24
+ racc_action_table = [
25
+ 18, 18, 20, 4, 26, 10, 18, 21, 14, 10,
26
+ 43, 36, 37, 38, 39, 40, 18, 18, 14, 10,
27
+ 45, 36, 37, 38, 39, 40, 18, 14, 10, 4,
28
+ 9, 36, 37, 38, 39, 40, 36, 37, 38, 39,
29
+ 40, 4, 9, 14, 10, 10, 18, 20, 32, 24,
30
+ 21, 4, 4, 29, 21, 4, 47, 18, 48, 4,
31
+ 27, 51, 11, 4, 18, 4, 18, 4 ]
32
+
33
+ racc_action_check = [
34
+ 25, 5, 5, 15, 9, 5, 54, 15, 31, 31,
35
+ 25, 54, 54, 54, 54, 54, 44, 30, 12, 12,
36
+ 30, 44, 44, 44, 44, 44, 46, 2, 2, 3,
37
+ 3, 46, 46, 46, 46, 46, 23, 23, 23, 23,
38
+ 23, 0, 0, 16, 16, 0, 17, 17, 20, 7,
39
+ 6, 8, 29, 14, 19, 34, 35, 41, 42, 43,
40
+ 11, 45, 1, 48, 49, 51, 53, 24 ]
41
+
42
+ racc_action_pointer = [
43
+ 39, 62, 22, 27, nil, -1, 44, 45, 49, -8,
44
+ nil, 60, 13, nil, 41, 1, 38, 44, nil, 48,
45
+ 36, nil, nil, 29, 65, -2, nil, nil, nil, 50,
46
+ 15, 3, nil, nil, 53, 44, nil, nil, nil, nil,
47
+ nil, 55, 46, 57, 14, 49, 24, nil, 61, 62,
48
+ nil, 63, nil, 64, 4, nil ]
49
+
50
+ racc_action_default = [
51
+ -35, -35, -1, -35, -5, -35, -7, -9, -11, -35,
52
+ -33, -35, -2, -29, -35, -35, -3, -35, -6, -8,
53
+ -35, -34, -10, -35, -35, -12, -14, 56, -30, -35,
54
+ -35, -4, -15, -18, -20, -35, -24, -25, -26, -27,
55
+ -28, -19, -13, -35, -35, -35, -21, -23, -35, -16,
56
+ -31, -35, -22, -17, -35, -32 ]
57
+
58
+ racc_goto_table = [
59
+ 5, 28, 33, 17, 12, 6, 2, 23, 25, 16,
60
+ 19, 42, 22, 3, 1, 30, nil, nil, 31, nil,
61
+ 28, nil, nil, 50, 41, 52, nil, nil, nil, 44,
62
+ nil, nil, nil, 55, 46, nil, nil, nil, nil, nil,
63
+ nil, nil, nil, 49, nil, nil, nil, nil, 53, nil,
64
+ nil, 54 ]
65
+
66
+ racc_goto_check = [
67
+ 5, 15, 12, 5, 3, 6, 2, 11, 5, 2,
68
+ 6, 10, 8, 4, 1, 5, nil, nil, 3, nil,
69
+ 15, nil, nil, 12, 5, 12, nil, nil, nil, 5,
70
+ nil, nil, nil, 12, 5, nil, nil, nil, nil, nil,
71
+ nil, nil, nil, 5, nil, nil, nil, nil, 5, nil,
72
+ nil, 5 ]
73
+
74
+ racc_goto_pointer = [
75
+ nil, 14, 6, 2, 13, 0, 5, nil, 5, nil,
76
+ -14, 0, -21, nil, nil, -11 ]
77
+
78
+ racc_goto_default = [
79
+ nil, nil, nil, nil, nil, nil, 15, 7, nil, 8,
80
+ nil, nil, nil, 34, 35, 13 ]
81
+
82
+ racc_reduce_table = [
83
+ 0, 0, :racc_error,
84
+ 1, 14, :_reduce_1,
85
+ 2, 14, :_reduce_2,
86
+ 2, 14, :_reduce_3,
87
+ 3, 14, :_reduce_4,
88
+ 1, 18, :_reduce_none,
89
+ 2, 18, :_reduce_none,
90
+ 1, 17, :_reduce_7,
91
+ 2, 17, :_reduce_8,
92
+ 1, 15, :_reduce_9,
93
+ 2, 15, :_reduce_10,
94
+ 1, 20, :_reduce_11,
95
+ 2, 20, :_reduce_12,
96
+ 3, 20, :_reduce_13,
97
+ 2, 22, :_reduce_14,
98
+ 3, 22, :_reduce_15,
99
+ 2, 23, :_reduce_16,
100
+ 3, 23, :_reduce_17,
101
+ 2, 21, :_reduce_18,
102
+ 2, 24, :_reduce_19,
103
+ 1, 25, :_reduce_20,
104
+ 2, 25, :_reduce_21,
105
+ 3, 25, :_reduce_22,
106
+ 2, 26, :_reduce_23,
107
+ 1, 27, :_reduce_none,
108
+ 1, 27, :_reduce_none,
109
+ 1, 27, :_reduce_none,
110
+ 1, 27, :_reduce_none,
111
+ 1, 27, :_reduce_none,
112
+ 1, 16, :_reduce_29,
113
+ 2, 16, :_reduce_30,
114
+ 4, 28, :_reduce_31,
115
+ 6, 28, :_reduce_32,
116
+ 1, 19, :_reduce_33,
117
+ 2, 19, :_reduce_34 ]
118
+
119
+ racc_reduce_n = 35
120
+
121
+ racc_shift_n = 56
122
+
123
+ racc_token_table = {
124
+ false => 0,
125
+ :error => 1,
126
+ :NEWLINE => 2,
127
+ :FEATURE => 3,
128
+ :BACKGROUND => 4,
129
+ :SCENARIO => 5,
130
+ :TAG => 6,
131
+ :GIVEN => 7,
132
+ :WHEN => 8,
133
+ :THEN => 9,
134
+ :AND => 10,
135
+ :BUT => 11,
136
+ :TEXT => 12 }
137
+
138
+ racc_nt_base = 13
139
+
140
+ racc_use_result_var = true
141
+
142
+ Racc_arg = [
143
+ racc_action_table,
144
+ racc_action_check,
145
+ racc_action_default,
146
+ racc_action_pointer,
147
+ racc_goto_table,
148
+ racc_goto_check,
149
+ racc_goto_default,
150
+ racc_goto_pointer,
151
+ racc_nt_base,
152
+ racc_reduce_table,
153
+ racc_token_table,
154
+ racc_shift_n,
155
+ racc_reduce_n,
156
+ racc_use_result_var ]
157
+
158
+ Racc_token_to_s_table = [
159
+ "$end",
160
+ "error",
161
+ "NEWLINE",
162
+ "FEATURE",
163
+ "BACKGROUND",
164
+ "SCENARIO",
165
+ "TAG",
166
+ "GIVEN",
167
+ "WHEN",
168
+ "THEN",
169
+ "AND",
170
+ "BUT",
171
+ "TEXT",
172
+ "$start",
173
+ "Root",
174
+ "Feature",
175
+ "Scenarios",
176
+ "FeatureTags",
177
+ "Newline",
178
+ "Tags",
179
+ "FeatureHeader",
180
+ "Background",
181
+ "FeatureName",
182
+ "Description",
183
+ "BackgroundHeader",
184
+ "Steps",
185
+ "Step",
186
+ "Keyword",
187
+ "Scenario" ]
188
+
189
+ Racc_debug_parser = false
190
+
191
+ ##### State transition tables end #####
192
+
193
+ # reduce 0 omitted
194
+
195
+ module_eval(<<'.,.,', 'gherkin.y', 14)
196
+ def _reduce_1(val, _values, result)
197
+ result = val[0];
198
+ result
199
+ end
200
+ .,.,
201
+
202
+ module_eval(<<'.,.,', 'gherkin.y', 17)
203
+ def _reduce_2(val, _values, result)
204
+ result = val[0]; result.scenarios = val[1]
205
+ result
206
+ end
207
+ .,.,
208
+
209
+ module_eval(<<'.,.,', 'gherkin.y', 18)
210
+ def _reduce_3(val, _values, result)
211
+ result = val[1]; result.tags = val[0]
212
+ result
213
+ end
214
+ .,.,
215
+
216
+ module_eval(<<'.,.,', 'gherkin.y', 20)
217
+ def _reduce_4(val, _values, result)
218
+ result = val[1]; result.scenarios = val[2]; result.tags = val[0]
219
+ result
220
+ end
221
+ .,.,
222
+
223
+ # reduce 5 omitted
224
+
225
+ # reduce 6 omitted
226
+
227
+ module_eval(<<'.,.,', 'gherkin.y', 29)
228
+ def _reduce_7(val, _values, result)
229
+ result = val[0]
230
+ result
231
+ end
232
+ .,.,
233
+
234
+ module_eval(<<'.,.,', 'gherkin.y', 30)
235
+ def _reduce_8(val, _values, result)
236
+ result = val[1]
237
+ result
238
+ end
239
+ .,.,
240
+
241
+ module_eval(<<'.,.,', 'gherkin.y', 33)
242
+ def _reduce_9(val, _values, result)
243
+ result = val[0]
244
+ result
245
+ end
246
+ .,.,
247
+
248
+ module_eval(<<'.,.,', 'gherkin.y', 35)
249
+ def _reduce_10(val, _values, result)
250
+ result = val[0]; result.background = val[1]
251
+ result
252
+ end
253
+ .,.,
254
+
255
+ module_eval(<<'.,.,', 'gherkin.y', 39)
256
+ def _reduce_11(val, _values, result)
257
+ result = val[0]
258
+ result
259
+ end
260
+ .,.,
261
+
262
+ module_eval(<<'.,.,', 'gherkin.y', 40)
263
+ def _reduce_12(val, _values, result)
264
+ result = val[0]
265
+ result
266
+ end
267
+ .,.,
268
+
269
+ module_eval(<<'.,.,', 'gherkin.y', 42)
270
+ def _reduce_13(val, _values, result)
271
+ result = val[0]; result.description = val[2]
272
+ result
273
+ end
274
+ .,.,
275
+
276
+ module_eval(<<'.,.,', 'gherkin.y', 46)
277
+ def _reduce_14(val, _values, result)
278
+ result = AST::Feature.new(val[1]); result.pos(filename, lineno)
279
+ result
280
+ end
281
+ .,.,
282
+
283
+ module_eval(<<'.,.,', 'gherkin.y', 47)
284
+ def _reduce_15(val, _values, result)
285
+ result = AST::Feature.new(val[2]); result.pos(filename, lineno)
286
+ result
287
+ end
288
+ .,.,
289
+
290
+ module_eval(<<'.,.,', 'gherkin.y', 51)
291
+ def _reduce_16(val, _values, result)
292
+ result = val[0]
293
+ result
294
+ end
295
+ .,.,
296
+
297
+ module_eval(<<'.,.,', 'gherkin.y', 52)
298
+ def _reduce_17(val, _values, result)
299
+ result = val[0...-1].flatten
300
+ result
301
+ end
302
+ .,.,
303
+
304
+ module_eval(<<'.,.,', 'gherkin.y', 57)
305
+ def _reduce_18(val, _values, result)
306
+ result = val[0]; result.steps = val[1]
307
+ result
308
+ end
309
+ .,.,
310
+
311
+ module_eval(<<'.,.,', 'gherkin.y', 61)
312
+ def _reduce_19(val, _values, result)
313
+ result = AST::Background.new; result.pos(filename, lineno)
314
+ result
315
+ end
316
+ .,.,
317
+
318
+ module_eval(<<'.,.,', 'gherkin.y', 65)
319
+ def _reduce_20(val, _values, result)
320
+ result = [val[0]]
321
+ result
322
+ end
323
+ .,.,
324
+
325
+ module_eval(<<'.,.,', 'gherkin.y', 66)
326
+ def _reduce_21(val, _values, result)
327
+ result = [val[0]]
328
+ result
329
+ end
330
+ .,.,
331
+
332
+ module_eval(<<'.,.,', 'gherkin.y', 67)
333
+ def _reduce_22(val, _values, result)
334
+ val[2].unshift(val[0]); result = val[2]
335
+ result
336
+ end
337
+ .,.,
338
+
339
+ module_eval(<<'.,.,', 'gherkin.y', 71)
340
+ def _reduce_23(val, _values, result)
341
+ result = AST::Step.new(val[1], val[0]); result.pos(filename, lineno)
342
+ result
343
+ end
344
+ .,.,
345
+
346
+ # reduce 24 omitted
347
+
348
+ # reduce 25 omitted
349
+
350
+ # reduce 26 omitted
351
+
352
+ # reduce 27 omitted
353
+
354
+ # reduce 28 omitted
355
+
356
+ module_eval(<<'.,.,', 'gherkin.y', 79)
357
+ def _reduce_29(val, _values, result)
358
+ result = [val[0]]
359
+ result
360
+ end
361
+ .,.,
362
+
363
+ module_eval(<<'.,.,', 'gherkin.y', 80)
364
+ def _reduce_30(val, _values, result)
365
+ result = val[0] << val[1]
366
+ result
367
+ end
368
+ .,.,
369
+
370
+ module_eval(<<'.,.,', 'gherkin.y', 85)
371
+ def _reduce_31(val, _values, result)
372
+ result = AST::Scenario.new(val[1], val[3]); result.pos(filename, lineno - 1)
373
+ result
374
+ end
375
+ .,.,
376
+
377
+ module_eval(<<'.,.,', 'gherkin.y', 88)
378
+ def _reduce_32(val, _values, result)
379
+ result = AST::Scenario.new(val[3], val[5], val[0]); result.pos(filename, lineno - 2)
380
+ result
381
+ end
382
+ .,.,
383
+
384
+ module_eval(<<'.,.,', 'gherkin.y', 92)
385
+ def _reduce_33(val, _values, result)
386
+ result = [AST::Tag.new(val[0])]
387
+ result
388
+ end
389
+ .,.,
390
+
391
+ module_eval(<<'.,.,', 'gherkin.y', 93)
392
+ def _reduce_34(val, _values, result)
393
+ result = val[0] << AST::Tag.new(val[1])
394
+ result
395
+ end
396
+ .,.,
397
+
398
+ def _reduce_none(val, _values, result)
399
+ val[0]
400
+ end
401
+
402
+ end # class Parser
403
+ end # module GherkinRuby
@@ -0,0 +1,3 @@
1
+ module GherkinRuby
2
+ VERSION = "0.3.1-jruby"
3
+ end
@@ -0,0 +1,124 @@
1
+ require_relative '../test_helper'
2
+ require 'ostruct'
3
+
4
+ class MyVisitor
5
+ def visit_MyNode(my_node)
6
+ my_node.elements
7
+ end
8
+ end
9
+
10
+ class MyNode < GherkinRuby::AST::Node
11
+ attr_reader :elements
12
+ def initialize(name, elements)
13
+ @name = name
14
+ @elements = elements
15
+ end
16
+ end
17
+
18
+ module GherkinRuby
19
+ module AST
20
+ describe Node do
21
+ it 'is visitable' do
22
+ my_node = MyNode.new('My Node', ['foo', 'bar', 'baz'])
23
+ visitor = MyVisitor.new
24
+
25
+ my_node.accept(visitor).must_equal ['foo', 'bar', 'baz']
26
+ end
27
+ end
28
+
29
+ [Feature, Scenario, Tag].each do |node|
30
+ describe node do
31
+ it 'is a Node' do
32
+ node.ancestors.must_include Node
33
+ end
34
+
35
+ it 'has a line' do
36
+ instance = node.new("Name")
37
+ instance.name.must_equal 'Name'
38
+ instance.must_respond_to :line
39
+ end
40
+ end
41
+ end
42
+
43
+ describe Feature do
44
+ it 'is Enumerable' do
45
+ tags = ['-foo', '-bar']
46
+ background = ['foo', 'bar']
47
+ elements = ['+foo', '+bar']
48
+
49
+ instance = Feature.new("My feature", elements, tags, background )
50
+ instance.tags.each.to_a.must_equal ['-foo', '-bar']
51
+ instance.background.each.to_a.must_equal ['foo', 'bar']
52
+ instance.each.to_a.must_equal ['+foo', '+bar']
53
+ end
54
+ end
55
+
56
+ describe Scenario do
57
+ before do
58
+ @steps = [
59
+ OpenStruct.new(line: 4),
60
+ OpenStruct.new(line: 5),
61
+ ]
62
+ end
63
+
64
+ it 'is Enumerable' do
65
+ instance = Scenario.new("Name", @steps)
66
+ instance.each.to_a.must_equal @steps
67
+ end
68
+
69
+ it 'has tags' do
70
+ tags = ['javascript', 'wip']
71
+
72
+ instance = Scenario.new("Name", @steps, tags)
73
+ instance.tags.must_equal tags
74
+ end
75
+ end
76
+
77
+ describe Background do
78
+ before do
79
+ @steps = [
80
+ OpenStruct.new(line: 4),
81
+ OpenStruct.new(line: 5),
82
+ ]
83
+ end
84
+
85
+ it 'is a Node' do
86
+ Background.ancestors.must_include Node
87
+ end
88
+
89
+ it 'is Enumerable' do
90
+ instance = Background.new(@steps)
91
+ instance.each.to_a.must_equal @steps
92
+ end
93
+
94
+ describe 'when there are background steps' do
95
+ it 'records line' do
96
+ instance = Background.new(@steps)
97
+ instance.pos("file", 3)
98
+ instance.line.must_equal 3
99
+ end
100
+ end
101
+
102
+ describe 'otherwise' do
103
+ it 'does not' do
104
+ instance = Background.new([])
105
+ instance.line.must_equal nil
106
+ end
107
+ end
108
+ end
109
+
110
+ describe Step do
111
+ it 'is a Node' do
112
+ Step.ancestors.must_include Node
113
+ end
114
+
115
+ it 'has a line' do
116
+ instance = Step.new("Name", 'Given')
117
+ instance.pos("file", 2)
118
+ instance.name.must_equal 'Name'
119
+ instance.keyword.must_equal 'Given'
120
+ instance.line.must_equal 2
121
+ end
122
+ end
123
+ end
124
+ end