yap-shell-parser 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/lib/yap/shell/parser/grammar.y +20 -2
- data/lib/yap/shell/parser/lexer.rb +114 -6
- data/lib/yap/shell/parser/nodes.rb +42 -0
- data/lib/yap/shell/parser/version.rb +1 -1
- data/lib/yap/shell/parser_impl.rb +196 -116
- data/spec/spec_helper.rb +27 -0
- data/spec/yap/shell/lexer_spec.rb +298 -5
- data/spec/yap/shell/parser_spec.rb +42 -55
- data/yap-shell-parser.gemspec +1 -1
- metadata +5 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.
|
3
|
+
# This file is automatically generated by Racc 1.4.14
|
4
4
|
# from Racc grammer file "".
|
5
5
|
#
|
6
6
|
|
@@ -21,7 +21,7 @@ module Yap
|
|
21
21
|
module Shell
|
22
22
|
class ParserImpl < Racc::Parser
|
23
23
|
|
24
|
-
module_eval(<<'...end grammar.y/module_eval...', 'grammar.y',
|
24
|
+
module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 115)
|
25
25
|
include Yap::Shell::Parser::Nodes
|
26
26
|
|
27
27
|
#=end
|
@@ -29,6 +29,7 @@ module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 101)
|
|
29
29
|
@yydebug = true
|
30
30
|
|
31
31
|
@q = Yap::Shell::Parser::Lexer.new.tokenize(str)
|
32
|
+
pp @q if ENV["DEBUG"]
|
32
33
|
# @q.push [false, '$'] # is optional from Racc 1.3.7
|
33
34
|
# puts @q.inspect
|
34
35
|
# puts "---- parse tree follows ----"
|
@@ -44,95 +45,122 @@ module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 101)
|
|
44
45
|
##### State transition tables begin ###
|
45
46
|
|
46
47
|
racc_action_table = [
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
21, 22, 25, 25, 23, 28, 14, 52, 33, 19,
|
49
|
+
25, 14, 55, 7, 21, 22, 51, 9, 23, 54,
|
50
|
+
59, 21, 22, 19, 25, 14, 25, 7, 21, 22,
|
51
|
+
38, 9, 23, 35, 57, 52, 60, 19, 36, 14,
|
52
|
+
26, 7, 21, 22, 26, 9, 23, 52, 27, 25,
|
53
|
+
42, 19, 27, 14, 21, 22, 53, 29, 23, 9,
|
54
|
+
29, 33, 25, 19, 33, 14, 24, 7, 21, 22,
|
55
|
+
49, 9, 23, 14, 39, 28, nil, 19, nil, 14,
|
56
|
+
nil, 7, 21, 22, nil, 9, 23, nil, nil, nil,
|
57
|
+
nil, 19, nil, 14, 21, 22, nil, nil, 23, 9,
|
58
|
+
nil, nil, nil, 19, nil, 14, nil, 7, 21, 22,
|
59
|
+
nil, 9, 23, nil, nil, nil, nil, 19, nil, 14,
|
60
|
+
nil, 7, 21, 22, nil, 9, 23, nil, nil, nil,
|
61
|
+
nil, 19, nil, 14, nil, 7, nil, nil, 47, 9 ]
|
54
62
|
|
55
63
|
racc_action_check = [
|
56
|
-
0, 0,
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
64
|
+
0, 0, 46, 31, 0, 44, 8, 32, 13, 0,
|
65
|
+
56, 0, 46, 0, 49, 49, 31, 0, 49, 38,
|
66
|
+
56, 18, 18, 49, 48, 49, 58, 49, 47, 47,
|
67
|
+
18, 49, 47, 15, 48, 40, 58, 47, 15, 47,
|
68
|
+
3, 47, 29, 29, 43, 47, 29, 41, 3, 34,
|
69
|
+
24, 29, 43, 29, 28, 28, 34, 5, 28, 29,
|
70
|
+
45, 22, 2, 28, 21, 28, 1, 28, 14, 14,
|
71
|
+
28, 28, 14, 50, 19, 4, nil, 14, nil, 14,
|
72
|
+
nil, 14, 26, 26, nil, 14, 26, nil, nil, nil,
|
73
|
+
nil, 26, nil, 26, 9, 9, nil, nil, 9, 26,
|
74
|
+
nil, nil, nil, 9, nil, 9, nil, 9, 25, 25,
|
75
|
+
nil, 9, 25, nil, nil, nil, nil, 25, nil, 25,
|
76
|
+
nil, 25, 27, 27, nil, 25, 27, nil, nil, nil,
|
77
|
+
nil, 27, nil, 27, nil, 27, nil, nil, 27, 27 ]
|
63
78
|
|
64
79
|
racc_action_pointer = [
|
65
|
-
-2,
|
66
|
-
|
67
|
-
nil,
|
68
|
-
nil,
|
69
|
-
43, nil,
|
80
|
+
-2, 66, 55, 32, 59, 48, nil, nil, -7, 92,
|
81
|
+
nil, nil, nil, 4, 66, 28, nil, nil, 19, 62,
|
82
|
+
nil, 60, 57, nil, 50, 106, 80, 120, 52, 40,
|
83
|
+
nil, -4, 3, nil, 42, nil, nil, nil, 7, nil,
|
84
|
+
31, 43, nil, 36, -11, 51, -5, 26, 17, 12,
|
85
|
+
60, nil, nil, nil, nil, nil, 3, nil, 19, nil,
|
86
|
+
nil ]
|
70
87
|
|
71
88
|
racc_action_default = [
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-32, -33, -
|
75
|
-
-16, -
|
76
|
-
-
|
89
|
+
-40, -40, -1, -3, -4, -6, -7, -12, -14, -40,
|
90
|
+
-17, -18, -19, -21, -40, -24, -26, -27, -28, -40,
|
91
|
+
-32, -33, -35, -39, -40, -40, -40, -40, -40, -40,
|
92
|
+
-16, -40, -20, -37, -40, -23, -25, -29, -40, -31,
|
93
|
+
-34, -36, 61, -2, -40, -5, -40, -40, -40, -40,
|
94
|
+
-13, -15, -38, -22, -30, -10, -40, -8, -40, -11,
|
95
|
+
-9 ]
|
77
96
|
|
78
97
|
racc_goto_table = [
|
79
|
-
|
80
|
-
|
98
|
+
2, 30, 32, 45, 44, 50, 43, 1, 37, 31,
|
99
|
+
40, 41, nil, nil, 34, nil, nil, nil, nil, nil,
|
100
|
+
nil, nil, nil, nil, nil, nil, nil, 46, 48, nil,
|
81
101
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
82
|
-
nil, nil, nil, nil, nil,
|
102
|
+
nil, nil, nil, 30, nil, nil, nil, 56, nil, 58 ]
|
83
103
|
|
84
104
|
racc_goto_check = [
|
85
|
-
|
86
|
-
|
105
|
+
2, 8, 12, 5, 4, 7, 3, 1, 15, 2,
|
106
|
+
12, 12, nil, nil, 2, nil, nil, nil, nil, nil,
|
107
|
+
nil, nil, nil, nil, nil, nil, nil, 2, 2, nil,
|
87
108
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
88
|
-
nil, nil, nil, nil, nil,
|
109
|
+
nil, nil, nil, 8, nil, nil, nil, 2, nil, 2 ]
|
89
110
|
|
90
111
|
racc_goto_pointer = [
|
91
|
-
nil,
|
92
|
-
|
112
|
+
nil, 7, 0, -19, -21, -23, nil, -24, -7, nil,
|
113
|
+
nil, nil, -11, nil, nil, -10, nil, nil ]
|
93
114
|
|
94
115
|
racc_goto_default = [
|
95
|
-
nil, nil, nil, 3, 4, 5,
|
96
|
-
nil,
|
116
|
+
nil, nil, nil, 3, 4, 5, 6, 8, 10, 11,
|
117
|
+
12, 13, nil, 15, 16, 17, 18, 20 ]
|
97
118
|
|
98
119
|
racc_reduce_table = [
|
99
120
|
0, 0, :racc_error,
|
100
|
-
1, 18, :_reduce_none,
|
101
|
-
3, 19, :_reduce_2,
|
102
|
-
1, 19, :_reduce_3,
|
103
|
-
3, 20, :_reduce_4,
|
104
|
-
1, 20, :_reduce_none,
|
105
|
-
3, 21, :_reduce_6,
|
106
|
-
1, 21, :_reduce_none,
|
107
|
-
3, 22, :_reduce_8,
|
108
|
-
2, 22, :_reduce_9,
|
109
121
|
1, 22, :_reduce_none,
|
110
|
-
|
111
|
-
1,
|
112
|
-
2, 23, :_reduce_13,
|
122
|
+
3, 23, :_reduce_2,
|
123
|
+
1, 23, :_reduce_3,
|
113
124
|
1, 23, :_reduce_none,
|
114
|
-
3,
|
115
|
-
|
125
|
+
3, 24, :_reduce_5,
|
126
|
+
1, 24, :_reduce_none,
|
116
127
|
1, 24, :_reduce_none,
|
117
|
-
|
128
|
+
4, 27, :_reduce_8,
|
129
|
+
5, 27, :_reduce_9,
|
130
|
+
4, 27, :_reduce_10,
|
131
|
+
5, 27, :_reduce_11,
|
132
|
+
1, 25, :_reduce_12,
|
133
|
+
3, 26, :_reduce_13,
|
134
|
+
1, 26, :_reduce_none,
|
135
|
+
3, 28, :_reduce_15,
|
136
|
+
2, 28, :_reduce_16,
|
118
137
|
1, 28, :_reduce_none,
|
119
138
|
1, 28, :_reduce_none,
|
120
139
|
1, 28, :_reduce_none,
|
121
|
-
2, 29, :
|
122
|
-
|
123
|
-
|
140
|
+
2, 29, :_reduce_20,
|
141
|
+
1, 29, :_reduce_none,
|
142
|
+
3, 32, :_reduce_22,
|
143
|
+
2, 30, :_reduce_23,
|
124
144
|
1, 30, :_reduce_none,
|
125
|
-
|
126
|
-
|
127
|
-
1,
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
145
|
+
2, 34, :_reduce_25,
|
146
|
+
1, 34, :_reduce_none,
|
147
|
+
1, 34, :_reduce_none,
|
148
|
+
1, 34, :_reduce_none,
|
149
|
+
2, 35, :_reduce_29,
|
150
|
+
3, 37, :_reduce_30,
|
151
|
+
2, 37, :_reduce_31,
|
152
|
+
1, 36, :_reduce_none,
|
153
|
+
1, 38, :_reduce_33,
|
154
|
+
2, 38, :_reduce_34,
|
155
|
+
1, 38, :_reduce_35,
|
156
|
+
2, 38, :_reduce_36,
|
157
|
+
1, 33, :_reduce_37,
|
158
|
+
2, 33, :_reduce_38,
|
159
|
+
1, 31, :_reduce_39 ]
|
160
|
+
|
161
|
+
racc_reduce_n = 40
|
162
|
+
|
163
|
+
racc_shift_n = 61
|
136
164
|
|
137
165
|
racc_token_table = {
|
138
166
|
false => 0,
|
@@ -150,10 +178,14 @@ racc_token_table = {
|
|
150
178
|
:RValue => 12,
|
151
179
|
:BeginCommandSubstitution => 13,
|
152
180
|
:EndCommandSubstitution => 14,
|
153
|
-
|
154
|
-
|
181
|
+
:Range => 15,
|
182
|
+
:BlockBegin => 16,
|
183
|
+
:BlockEnd => 17,
|
184
|
+
:BlockParams => 18,
|
185
|
+
"(" => 19,
|
186
|
+
")" => 20 }
|
155
187
|
|
156
|
-
racc_nt_base =
|
188
|
+
racc_nt_base = 21
|
157
189
|
|
158
190
|
racc_use_result_var = true
|
159
191
|
|
@@ -189,13 +221,19 @@ Racc_token_to_s_table = [
|
|
189
221
|
"RValue",
|
190
222
|
"BeginCommandSubstitution",
|
191
223
|
"EndCommandSubstitution",
|
224
|
+
"Range",
|
225
|
+
"BlockBegin",
|
226
|
+
"BlockEnd",
|
227
|
+
"BlockParams",
|
192
228
|
"\"(\"",
|
193
229
|
"\")\"",
|
194
230
|
"$start",
|
195
231
|
"program",
|
196
232
|
"stmts",
|
197
233
|
"stmt",
|
234
|
+
"range_stmt",
|
198
235
|
"pipeline",
|
236
|
+
"block_stmt",
|
199
237
|
"stmts2",
|
200
238
|
"stmt_w_substitutions",
|
201
239
|
"command_w_heredoc",
|
@@ -230,149 +268,188 @@ module_eval(<<'.,.,', 'grammar.y', 25)
|
|
230
268
|
end
|
231
269
|
.,.,
|
232
270
|
|
233
|
-
|
234
|
-
|
271
|
+
# reduce 4 omitted
|
272
|
+
|
273
|
+
module_eval(<<'.,.,', 'grammar.y', 29)
|
274
|
+
def _reduce_5(val, _values, result)
|
235
275
|
result = ConditionalNode.new(val[1].value, val[0], val[2])
|
236
276
|
result
|
237
277
|
end
|
238
278
|
.,.,
|
239
279
|
|
240
|
-
# reduce
|
280
|
+
# reduce 6 omitted
|
281
|
+
|
282
|
+
# reduce 7 omitted
|
283
|
+
|
284
|
+
module_eval(<<'.,.,', 'grammar.y', 34)
|
285
|
+
def _reduce_8(val, _values, result)
|
286
|
+
result = val[0].tap { |range_node| range_node.tail = BlockNode.new(nil, val[2]) }
|
287
|
+
result
|
288
|
+
end
|
289
|
+
.,.,
|
290
|
+
|
291
|
+
module_eval(<<'.,.,', 'grammar.y', 36)
|
292
|
+
def _reduce_9(val, _values, result)
|
293
|
+
result = val[0].tap { |range_node| range_node.tail = BlockNode.new(nil, val[3], params: val[2].value) }
|
294
|
+
result
|
295
|
+
end
|
296
|
+
.,.,
|
297
|
+
|
298
|
+
module_eval(<<'.,.,', 'grammar.y', 38)
|
299
|
+
def _reduce_10(val, _values, result)
|
300
|
+
result = BlockNode.new(val[0], val[2])
|
301
|
+
result
|
302
|
+
end
|
303
|
+
.,.,
|
241
304
|
|
242
|
-
module_eval(<<'.,.,', 'grammar.y',
|
243
|
-
def
|
305
|
+
module_eval(<<'.,.,', 'grammar.y', 40)
|
306
|
+
def _reduce_11(val, _values, result)
|
307
|
+
result = BlockNode.new(val[0], val[3], params: val[2].value)
|
308
|
+
result
|
309
|
+
end
|
310
|
+
.,.,
|
311
|
+
|
312
|
+
module_eval(<<'.,.,', 'grammar.y', 43)
|
313
|
+
def _reduce_12(val, _values, result)
|
314
|
+
result = RangeNode.new(val[0])
|
315
|
+
result
|
316
|
+
end
|
317
|
+
.,.,
|
318
|
+
|
319
|
+
module_eval(<<'.,.,', 'grammar.y', 46)
|
320
|
+
def _reduce_13(val, _values, result)
|
244
321
|
result = PipelineNode.new(val[0], val[2])
|
245
322
|
result
|
246
323
|
end
|
247
324
|
.,.,
|
248
325
|
|
249
|
-
# reduce
|
326
|
+
# reduce 14 omitted
|
250
327
|
|
251
|
-
module_eval(<<'.,.,', 'grammar.y',
|
252
|
-
def
|
328
|
+
module_eval(<<'.,.,', 'grammar.y', 50)
|
329
|
+
def _reduce_15(val, _values, result)
|
253
330
|
result = val[1]
|
254
331
|
result
|
255
332
|
end
|
256
333
|
.,.,
|
257
334
|
|
258
|
-
module_eval(<<'.,.,', 'grammar.y',
|
259
|
-
def
|
335
|
+
module_eval(<<'.,.,', 'grammar.y', 52)
|
336
|
+
def _reduce_16(val, _values, result)
|
260
337
|
result = ConcatenationNode.new(val[0], val[1])
|
261
338
|
result
|
262
339
|
end
|
263
340
|
.,.,
|
264
341
|
|
265
|
-
# reduce
|
342
|
+
# reduce 17 omitted
|
266
343
|
|
267
|
-
# reduce
|
344
|
+
# reduce 18 omitted
|
268
345
|
|
269
|
-
# reduce
|
346
|
+
# reduce 19 omitted
|
270
347
|
|
271
|
-
module_eval(<<'.,.,', 'grammar.y',
|
272
|
-
def
|
348
|
+
module_eval(<<'.,.,', 'grammar.y', 58)
|
349
|
+
def _reduce_20(val, _values, result)
|
273
350
|
result = val[0] ; val[0].tail = val[1]
|
274
351
|
result
|
275
352
|
end
|
276
353
|
.,.,
|
277
354
|
|
278
|
-
# reduce
|
355
|
+
# reduce 21 omitted
|
279
356
|
|
280
|
-
module_eval(<<'.,.,', 'grammar.y',
|
281
|
-
def
|
357
|
+
module_eval(<<'.,.,', 'grammar.y', 62)
|
358
|
+
def _reduce_22(val, _values, result)
|
282
359
|
result = CommandSubstitutionNode.new(val[1])
|
283
360
|
result
|
284
361
|
end
|
285
362
|
.,.,
|
286
363
|
|
287
|
-
module_eval(<<'.,.,', 'grammar.y',
|
288
|
-
def
|
364
|
+
module_eval(<<'.,.,', 'grammar.y', 65)
|
365
|
+
def _reduce_23(val, _values, result)
|
289
366
|
val[0].heredoc = val[1] ; result = val[0]
|
290
367
|
result
|
291
368
|
end
|
292
369
|
.,.,
|
293
370
|
|
294
|
-
# reduce
|
371
|
+
# reduce 24 omitted
|
295
372
|
|
296
|
-
module_eval(<<'.,.,', 'grammar.y',
|
297
|
-
def
|
373
|
+
module_eval(<<'.,.,', 'grammar.y', 69)
|
374
|
+
def _reduce_25(val, _values, result)
|
298
375
|
val[0].redirects << RedirectionNode.new(val[1].value, val[1].attrs[:target]) ; result = val[0]
|
299
376
|
result
|
300
377
|
end
|
301
378
|
.,.,
|
302
379
|
|
303
|
-
# reduce
|
380
|
+
# reduce 26 omitted
|
304
381
|
|
305
|
-
# reduce
|
382
|
+
# reduce 27 omitted
|
306
383
|
|
307
|
-
# reduce
|
384
|
+
# reduce 28 omitted
|
308
385
|
|
309
|
-
module_eval(<<'.,.,', 'grammar.y',
|
310
|
-
def
|
386
|
+
module_eval(<<'.,.,', 'grammar.y', 75)
|
387
|
+
def _reduce_29(val, _values, result)
|
311
388
|
result = EnvWrapperNode.new(val[0], val[1])
|
312
389
|
result
|
313
390
|
end
|
314
391
|
.,.,
|
315
392
|
|
316
|
-
module_eval(<<'.,.,', 'grammar.y',
|
317
|
-
def
|
393
|
+
module_eval(<<'.,.,', 'grammar.y', 78)
|
394
|
+
def _reduce_30(val, _values, result)
|
318
395
|
val[0].add_var(val[1].value, val[2].value) ; result = val[0]
|
319
396
|
result
|
320
397
|
end
|
321
398
|
.,.,
|
322
399
|
|
323
|
-
module_eval(<<'.,.,', 'grammar.y',
|
324
|
-
def
|
400
|
+
module_eval(<<'.,.,', 'grammar.y', 80)
|
401
|
+
def _reduce_31(val, _values, result)
|
325
402
|
result = EnvNode.new(val[0].value, val[1].value)
|
326
403
|
result
|
327
404
|
end
|
328
405
|
.,.,
|
329
406
|
|
330
|
-
# reduce
|
407
|
+
# reduce 32 omitted
|
331
408
|
|
332
|
-
module_eval(<<'.,.,', 'grammar.y',
|
333
|
-
def
|
409
|
+
module_eval(<<'.,.,', 'grammar.y', 85)
|
410
|
+
def _reduce_33(val, _values, result)
|
334
411
|
result = CommandNode.new(val[0].value)
|
335
412
|
result
|
336
413
|
end
|
337
414
|
.,.,
|
338
415
|
|
339
|
-
module_eval(<<'.,.,', 'grammar.y',
|
340
|
-
def
|
416
|
+
module_eval(<<'.,.,', 'grammar.y', 87)
|
417
|
+
def _reduce_34(val, _values, result)
|
341
418
|
result = CommandNode.new(val[0].value, val[1].flatten)
|
342
419
|
result
|
343
420
|
end
|
344
421
|
.,.,
|
345
422
|
|
346
|
-
module_eval(<<'.,.,', 'grammar.y',
|
347
|
-
def
|
423
|
+
module_eval(<<'.,.,', 'grammar.y', 89)
|
424
|
+
def _reduce_35(val, _values, result)
|
348
425
|
result = CommandNode.new(val[0].value, literal:true)
|
349
426
|
result
|
350
427
|
end
|
351
428
|
.,.,
|
352
429
|
|
353
|
-
module_eval(<<'.,.,', 'grammar.y',
|
354
|
-
def
|
430
|
+
module_eval(<<'.,.,', 'grammar.y', 91)
|
431
|
+
def _reduce_36(val, _values, result)
|
355
432
|
result = CommandNode.new(val[0].value, val[1].flatten, literal:true)
|
356
433
|
result
|
357
434
|
end
|
358
435
|
.,.,
|
359
436
|
|
360
|
-
module_eval(<<'.,.,', 'grammar.y',
|
361
|
-
def
|
437
|
+
module_eval(<<'.,.,', 'grammar.y', 94)
|
438
|
+
def _reduce_37(val, _values, result)
|
362
439
|
result = [ArgumentNode.new(val[0].value)]
|
363
440
|
result
|
364
441
|
end
|
365
442
|
.,.,
|
366
443
|
|
367
|
-
module_eval(<<'.,.,', 'grammar.y',
|
368
|
-
def
|
444
|
+
module_eval(<<'.,.,', 'grammar.y', 96)
|
445
|
+
def _reduce_38(val, _values, result)
|
369
446
|
result = [val[0], ArgumentNode.new(val[1].value)].flatten
|
370
447
|
result
|
371
448
|
end
|
372
449
|
.,.,
|
373
450
|
|
374
|
-
module_eval(<<'.,.,', 'grammar.y',
|
375
|
-
def
|
451
|
+
module_eval(<<'.,.,', 'grammar.y', 99)
|
452
|
+
def _reduce_39(val, _values, result)
|
376
453
|
result = InternalEvalNode.new(val[0].value)
|
377
454
|
result
|
378
455
|
end
|
@@ -388,6 +465,7 @@ end
|
|
388
465
|
|
389
466
|
|
390
467
|
if $0 == __FILE__
|
468
|
+
require 'pry'
|
391
469
|
$LOAD_PATH.unshift File.dirname(__FILE__) + "/lib/"
|
392
470
|
require 'yap/shell/parser/lexer'
|
393
471
|
require 'yap/shell/parser/nodes'
|
@@ -396,7 +474,9 @@ if $0 == __FILE__
|
|
396
474
|
# "`git cbranch`",
|
397
475
|
# "`git cbranch`.bak",
|
398
476
|
# "echo `echo hi`",
|
399
|
-
"
|
477
|
+
# "ls *.rb te* { |f| f }",
|
478
|
+
# "f { |a, b, c| echo foo }"
|
479
|
+
"(0..3) as n : echo hi",
|
400
480
|
# "`hi``bye` `what`",
|
401
481
|
# "echo && `what` && where is `that`thing | `you know`",
|
402
482
|
].each do |src|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
|
2
2
|
|
3
|
+
require 'pry'
|
4
|
+
|
3
5
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
6
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
7
|
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
@@ -89,3 +91,28 @@ RSpec.configure do |config|
|
|
89
91
|
Kernel.srand config.seed
|
90
92
|
=end
|
91
93
|
end
|
94
|
+
|
95
|
+
|
96
|
+
RSpec::Matchers.define :parse do |expected|
|
97
|
+
match do |parser|
|
98
|
+
begin
|
99
|
+
results = parser.parse(expected)
|
100
|
+
pp results if ENV["DEBUG"]
|
101
|
+
rescue Yap::Shell::Parser::ParseError => ex
|
102
|
+
raise ex
|
103
|
+
end
|
104
|
+
true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
RSpec::Matchers.define :fail_parsing do |expected|
|
109
|
+
match do |parser|
|
110
|
+
begin
|
111
|
+
results = parser.parse(expected)
|
112
|
+
pp results if ENV["DEBUG"]
|
113
|
+
rescue Yap::Shell::Parser::ParseError => ex
|
114
|
+
return true
|
115
|
+
end
|
116
|
+
false
|
117
|
+
end
|
118
|
+
end
|