packcr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4292 @@
1
+ # A packrat parser generated by PackCR 0.0.4
2
+
3
+ class Packcr::Parser
4
+ def initialize(debug: false)
5
+ @buffer = +""
6
+
7
+ @pos = 0
8
+ @cur = 0
9
+ @level = 0
10
+ @lrstack = []
11
+ @thunks = []
12
+ @lrtable = LrTable.new
13
+ @debug = debug
14
+ @pos_loc = Location.new
15
+ @cur_loc = Location.new
16
+ @location = []
17
+ @lsource = []
18
+ @init = []
19
+ @utf8 = true
20
+ @ascii = false
21
+ @lang = :rb
22
+ @rules = []
23
+ @rulehash = {}
24
+ end
25
+
26
+ def debug
27
+ yield if @debug
28
+ end
29
+
30
+ def refill_buffer(num, mode = nil)
31
+ len = @buffer.length
32
+ if len >= @cur + num
33
+ return len - @cur
34
+ end
35
+ while len < @cur + num
36
+ c = $stdin.getc
37
+ break if !c
38
+ @buffer << c
39
+ len = @buffer.length
40
+ end
41
+ return len - @cur
42
+ end
43
+
44
+ def commit_buffer
45
+ @buffer = @buffer[@cur, @buffer.length - @cur]
46
+ @pos += @cur
47
+ @lrtable.shift(@cur)
48
+ @cur = 0
49
+ @pos_loc = @pos_loc + @cur_loc
50
+ @cur_loc = Location.new
51
+ end
52
+
53
+ def parse
54
+ if apply_rule(:evaluate_rule_statement, @thunks, nil, 0)
55
+ do_action(@thunks, nil, 0)
56
+ else
57
+ raise SyntaxError, "can't parse"
58
+ end
59
+ commit_buffer
60
+ @thunks.clear
61
+ refill_buffer(1) >= 1
62
+ end
63
+
64
+ def run
65
+ nil while parse
66
+ end
67
+
68
+ def action_statement_0(__pcc_in, __pcc_vars, __pcc_index)
69
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
70
+ __0 = __pcc_in.capt0.capture_string(@buffer)
71
+ __0s = @pos + __pcc_in.capt0.range_start
72
+ __0e = @pos + __pcc_in.capt0.range_end
73
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
74
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
75
+ @errnum += 1; warn "err #{__0.inspect} #{__0sl.linenum}, #{__0sl.charnum}"
76
+
77
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
78
+ end
79
+
80
+ def action_directive_include_0(__pcc_in, __pcc_vars, __pcc_index)
81
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
82
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
83
+ __0 = __pcc_in.capt0.capture_string(@buffer)
84
+ __0s = @pos + __pcc_in.capt0.range_start
85
+ __0e = @pos + __pcc_in.capt0.range_end
86
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
87
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
88
+ blocks.each { |b| @esource << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
89
+
90
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
91
+ end
92
+
93
+ def action_directive_include_1(__pcc_in, __pcc_vars, __pcc_index)
94
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
95
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
96
+ __0 = __pcc_in.capt0.capture_string(@buffer)
97
+ __0s = @pos + __pcc_in.capt0.range_start
98
+ __0e = @pos + __pcc_in.capt0.range_end
99
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
100
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
101
+ blocks.each { |b| @ecommon << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
102
+
103
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
104
+ end
105
+
106
+ def action_directive_include_2(__pcc_in, __pcc_vars, __pcc_index)
107
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
108
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
109
+ __0 = __pcc_in.capt0.capture_string(@buffer)
110
+ __0s = @pos + __pcc_in.capt0.range_start
111
+ __0e = @pos + __pcc_in.capt0.range_end
112
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
113
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
114
+ blocks.each { |b| @source << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
115
+
116
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
117
+ end
118
+
119
+ def action_directive_include_3(__pcc_in, __pcc_vars, __pcc_index)
120
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
121
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
122
+ __0 = __pcc_in.capt0.capture_string(@buffer)
123
+ __0s = @pos + __pcc_in.capt0.range_start
124
+ __0e = @pos + __pcc_in.capt0.range_end
125
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
126
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
127
+ blocks.each { |b| @lheader << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
128
+
129
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
130
+ end
131
+
132
+ def action_directive_include_4(__pcc_in, __pcc_vars, __pcc_index)
133
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
134
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
135
+ __0 = __pcc_in.capt0.capture_string(@buffer)
136
+ __0s = @pos + __pcc_in.capt0.range_start
137
+ __0e = @pos + __pcc_in.capt0.range_end
138
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
139
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
140
+ blocks.each { |b| @lsource << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
141
+
142
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
143
+ end
144
+
145
+ def action_directive_include_5(__pcc_in, __pcc_vars, __pcc_index)
146
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
147
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
148
+ __0 = __pcc_in.capt0.capture_string(@buffer)
149
+ __0s = @pos + __pcc_in.capt0.range_start
150
+ __0e = @pos + __pcc_in.capt0.range_end
151
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
152
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
153
+ blocks.each { |b| @header << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
154
+
155
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
156
+ end
157
+
158
+ def action_directive_include_6(__pcc_in, __pcc_vars, __pcc_index)
159
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
160
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
161
+ __0 = __pcc_in.capt0.capture_string(@buffer)
162
+ __0s = @pos + __pcc_in.capt0.range_start
163
+ __0e = @pos + __pcc_in.capt0.range_end
164
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
165
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
166
+ blocks.each { |b| @common << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
167
+
168
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
169
+ end
170
+
171
+ def action_directive_include_7(__pcc_in, __pcc_vars, __pcc_index)
172
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
173
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
174
+ __0 = __pcc_in.capt0.capture_string(@buffer)
175
+ __0s = @pos + __pcc_in.capt0.range_start
176
+ __0e = @pos + __pcc_in.capt0.range_end
177
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
178
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
179
+ blocks.each { |b| @location << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
180
+
181
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
182
+ end
183
+
184
+ def action_directive_include_8(__pcc_in, __pcc_vars, __pcc_index)
185
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
186
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
187
+ __0 = __pcc_in.capt0.capture_string(@buffer)
188
+ __0s = @pos + __pcc_in.capt0.range_start
189
+ __0e = @pos + __pcc_in.capt0.range_end
190
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
191
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
192
+ blocks.each { |b| @init << Packcr::CodeBlock.new(b, Packcr.find_trailing_blanks(b), __0sl.linenum, __0sl.charnum) }
193
+
194
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
195
+ end
196
+
197
+ def action_code_blocks_0(__pcc_in, __pcc_vars, __pcc_index)
198
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
199
+ blocks = (__pcc_in.value_refs[0] ||= Value.new).value
200
+ block = (__pcc_in.value_refs[1] ||= Value.new).value
201
+ __0 = __pcc_in.capt0.capture_string(@buffer)
202
+ __0s = @pos + __pcc_in.capt0.range_start
203
+ __0e = @pos + __pcc_in.capt0.range_end
204
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
205
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
206
+ blocks.push(block) if block; ____ = blocks
207
+
208
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
209
+ end
210
+
211
+ def action_code_blocks_1(__pcc_in, __pcc_vars, __pcc_index)
212
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
213
+ block = (__pcc_in.value_refs[1] ||= Value.new).value
214
+ __0 = __pcc_in.capt0.capture_string(@buffer)
215
+ __0s = @pos + __pcc_in.capt0.range_start
216
+ __0e = @pos + __pcc_in.capt0.range_end
217
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
218
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
219
+ ____ = block ? [block] : []
220
+
221
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
222
+ end
223
+
224
+ def action_directive_string_0(__pcc_in, __pcc_vars, __pcc_index)
225
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
226
+ str = (__pcc_in.value_refs[0] ||= Value.new).value
227
+ __0 = __pcc_in.capt0.capture_string(@buffer)
228
+ __0s = @pos + __pcc_in.capt0.range_start
229
+ __0e = @pos + __pcc_in.capt0.range_end
230
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
231
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
232
+ @value_type = str
233
+
234
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
235
+ end
236
+
237
+ def action_directive_string_1(__pcc_in, __pcc_vars, __pcc_index)
238
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
239
+ str = (__pcc_in.value_refs[0] ||= Value.new).value
240
+ __0 = __pcc_in.capt0.capture_string(@buffer)
241
+ __0s = @pos + __pcc_in.capt0.range_start
242
+ __0e = @pos + __pcc_in.capt0.range_end
243
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
244
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
245
+ @auxil_type = str
246
+
247
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
248
+ end
249
+
250
+ def action_directive_string_2(__pcc_in, __pcc_vars, __pcc_index)
251
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
252
+ str = (__pcc_in.value_refs[0] ||= Value.new).value
253
+ __0 = __pcc_in.capt0.capture_string(@buffer)
254
+ __0s = @pos + __pcc_in.capt0.range_start
255
+ __0e = @pos + __pcc_in.capt0.range_end
256
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
257
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
258
+ @prefix = str
259
+
260
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
261
+ end
262
+
263
+ def action_rule_0(__pcc_in, __pcc_vars, __pcc_index)
264
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
265
+ name = (__pcc_in.value_refs[0] ||= Value.new).value
266
+ expr = (__pcc_in.value_refs[1] ||= Value.new).value
267
+ __0 = __pcc_in.capt0.capture_string(@buffer)
268
+ __0s = @pos + __pcc_in.capt0.range_start
269
+ __0e = @pos + __pcc_in.capt0.range_end
270
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
271
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
272
+ rule = Packcr::Node::RuleNode.new(expr, name, __0sl.linenum, __0sl.charnum)
273
+ @rules << rule
274
+
275
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
276
+ end
277
+
278
+ def action_expression_0(__pcc_in, __pcc_vars, __pcc_index)
279
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
280
+ expr = (__pcc_in.value_refs[0] ||= Value.new).value
281
+ seq = (__pcc_in.value_refs[1] ||= Value.new).value
282
+ __0 = __pcc_in.capt0.capture_string(@buffer)
283
+ __0s = @pos + __pcc_in.capt0.range_start
284
+ __0e = @pos + __pcc_in.capt0.range_end
285
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
286
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
287
+ ____ = expr.alt(seq)
288
+
289
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
290
+ end
291
+
292
+ def action_expression_1(__pcc_in, __pcc_vars, __pcc_index)
293
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
294
+ seq = (__pcc_in.value_refs[1] ||= Value.new).value
295
+ __0 = __pcc_in.capt0.capture_string(@buffer)
296
+ __0s = @pos + __pcc_in.capt0.range_start
297
+ __0e = @pos + __pcc_in.capt0.range_end
298
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
299
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
300
+ ____ = seq
301
+
302
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
303
+ end
304
+
305
+ def action_sequence_0(__pcc_in, __pcc_vars, __pcc_index)
306
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
307
+ seq = (__pcc_in.value_refs[0] ||= Value.new).value
308
+ expr = (__pcc_in.value_refs[1] ||= Value.new).value
309
+ __0 = __pcc_in.capt0.capture_string(@buffer)
310
+ __0s = @pos + __pcc_in.capt0.range_start
311
+ __0e = @pos + __pcc_in.capt0.range_end
312
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
313
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
314
+ ____ = seq.seq(expr)
315
+
316
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
317
+ end
318
+
319
+ def action_sequence_1(__pcc_in, __pcc_vars, __pcc_index)
320
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
321
+ expr = (__pcc_in.value_refs[1] ||= Value.new).value
322
+ __0 = __pcc_in.capt0.capture_string(@buffer)
323
+ __0s = @pos + __pcc_in.capt0.range_start
324
+ __0e = @pos + __pcc_in.capt0.range_end
325
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
326
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
327
+ ____ = expr
328
+
329
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
330
+ end
331
+
332
+ def action_term_0(__pcc_in, __pcc_vars, __pcc_index)
333
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
334
+ expr = (__pcc_in.value_refs[0] ||= Value.new).value
335
+ code = (__pcc_in.value_refs[1] ||= Value.new).value
336
+ __0 = __pcc_in.capt0.capture_string(@buffer)
337
+ __0s = @pos + __pcc_in.capt0.range_start
338
+ __0e = @pos + __pcc_in.capt0.range_end
339
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
340
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
341
+ ____ = Packcr::Node::ErrorNode.new(expr, Packcr::CodeBlock.new(code, Packcr.find_trailing_blanks(code), __0sl.linenum, __0sl.charnum))
342
+
343
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
344
+ end
345
+
346
+ def action_term_1(__pcc_in, __pcc_vars, __pcc_index)
347
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
348
+ expr = (__pcc_in.value_refs[0] ||= Value.new).value
349
+ __0 = __pcc_in.capt0.capture_string(@buffer)
350
+ __0s = @pos + __pcc_in.capt0.range_start
351
+ __0e = @pos + __pcc_in.capt0.range_end
352
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
353
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
354
+ ____ = expr
355
+
356
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
357
+ end
358
+
359
+ def action_pred_0(__pcc_in, __pcc_vars, __pcc_index)
360
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
361
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
362
+ __0 = __pcc_in.capt0.capture_string(@buffer)
363
+ __0s = @pos + __pcc_in.capt0.range_start
364
+ __0e = @pos + __pcc_in.capt0.range_end
365
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
366
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
367
+ ____ = Packcr::Node::PredicateNode.new(node)
368
+
369
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
370
+ end
371
+
372
+ def action_pred_1(__pcc_in, __pcc_vars, __pcc_index)
373
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
374
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
375
+ __0 = __pcc_in.capt0.capture_string(@buffer)
376
+ __0s = @pos + __pcc_in.capt0.range_start
377
+ __0e = @pos + __pcc_in.capt0.range_end
378
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
379
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
380
+ ____ = Packcr::Node::PredicateNode.new(node, true)
381
+
382
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
383
+ end
384
+
385
+ def action_pred_2(__pcc_in, __pcc_vars, __pcc_index)
386
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
387
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
388
+ __0 = __pcc_in.capt0.capture_string(@buffer)
389
+ __0s = @pos + __pcc_in.capt0.range_start
390
+ __0e = @pos + __pcc_in.capt0.range_end
391
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
392
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
393
+ ____ = node
394
+
395
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
396
+ end
397
+
398
+ def action_quantity_0(__pcc_in, __pcc_vars, __pcc_index)
399
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
400
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
401
+ __0 = __pcc_in.capt0.capture_string(@buffer)
402
+ __0s = @pos + __pcc_in.capt0.range_start
403
+ __0e = @pos + __pcc_in.capt0.range_end
404
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
405
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
406
+ ____ = Packcr::Node::QuantityNode.new(node, 0, -1)
407
+
408
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
409
+ end
410
+
411
+ def action_quantity_1(__pcc_in, __pcc_vars, __pcc_index)
412
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
413
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
414
+ __0 = __pcc_in.capt0.capture_string(@buffer)
415
+ __0s = @pos + __pcc_in.capt0.range_start
416
+ __0e = @pos + __pcc_in.capt0.range_end
417
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
418
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
419
+ ____ = Packcr::Node::QuantityNode.new(node, 1, -1)
420
+
421
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
422
+ end
423
+
424
+ def action_quantity_2(__pcc_in, __pcc_vars, __pcc_index)
425
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
426
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
427
+ __0 = __pcc_in.capt0.capture_string(@buffer)
428
+ __0s = @pos + __pcc_in.capt0.range_start
429
+ __0e = @pos + __pcc_in.capt0.range_end
430
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
431
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
432
+ ____ = Packcr::Node::QuantityNode.new(node, 0, 1)
433
+
434
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
435
+ end
436
+
437
+ def action_quantity_3(__pcc_in, __pcc_vars, __pcc_index)
438
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
439
+ node = (__pcc_in.value_refs[0] ||= Value.new).value
440
+ __0 = __pcc_in.capt0.capture_string(@buffer)
441
+ __0s = @pos + __pcc_in.capt0.range_start
442
+ __0e = @pos + __pcc_in.capt0.range_end
443
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
444
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
445
+ ____ = node
446
+
447
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
448
+ end
449
+
450
+ def action_primary_0(__pcc_in, __pcc_vars, __pcc_index)
451
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
452
+ var_name = (__pcc_in.value_refs[0] ||= Value.new).value
453
+ name = (__pcc_in.value_refs[1] ||= Value.new).value
454
+ __0 = __pcc_in.capt0.capture_string(@buffer)
455
+ __0s = @pos + __pcc_in.capt0.range_start
456
+ __0e = @pos + __pcc_in.capt0.range_end
457
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
458
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
459
+ ____ = Packcr::Node::ReferenceNode.new(name, var_name, __0sl.linenum, __0sl.charnum)
460
+
461
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
462
+ end
463
+
464
+ def action_primary_1(__pcc_in, __pcc_vars, __pcc_index)
465
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
466
+ name = (__pcc_in.value_refs[1] ||= Value.new).value
467
+ __0 = __pcc_in.capt0.capture_string(@buffer)
468
+ __0s = @pos + __pcc_in.capt0.range_start
469
+ __0e = @pos + __pcc_in.capt0.range_end
470
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
471
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
472
+ ____ = Packcr::Node::ReferenceNode.new(name, nil, __0sl.linenum, __0sl.charnum)
473
+
474
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
475
+ end
476
+
477
+ def action_primary_2(__pcc_in, __pcc_vars, __pcc_index)
478
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
479
+ expr = (__pcc_in.value_refs[2] ||= Value.new).value
480
+ __0 = __pcc_in.capt0.capture_string(@buffer)
481
+ __0s = @pos + __pcc_in.capt0.range_start
482
+ __0e = @pos + __pcc_in.capt0.range_end
483
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
484
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
485
+ ____ = expr
486
+
487
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
488
+ end
489
+
490
+ def action_primary_3(__pcc_in, __pcc_vars, __pcc_index)
491
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
492
+ expr = (__pcc_in.value_refs[2] ||= Value.new).value
493
+ __0 = __pcc_in.capt0.capture_string(@buffer)
494
+ __0s = @pos + __pcc_in.capt0.range_start
495
+ __0e = @pos + __pcc_in.capt0.range_end
496
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
497
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
498
+ ____ = Packcr::Node::CaptureNode.new(expr)
499
+
500
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
501
+ end
502
+
503
+ def action_primary_4(__pcc_in, __pcc_vars, __pcc_index)
504
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
505
+ __0 = __pcc_in.capt0.capture_string(@buffer)
506
+ __0s = @pos + __pcc_in.capt0.range_start
507
+ __0e = @pos + __pcc_in.capt0.range_end
508
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
509
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
510
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
511
+ __1s = @pos + __pcc_in.capts[0].range_start
512
+ __1e = @pos + __pcc_in.capts[0].range_end
513
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
514
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
515
+ ____ = Packcr::Node::ExpandNode.new(__1.to_i - 1)
516
+
517
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
518
+ end
519
+
520
+ def action_primary_5(__pcc_in, __pcc_vars, __pcc_index)
521
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
522
+ __0 = __pcc_in.capt0.capture_string(@buffer)
523
+ __0s = @pos + __pcc_in.capt0.range_start
524
+ __0e = @pos + __pcc_in.capt0.range_end
525
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
526
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
527
+ ____ = Packcr::Node::CharclassNode.new
528
+
529
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
530
+ end
531
+
532
+ def action_primary_6(__pcc_in, __pcc_vars, __pcc_index)
533
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
534
+ str = (__pcc_in.value_refs[3] ||= Value.new).value
535
+ __0 = __pcc_in.capt0.capture_string(@buffer)
536
+ __0s = @pos + __pcc_in.capt0.range_start
537
+ __0e = @pos + __pcc_in.capt0.range_end
538
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
539
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
540
+ ____ = Packcr::Node::CharclassNode.new(Packcr.unescape_string(str, true))
541
+
542
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
543
+ end
544
+
545
+ def action_primary_7(__pcc_in, __pcc_vars, __pcc_index)
546
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
547
+ str = (__pcc_in.value_refs[3] ||= Value.new).value
548
+ __0 = __pcc_in.capt0.capture_string(@buffer)
549
+ __0s = @pos + __pcc_in.capt0.range_start
550
+ __0e = @pos + __pcc_in.capt0.range_end
551
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
552
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
553
+ ____ = Packcr::Node::StringNode.new(Packcr.unescape_string(str, false))
554
+
555
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
556
+ end
557
+
558
+ def action_primary_8(__pcc_in, __pcc_vars, __pcc_index)
559
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
560
+ str = (__pcc_in.value_refs[3] ||= Value.new).value
561
+ __0 = __pcc_in.capt0.capture_string(@buffer)
562
+ __0s = @pos + __pcc_in.capt0.range_start
563
+ __0e = @pos + __pcc_in.capt0.range_end
564
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
565
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
566
+ ____ = Packcr::Node::StringNode.new(Packcr.unescape_string(str, false))
567
+
568
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
569
+ end
570
+
571
+ def action_primary_9(__pcc_in, __pcc_vars, __pcc_index)
572
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
573
+ code = (__pcc_in.value_refs[4] ||= Value.new).value
574
+ __0 = __pcc_in.capt0.capture_string(@buffer)
575
+ __0s = @pos + __pcc_in.capt0.range_start
576
+ __0e = @pos + __pcc_in.capt0.range_end
577
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
578
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
579
+ ____ = Packcr::Node::ActionNode.new(Packcr::CodeBlock.new(code, Packcr.find_trailing_blanks(code), __0sl.linenum, __0sl.charnum))
580
+
581
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
582
+ end
583
+
584
+ def action_character_class_0(__pcc_in, __pcc_vars, __pcc_index)
585
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
586
+ __0 = __pcc_in.capt0.capture_string(@buffer)
587
+ __0s = @pos + __pcc_in.capt0.range_start
588
+ __0e = @pos + __pcc_in.capt0.range_end
589
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
590
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
591
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
592
+ __1s = @pos + __pcc_in.capts[0].range_start
593
+ __1e = @pos + __pcc_in.capts[0].range_end
594
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
595
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
596
+ ____ = __1
597
+
598
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
599
+ end
600
+
601
+ def action_lang_code_block_0(__pcc_in, __pcc_vars, __pcc_index)
602
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
603
+ code = (__pcc_in.value_refs[0] ||= Value.new).value
604
+ __0 = __pcc_in.capt0.capture_string(@buffer)
605
+ __0s = @pos + __pcc_in.capt0.range_start
606
+ __0e = @pos + __pcc_in.capt0.range_end
607
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
608
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
609
+ ____ = code
610
+
611
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
612
+ end
613
+
614
+ def action_lang_code_block_1(__pcc_in, __pcc_vars, __pcc_index)
615
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
616
+ code = (__pcc_in.value_refs[0] ||= Value.new).value
617
+ __0 = __pcc_in.capt0.capture_string(@buffer)
618
+ __0s = @pos + __pcc_in.capt0.range_start
619
+ __0e = @pos + __pcc_in.capt0.range_end
620
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
621
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
622
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
623
+ __1s = @pos + __pcc_in.capts[0].range_start
624
+ __1e = @pos + __pcc_in.capts[0].range_end
625
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
626
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
627
+ ____ = @lang == __1.to_sym ? code : nil
628
+
629
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
630
+ end
631
+
632
+ def action_code_block_0(__pcc_in, __pcc_vars, __pcc_index)
633
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
634
+ code = (__pcc_in.value_refs[0] ||= Value.new).value
635
+ __0 = __pcc_in.capt0.capture_string(@buffer)
636
+ __0s = @pos + __pcc_in.capt0.range_start
637
+ __0e = @pos + __pcc_in.capt0.range_end
638
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
639
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
640
+ ____ = code
641
+
642
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
643
+ end
644
+
645
+ def action_code_block_1(__pcc_in, __pcc_vars, __pcc_index)
646
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
647
+ code = (__pcc_in.value_refs[0] ||= Value.new).value
648
+ __0 = __pcc_in.capt0.capture_string(@buffer)
649
+ __0s = @pos + __pcc_in.capt0.range_start
650
+ __0e = @pos + __pcc_in.capt0.range_end
651
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
652
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
653
+ ____ = code.gsub("$", @lang == :rb ? "__" : "_")
654
+
655
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
656
+ end
657
+
658
+ def action_plain_code_block_0(__pcc_in, __pcc_vars, __pcc_index)
659
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
660
+ __0 = __pcc_in.capt0.capture_string(@buffer)
661
+ __0s = @pos + __pcc_in.capt0.range_start
662
+ __0e = @pos + __pcc_in.capt0.range_end
663
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
664
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
665
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
666
+ __1s = @pos + __pcc_in.capts[0].range_start
667
+ __1e = @pos + __pcc_in.capts[0].range_end
668
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
669
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
670
+ ____ = __1
671
+
672
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
673
+ end
674
+
675
+ def action_quotation_single_0(__pcc_in, __pcc_vars, __pcc_index)
676
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
677
+ __0 = __pcc_in.capt0.capture_string(@buffer)
678
+ __0s = @pos + __pcc_in.capt0.range_start
679
+ __0e = @pos + __pcc_in.capt0.range_end
680
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
681
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
682
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
683
+ __1s = @pos + __pcc_in.capts[0].range_start
684
+ __1e = @pos + __pcc_in.capts[0].range_end
685
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
686
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
687
+ ____ = __1
688
+
689
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
690
+ end
691
+
692
+ def action_quotation_double_0(__pcc_in, __pcc_vars, __pcc_index)
693
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
694
+ __0 = __pcc_in.capt0.capture_string(@buffer)
695
+ __0s = @pos + __pcc_in.capt0.range_start
696
+ __0e = @pos + __pcc_in.capt0.range_end
697
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
698
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
699
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
700
+ __1s = @pos + __pcc_in.capts[0].range_start
701
+ __1e = @pos + __pcc_in.capts[0].range_end
702
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
703
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
704
+ ____ = __1
705
+
706
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
707
+ end
708
+
709
+ def action_identifier_0(__pcc_in, __pcc_vars, __pcc_index)
710
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
711
+ __0 = __pcc_in.capt0.capture_string(@buffer)
712
+ __0s = @pos + __pcc_in.capt0.range_start
713
+ __0e = @pos + __pcc_in.capt0.range_end
714
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
715
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
716
+ ____ = __0
717
+
718
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
719
+ end
720
+
721
+ def action_footer_0(__pcc_in, __pcc_vars, __pcc_index)
722
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
723
+ __0 = __pcc_in.capt0.capture_string(@buffer)
724
+ __0s = @pos + __pcc_in.capt0.range_start
725
+ __0e = @pos + __pcc_in.capt0.range_end
726
+ __0sl = @pos_loc + __pcc_in.capt0.start_loc
727
+ __0el = @pos_loc + __pcc_in.capt0.end_loc
728
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
729
+ __1s = @pos + __pcc_in.capts[0].range_start
730
+ __1e = @pos + __pcc_in.capts[0].range_end
731
+ __1sl = @pos_loc + __pcc_in.capts[0].start_loc
732
+ __1el = @pos_loc + __pcc_in.capts[0].end_loc
733
+ @lsource << Packcr::CodeBlock.new(__1, Packcr.find_trailing_blanks(__1), __1sl.linenum, __1sl.charnum)
734
+
735
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
736
+ end
737
+
738
+ def evaluate_rule_statement
739
+ chunk = ThunkChunk.new
740
+ chunk.pos = @cur
741
+ chunk.pos_loc = @cur_loc
742
+ debug { warn "#{ " " * @level}EVAL statement #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
743
+ @level += 1
744
+ chunk.resize_captures(0)
745
+ catch(0) do
746
+ catch(1) do |; pos, p_loc, n|
747
+ pos = @cur
748
+ p_loc = @cur_loc
749
+ n = chunk.thunks.length
750
+ catch(2) do
751
+ if !apply_rule(:evaluate_rule_comment, chunk.thunks, nil, 0)
752
+ throw(2)
753
+ end
754
+ throw(1)
755
+ end
756
+ @cur = pos
757
+ @cur_loc = p_loc
758
+ chunk.thunks[n..-1] = []
759
+ catch(3) do
760
+ if !apply_rule(:evaluate_rule_spaces, chunk.thunks, nil, 0)
761
+ throw(3)
762
+ end
763
+ throw(1)
764
+ end
765
+ @cur = pos
766
+ @cur_loc = p_loc
767
+ chunk.thunks[n..-1] = []
768
+ catch(4) do
769
+ if !apply_rule(:evaluate_rule_directive_include, chunk.thunks, nil, 0)
770
+ throw(4)
771
+ end
772
+ throw(1)
773
+ end
774
+ @cur = pos
775
+ @cur_loc = p_loc
776
+ chunk.thunks[n..-1] = []
777
+ catch(5) do
778
+ if !apply_rule(:evaluate_rule_directive_string, chunk.thunks, nil, 0)
779
+ throw(5)
780
+ end
781
+ throw(1)
782
+ end
783
+ @cur = pos
784
+ @cur_loc = p_loc
785
+ chunk.thunks[n..-1] = []
786
+ catch(6) do
787
+ if !apply_rule(:evaluate_rule_rule, chunk.thunks, nil, 0)
788
+ throw(6)
789
+ end
790
+ throw(1)
791
+ end
792
+ @cur = pos
793
+ @cur_loc = p_loc
794
+ chunk.thunks[n..-1] = []
795
+ catch(7) do
796
+ if !apply_rule(:evaluate_rule_footer, chunk.thunks, nil, 0)
797
+ throw(7)
798
+ end
799
+ throw(1)
800
+ end
801
+ @cur = pos
802
+ @cur_loc = p_loc
803
+ chunk.thunks[n..-1] = []
804
+ catch(8) do
805
+ 1.times do |;p0, p0_loc, n0, i|
806
+ i = -1
807
+ loop do |;pos, p_loc, n, stat|
808
+ i += 1
809
+ pos = @cur
810
+ p_loc = @cur_loc
811
+ n = chunk.thunks.length
812
+ stat = nil
813
+ catch(9) do
814
+ 1.times do |;u, n|
815
+ if refill_buffer(1) < 1
816
+ throw(9)
817
+ end
818
+ u = @buffer[@cur]
819
+ if (
820
+ u == "\n"
821
+ )
822
+ throw(9)
823
+ end
824
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
825
+ @cur += 1
826
+ end
827
+ if @cur == pos
828
+ stat = :break
829
+ else
830
+ stat = :continue
831
+ end
832
+ end
833
+ if stat == :break
834
+ break
835
+ elsif stat != :continue
836
+ @cur = pos
837
+ @cur_loc = p_loc
838
+ chunk.thunks[n..-1] = []
839
+ break
840
+ end
841
+ end
842
+ end
843
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
844
+ thunk = ThunkLeaf.new(:action_statement_0)
845
+ capt0 = thunk.capt0
846
+ capt0.range_start = chunk.pos
847
+ capt0.range_end = @cur
848
+ capt0.start_loc = chunk.pos_loc
849
+ capt0.end_loc = @cur_loc
850
+ chunk.thunks.push(thunk)
851
+ end
852
+ end
853
+ end
854
+ debug { warn "#{ " " * @level}MATCH statement #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
855
+ return chunk
856
+ ensure
857
+ @level -= 1
858
+ end
859
+ end
860
+
861
+ def evaluate_rule_comment
862
+ chunk = ThunkChunk.new
863
+ chunk.pos = @cur
864
+ chunk.pos_loc = @cur_loc
865
+ debug { warn "#{ " " * @level}EVAL comment #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
866
+ @level += 1
867
+ chunk.resize_captures(0)
868
+ catch(0) do
869
+ if (
870
+ refill_buffer(1) < 1 ||
871
+ @buffer[@cur] != "#"
872
+ )
873
+ throw(0)
874
+ end
875
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
876
+ @cur += 1
877
+ 1.times do |;p0, p0_loc, n0, i|
878
+ i = -1
879
+ loop do |;pos, p_loc, n, stat|
880
+ i += 1
881
+ pos = @cur
882
+ p_loc = @cur_loc
883
+ n = chunk.thunks.length
884
+ stat = nil
885
+ catch(1) do
886
+ 1.times do |;u, n|
887
+ if refill_buffer(1) < 1
888
+ throw(1)
889
+ end
890
+ u = @buffer[@cur]
891
+ if (
892
+ u == "\n"
893
+ )
894
+ throw(1)
895
+ end
896
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
897
+ @cur += 1
898
+ end
899
+ if @cur == pos
900
+ stat = :break
901
+ else
902
+ stat = :continue
903
+ end
904
+ end
905
+ if stat == :break
906
+ break
907
+ elsif stat != :continue
908
+ @cur = pos
909
+ @cur_loc = p_loc
910
+ chunk.thunks[n..-1] = []
911
+ break
912
+ end
913
+ end
914
+ end
915
+ if !apply_rule(:evaluate_rule_lf, chunk.thunks, nil, 0)
916
+ throw(0)
917
+ end
918
+ debug { warn "#{ " " * @level}MATCH comment #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
919
+ return chunk
920
+ ensure
921
+ @level -= 1
922
+ end
923
+ debug { warn "#{ " " * @level}NOMATCH comment #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
924
+ return nil
925
+ end
926
+
927
+ def evaluate_rule_directive_include
928
+ chunk = ThunkChunk.new
929
+ chunk.pos = @cur
930
+ chunk.pos_loc = @cur_loc
931
+ debug { warn "#{ " " * @level}EVAL directive_include #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
932
+ @level += 1
933
+ chunk.resize_captures(0)
934
+ chunk.values = []
935
+ catch(0) do
936
+ catch(1) do |; pos, p_loc, n|
937
+ pos = @cur
938
+ p_loc = @cur_loc
939
+ n = chunk.thunks.length
940
+ catch(2) do
941
+ if (
942
+ refill_buffer(12) < 12 ||
943
+ @buffer[@cur, 12] != "%earlysource"
944
+ )
945
+ throw(2)
946
+ end
947
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 12)
948
+ @cur += 12
949
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
950
+ throw(2)
951
+ end
952
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
953
+ throw(2)
954
+ end
955
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
956
+ thunk = ThunkLeaf.new(:action_directive_include_0)
957
+ capt0 = thunk.capt0
958
+ values = chunk.values
959
+ value_refs = thunk.value_refs
960
+ value = values[0]
961
+ value_refs[0] = value
962
+ capt0.range_start = chunk.pos
963
+ capt0.range_end = @cur
964
+ capt0.start_loc = chunk.pos_loc
965
+ capt0.end_loc = @cur_loc
966
+ chunk.thunks.push(thunk)
967
+ end
968
+ throw(1)
969
+ end
970
+ @cur = pos
971
+ @cur_loc = p_loc
972
+ chunk.thunks[n..-1] = []
973
+ catch(3) do
974
+ if (
975
+ refill_buffer(12) < 12 ||
976
+ @buffer[@cur, 12] != "%earlycommon"
977
+ )
978
+ throw(3)
979
+ end
980
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 12)
981
+ @cur += 12
982
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
983
+ throw(3)
984
+ end
985
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
986
+ throw(3)
987
+ end
988
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
989
+ thunk = ThunkLeaf.new(:action_directive_include_1)
990
+ capt0 = thunk.capt0
991
+ values = chunk.values
992
+ value_refs = thunk.value_refs
993
+ value = values[0]
994
+ value_refs[0] = value
995
+ capt0.range_start = chunk.pos
996
+ capt0.range_end = @cur
997
+ capt0.start_loc = chunk.pos_loc
998
+ capt0.end_loc = @cur_loc
999
+ chunk.thunks.push(thunk)
1000
+ end
1001
+ throw(1)
1002
+ end
1003
+ @cur = pos
1004
+ @cur_loc = p_loc
1005
+ chunk.thunks[n..-1] = []
1006
+ catch(4) do
1007
+ if (
1008
+ refill_buffer(7) < 7 ||
1009
+ @buffer[@cur, 7] != "%source"
1010
+ )
1011
+ throw(4)
1012
+ end
1013
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 7)
1014
+ @cur += 7
1015
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1016
+ throw(4)
1017
+ end
1018
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1019
+ throw(4)
1020
+ end
1021
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1022
+ thunk = ThunkLeaf.new(:action_directive_include_2)
1023
+ capt0 = thunk.capt0
1024
+ values = chunk.values
1025
+ value_refs = thunk.value_refs
1026
+ value = values[0]
1027
+ value_refs[0] = value
1028
+ capt0.range_start = chunk.pos
1029
+ capt0.range_end = @cur
1030
+ capt0.start_loc = chunk.pos_loc
1031
+ capt0.end_loc = @cur_loc
1032
+ chunk.thunks.push(thunk)
1033
+ end
1034
+ throw(1)
1035
+ end
1036
+ @cur = pos
1037
+ @cur_loc = p_loc
1038
+ chunk.thunks[n..-1] = []
1039
+ catch(5) do
1040
+ if (
1041
+ refill_buffer(11) < 11 ||
1042
+ @buffer[@cur, 11] != "%lateheader"
1043
+ )
1044
+ throw(5)
1045
+ end
1046
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 11)
1047
+ @cur += 11
1048
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1049
+ throw(5)
1050
+ end
1051
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1052
+ throw(5)
1053
+ end
1054
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1055
+ thunk = ThunkLeaf.new(:action_directive_include_3)
1056
+ capt0 = thunk.capt0
1057
+ values = chunk.values
1058
+ value_refs = thunk.value_refs
1059
+ value = values[0]
1060
+ value_refs[0] = value
1061
+ capt0.range_start = chunk.pos
1062
+ capt0.range_end = @cur
1063
+ capt0.start_loc = chunk.pos_loc
1064
+ capt0.end_loc = @cur_loc
1065
+ chunk.thunks.push(thunk)
1066
+ end
1067
+ throw(1)
1068
+ end
1069
+ @cur = pos
1070
+ @cur_loc = p_loc
1071
+ chunk.thunks[n..-1] = []
1072
+ catch(6) do
1073
+ if (
1074
+ refill_buffer(11) < 11 ||
1075
+ @buffer[@cur, 11] != "%latesource"
1076
+ )
1077
+ throw(6)
1078
+ end
1079
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 11)
1080
+ @cur += 11
1081
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1082
+ throw(6)
1083
+ end
1084
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1085
+ throw(6)
1086
+ end
1087
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1088
+ thunk = ThunkLeaf.new(:action_directive_include_4)
1089
+ capt0 = thunk.capt0
1090
+ values = chunk.values
1091
+ value_refs = thunk.value_refs
1092
+ value = values[0]
1093
+ value_refs[0] = value
1094
+ capt0.range_start = chunk.pos
1095
+ capt0.range_end = @cur
1096
+ capt0.start_loc = chunk.pos_loc
1097
+ capt0.end_loc = @cur_loc
1098
+ chunk.thunks.push(thunk)
1099
+ end
1100
+ throw(1)
1101
+ end
1102
+ @cur = pos
1103
+ @cur_loc = p_loc
1104
+ chunk.thunks[n..-1] = []
1105
+ catch(7) do
1106
+ if (
1107
+ refill_buffer(7) < 7 ||
1108
+ @buffer[@cur, 7] != "%header"
1109
+ )
1110
+ throw(7)
1111
+ end
1112
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 7)
1113
+ @cur += 7
1114
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1115
+ throw(7)
1116
+ end
1117
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1118
+ throw(7)
1119
+ end
1120
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1121
+ thunk = ThunkLeaf.new(:action_directive_include_5)
1122
+ capt0 = thunk.capt0
1123
+ values = chunk.values
1124
+ value_refs = thunk.value_refs
1125
+ value = values[0]
1126
+ value_refs[0] = value
1127
+ capt0.range_start = chunk.pos
1128
+ capt0.range_end = @cur
1129
+ capt0.start_loc = chunk.pos_loc
1130
+ capt0.end_loc = @cur_loc
1131
+ chunk.thunks.push(thunk)
1132
+ end
1133
+ throw(1)
1134
+ end
1135
+ @cur = pos
1136
+ @cur_loc = p_loc
1137
+ chunk.thunks[n..-1] = []
1138
+ catch(8) do
1139
+ if (
1140
+ refill_buffer(7) < 7 ||
1141
+ @buffer[@cur, 7] != "%common"
1142
+ )
1143
+ throw(8)
1144
+ end
1145
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 7)
1146
+ @cur += 7
1147
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1148
+ throw(8)
1149
+ end
1150
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1151
+ throw(8)
1152
+ end
1153
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1154
+ thunk = ThunkLeaf.new(:action_directive_include_6)
1155
+ capt0 = thunk.capt0
1156
+ values = chunk.values
1157
+ value_refs = thunk.value_refs
1158
+ value = values[0]
1159
+ value_refs[0] = value
1160
+ capt0.range_start = chunk.pos
1161
+ capt0.range_end = @cur
1162
+ capt0.start_loc = chunk.pos_loc
1163
+ capt0.end_loc = @cur_loc
1164
+ chunk.thunks.push(thunk)
1165
+ end
1166
+ throw(1)
1167
+ end
1168
+ @cur = pos
1169
+ @cur_loc = p_loc
1170
+ chunk.thunks[n..-1] = []
1171
+ catch(9) do
1172
+ if (
1173
+ refill_buffer(9) < 9 ||
1174
+ @buffer[@cur, 9] != "%location"
1175
+ )
1176
+ throw(9)
1177
+ end
1178
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 9)
1179
+ @cur += 9
1180
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1181
+ throw(9)
1182
+ end
1183
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1184
+ throw(9)
1185
+ end
1186
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1187
+ thunk = ThunkLeaf.new(:action_directive_include_7)
1188
+ capt0 = thunk.capt0
1189
+ values = chunk.values
1190
+ value_refs = thunk.value_refs
1191
+ value = values[0]
1192
+ value_refs[0] = value
1193
+ capt0.range_start = chunk.pos
1194
+ capt0.range_end = @cur
1195
+ capt0.start_loc = chunk.pos_loc
1196
+ capt0.end_loc = @cur_loc
1197
+ chunk.thunks.push(thunk)
1198
+ end
1199
+ throw(1)
1200
+ end
1201
+ @cur = pos
1202
+ @cur_loc = p_loc
1203
+ chunk.thunks[n..-1] = []
1204
+ catch(10) do
1205
+ if (
1206
+ refill_buffer(11) < 11 ||
1207
+ @buffer[@cur, 11] != "%initialize"
1208
+ )
1209
+ throw(10)
1210
+ end
1211
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 11)
1212
+ @cur += 11
1213
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1214
+ throw(10)
1215
+ end
1216
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1217
+ throw(10)
1218
+ end
1219
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1220
+ thunk = ThunkLeaf.new(:action_directive_include_8)
1221
+ capt0 = thunk.capt0
1222
+ values = chunk.values
1223
+ value_refs = thunk.value_refs
1224
+ value = values[0]
1225
+ value_refs[0] = value
1226
+ capt0.range_start = chunk.pos
1227
+ capt0.range_end = @cur
1228
+ capt0.start_loc = chunk.pos_loc
1229
+ capt0.end_loc = @cur_loc
1230
+ chunk.thunks.push(thunk)
1231
+ end
1232
+ throw(1)
1233
+ end
1234
+ @cur = pos
1235
+ @cur_loc = p_loc
1236
+ chunk.thunks[n..-1] = []
1237
+ throw(0)
1238
+ end
1239
+ debug { warn "#{ " " * @level}MATCH directive_include #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1240
+ return chunk
1241
+ ensure
1242
+ @level -= 1
1243
+ end
1244
+ debug { warn "#{ " " * @level}NOMATCH directive_include #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1245
+ return nil
1246
+ end
1247
+
1248
+ def evaluate_rule_code_blocks
1249
+ chunk = ThunkChunk.new
1250
+ chunk.pos = @cur
1251
+ chunk.pos_loc = @cur_loc
1252
+ debug { warn "#{ " " * @level}EVAL code_blocks #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1253
+ @level += 1
1254
+ chunk.resize_captures(0)
1255
+ chunk.values = []
1256
+ catch(0) do
1257
+ catch(1) do |; pos, p_loc, n|
1258
+ pos = @cur
1259
+ p_loc = @cur_loc
1260
+ n = chunk.thunks.length
1261
+ catch(2) do
1262
+ if !apply_rule(:evaluate_rule_code_blocks, chunk.thunks, chunk.values, 0)
1263
+ throw(2)
1264
+ end
1265
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1266
+ throw(2)
1267
+ end
1268
+ if !apply_rule(:evaluate_rule_lang_code_block, chunk.thunks, chunk.values, 1)
1269
+ throw(2)
1270
+ end
1271
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1272
+ thunk = ThunkLeaf.new(:action_code_blocks_0)
1273
+ capt0 = thunk.capt0
1274
+ values = chunk.values
1275
+ value_refs = thunk.value_refs
1276
+ value = values[0]
1277
+ value_refs[0] = value
1278
+ value = values[1]
1279
+ value_refs[1] = value
1280
+ capt0.range_start = chunk.pos
1281
+ capt0.range_end = @cur
1282
+ capt0.start_loc = chunk.pos_loc
1283
+ capt0.end_loc = @cur_loc
1284
+ chunk.thunks.push(thunk)
1285
+ end
1286
+ throw(1)
1287
+ end
1288
+ @cur = pos
1289
+ @cur_loc = p_loc
1290
+ chunk.thunks[n..-1] = []
1291
+ catch(3) do
1292
+ if !apply_rule(:evaluate_rule_lang_code_block, chunk.thunks, chunk.values, 1)
1293
+ throw(3)
1294
+ end
1295
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1296
+ thunk = ThunkLeaf.new(:action_code_blocks_1)
1297
+ capt0 = thunk.capt0
1298
+ values = chunk.values
1299
+ value_refs = thunk.value_refs
1300
+ value = values[1]
1301
+ value_refs[1] = value
1302
+ capt0.range_start = chunk.pos
1303
+ capt0.range_end = @cur
1304
+ capt0.start_loc = chunk.pos_loc
1305
+ capt0.end_loc = @cur_loc
1306
+ chunk.thunks.push(thunk)
1307
+ end
1308
+ throw(1)
1309
+ end
1310
+ @cur = pos
1311
+ @cur_loc = p_loc
1312
+ chunk.thunks[n..-1] = []
1313
+ throw(0)
1314
+ end
1315
+ debug { warn "#{ " " * @level}MATCH code_blocks #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1316
+ return chunk
1317
+ ensure
1318
+ @level -= 1
1319
+ end
1320
+ debug { warn "#{ " " * @level}NOMATCH code_blocks #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1321
+ return nil
1322
+ end
1323
+
1324
+ def evaluate_rule_directive_string
1325
+ chunk = ThunkChunk.new
1326
+ chunk.pos = @cur
1327
+ chunk.pos_loc = @cur_loc
1328
+ debug { warn "#{ " " * @level}EVAL directive_string #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1329
+ @level += 1
1330
+ chunk.resize_captures(0)
1331
+ chunk.values = []
1332
+ catch(0) do
1333
+ catch(1) do |; pos, p_loc, n|
1334
+ pos = @cur
1335
+ p_loc = @cur_loc
1336
+ n = chunk.thunks.length
1337
+ catch(2) do
1338
+ if (
1339
+ refill_buffer(6) < 6 ||
1340
+ @buffer[@cur, 6] != "%value"
1341
+ )
1342
+ throw(2)
1343
+ end
1344
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 6)
1345
+ @cur += 6
1346
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1347
+ throw(2)
1348
+ end
1349
+ if !apply_rule(:evaluate_rule_quotation_double, chunk.thunks, chunk.values, 0)
1350
+ throw(2)
1351
+ end
1352
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1353
+ thunk = ThunkLeaf.new(:action_directive_string_0)
1354
+ capt0 = thunk.capt0
1355
+ values = chunk.values
1356
+ value_refs = thunk.value_refs
1357
+ value = values[0]
1358
+ value_refs[0] = value
1359
+ capt0.range_start = chunk.pos
1360
+ capt0.range_end = @cur
1361
+ capt0.start_loc = chunk.pos_loc
1362
+ capt0.end_loc = @cur_loc
1363
+ chunk.thunks.push(thunk)
1364
+ end
1365
+ throw(1)
1366
+ end
1367
+ @cur = pos
1368
+ @cur_loc = p_loc
1369
+ chunk.thunks[n..-1] = []
1370
+ catch(3) do
1371
+ if (
1372
+ refill_buffer(6) < 6 ||
1373
+ @buffer[@cur, 6] != "%auxil"
1374
+ )
1375
+ throw(3)
1376
+ end
1377
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 6)
1378
+ @cur += 6
1379
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1380
+ throw(3)
1381
+ end
1382
+ if !apply_rule(:evaluate_rule_quotation_double, chunk.thunks, chunk.values, 0)
1383
+ throw(3)
1384
+ end
1385
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1386
+ thunk = ThunkLeaf.new(:action_directive_string_1)
1387
+ capt0 = thunk.capt0
1388
+ values = chunk.values
1389
+ value_refs = thunk.value_refs
1390
+ value = values[0]
1391
+ value_refs[0] = value
1392
+ capt0.range_start = chunk.pos
1393
+ capt0.range_end = @cur
1394
+ capt0.start_loc = chunk.pos_loc
1395
+ capt0.end_loc = @cur_loc
1396
+ chunk.thunks.push(thunk)
1397
+ end
1398
+ throw(1)
1399
+ end
1400
+ @cur = pos
1401
+ @cur_loc = p_loc
1402
+ chunk.thunks[n..-1] = []
1403
+ catch(4) do
1404
+ if (
1405
+ refill_buffer(7) < 7 ||
1406
+ @buffer[@cur, 7] != "%prefix"
1407
+ )
1408
+ throw(4)
1409
+ end
1410
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 7)
1411
+ @cur += 7
1412
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1413
+ throw(4)
1414
+ end
1415
+ if !apply_rule(:evaluate_rule_quotation_double, chunk.thunks, chunk.values, 0)
1416
+ throw(4)
1417
+ end
1418
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1419
+ thunk = ThunkLeaf.new(:action_directive_string_2)
1420
+ capt0 = thunk.capt0
1421
+ values = chunk.values
1422
+ value_refs = thunk.value_refs
1423
+ value = values[0]
1424
+ value_refs[0] = value
1425
+ capt0.range_start = chunk.pos
1426
+ capt0.range_end = @cur
1427
+ capt0.start_loc = chunk.pos_loc
1428
+ capt0.end_loc = @cur_loc
1429
+ chunk.thunks.push(thunk)
1430
+ end
1431
+ throw(1)
1432
+ end
1433
+ @cur = pos
1434
+ @cur_loc = p_loc
1435
+ chunk.thunks[n..-1] = []
1436
+ throw(0)
1437
+ end
1438
+ debug { warn "#{ " " * @level}MATCH directive_string #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1439
+ return chunk
1440
+ ensure
1441
+ @level -= 1
1442
+ end
1443
+ debug { warn "#{ " " * @level}NOMATCH directive_string #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1444
+ return nil
1445
+ end
1446
+
1447
+ def evaluate_rule_rule
1448
+ chunk = ThunkChunk.new
1449
+ chunk.pos = @cur
1450
+ chunk.pos_loc = @cur_loc
1451
+ debug { warn "#{ " " * @level}EVAL rule #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1452
+ @level += 1
1453
+ chunk.resize_captures(0)
1454
+ chunk.values = []
1455
+ catch(0) do
1456
+ if !apply_rule(:evaluate_rule_identifier, chunk.thunks, chunk.values, 0)
1457
+ throw(0)
1458
+ end
1459
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1460
+ throw(0)
1461
+ end
1462
+ if (
1463
+ refill_buffer(2) < 2 ||
1464
+ @buffer[@cur, 2] != "<-"
1465
+ )
1466
+ throw(0)
1467
+ end
1468
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
1469
+ @cur += 2
1470
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1471
+ throw(0)
1472
+ end
1473
+ if !apply_rule(:evaluate_rule_expression, chunk.thunks, chunk.values, 1)
1474
+ throw(0)
1475
+ end
1476
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1477
+ thunk = ThunkLeaf.new(:action_rule_0)
1478
+ capt0 = thunk.capt0
1479
+ values = chunk.values
1480
+ value_refs = thunk.value_refs
1481
+ value = values[0]
1482
+ value_refs[0] = value
1483
+ value = values[1]
1484
+ value_refs[1] = value
1485
+ capt0.range_start = chunk.pos
1486
+ capt0.range_end = @cur
1487
+ capt0.start_loc = chunk.pos_loc
1488
+ capt0.end_loc = @cur_loc
1489
+ chunk.thunks.push(thunk)
1490
+ end
1491
+ debug { warn "#{ " " * @level}MATCH rule #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1492
+ return chunk
1493
+ ensure
1494
+ @level -= 1
1495
+ end
1496
+ debug { warn "#{ " " * @level}NOMATCH rule #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1497
+ return nil
1498
+ end
1499
+
1500
+ def evaluate_rule_expression
1501
+ chunk = ThunkChunk.new
1502
+ chunk.pos = @cur
1503
+ chunk.pos_loc = @cur_loc
1504
+ debug { warn "#{ " " * @level}EVAL expression #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1505
+ @level += 1
1506
+ chunk.resize_captures(0)
1507
+ chunk.values = []
1508
+ catch(0) do
1509
+ catch(1) do |; pos, p_loc, n|
1510
+ pos = @cur
1511
+ p_loc = @cur_loc
1512
+ n = chunk.thunks.length
1513
+ catch(2) do
1514
+ if !apply_rule(:evaluate_rule_expression, chunk.thunks, chunk.values, 0)
1515
+ throw(2)
1516
+ end
1517
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1518
+ throw(2)
1519
+ end
1520
+ if (
1521
+ refill_buffer(1) < 1 ||
1522
+ @buffer[@cur] != "/"
1523
+ )
1524
+ throw(2)
1525
+ end
1526
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1527
+ @cur += 1
1528
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1529
+ throw(2)
1530
+ end
1531
+ if !apply_rule(:evaluate_rule_sequence, chunk.thunks, chunk.values, 1)
1532
+ throw(2)
1533
+ end
1534
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1535
+ thunk = ThunkLeaf.new(:action_expression_0)
1536
+ capt0 = thunk.capt0
1537
+ values = chunk.values
1538
+ value_refs = thunk.value_refs
1539
+ value = values[0]
1540
+ value_refs[0] = value
1541
+ value = values[1]
1542
+ value_refs[1] = value
1543
+ capt0.range_start = chunk.pos
1544
+ capt0.range_end = @cur
1545
+ capt0.start_loc = chunk.pos_loc
1546
+ capt0.end_loc = @cur_loc
1547
+ chunk.thunks.push(thunk)
1548
+ end
1549
+ throw(1)
1550
+ end
1551
+ @cur = pos
1552
+ @cur_loc = p_loc
1553
+ chunk.thunks[n..-1] = []
1554
+ catch(3) do
1555
+ if !apply_rule(:evaluate_rule_sequence, chunk.thunks, chunk.values, 1)
1556
+ throw(3)
1557
+ end
1558
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1559
+ thunk = ThunkLeaf.new(:action_expression_1)
1560
+ capt0 = thunk.capt0
1561
+ values = chunk.values
1562
+ value_refs = thunk.value_refs
1563
+ value = values[1]
1564
+ value_refs[1] = value
1565
+ capt0.range_start = chunk.pos
1566
+ capt0.range_end = @cur
1567
+ capt0.start_loc = chunk.pos_loc
1568
+ capt0.end_loc = @cur_loc
1569
+ chunk.thunks.push(thunk)
1570
+ end
1571
+ throw(1)
1572
+ end
1573
+ @cur = pos
1574
+ @cur_loc = p_loc
1575
+ chunk.thunks[n..-1] = []
1576
+ throw(0)
1577
+ end
1578
+ debug { warn "#{ " " * @level}MATCH expression #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1579
+ return chunk
1580
+ ensure
1581
+ @level -= 1
1582
+ end
1583
+ debug { warn "#{ " " * @level}NOMATCH expression #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1584
+ return nil
1585
+ end
1586
+
1587
+ def evaluate_rule_sequence
1588
+ chunk = ThunkChunk.new
1589
+ chunk.pos = @cur
1590
+ chunk.pos_loc = @cur_loc
1591
+ debug { warn "#{ " " * @level}EVAL sequence #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1592
+ @level += 1
1593
+ chunk.resize_captures(0)
1594
+ chunk.values = []
1595
+ catch(0) do
1596
+ catch(1) do |; pos, p_loc, n|
1597
+ pos = @cur
1598
+ p_loc = @cur_loc
1599
+ n = chunk.thunks.length
1600
+ catch(2) do
1601
+ if !apply_rule(:evaluate_rule_sequence, chunk.thunks, chunk.values, 0)
1602
+ throw(2)
1603
+ end
1604
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1605
+ throw(2)
1606
+ end
1607
+ if !apply_rule(:evaluate_rule_term, chunk.thunks, chunk.values, 1)
1608
+ throw(2)
1609
+ end
1610
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1611
+ thunk = ThunkLeaf.new(:action_sequence_0)
1612
+ capt0 = thunk.capt0
1613
+ values = chunk.values
1614
+ value_refs = thunk.value_refs
1615
+ value = values[0]
1616
+ value_refs[0] = value
1617
+ value = values[1]
1618
+ value_refs[1] = value
1619
+ capt0.range_start = chunk.pos
1620
+ capt0.range_end = @cur
1621
+ capt0.start_loc = chunk.pos_loc
1622
+ capt0.end_loc = @cur_loc
1623
+ chunk.thunks.push(thunk)
1624
+ end
1625
+ throw(1)
1626
+ end
1627
+ @cur = pos
1628
+ @cur_loc = p_loc
1629
+ chunk.thunks[n..-1] = []
1630
+ catch(3) do
1631
+ if !apply_rule(:evaluate_rule_term, chunk.thunks, chunk.values, 1)
1632
+ throw(3)
1633
+ end
1634
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1635
+ thunk = ThunkLeaf.new(:action_sequence_1)
1636
+ capt0 = thunk.capt0
1637
+ values = chunk.values
1638
+ value_refs = thunk.value_refs
1639
+ value = values[1]
1640
+ value_refs[1] = value
1641
+ capt0.range_start = chunk.pos
1642
+ capt0.range_end = @cur
1643
+ capt0.start_loc = chunk.pos_loc
1644
+ capt0.end_loc = @cur_loc
1645
+ chunk.thunks.push(thunk)
1646
+ end
1647
+ throw(1)
1648
+ end
1649
+ @cur = pos
1650
+ @cur_loc = p_loc
1651
+ chunk.thunks[n..-1] = []
1652
+ throw(0)
1653
+ end
1654
+ debug { warn "#{ " " * @level}MATCH sequence #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1655
+ return chunk
1656
+ ensure
1657
+ @level -= 1
1658
+ end
1659
+ debug { warn "#{ " " * @level}NOMATCH sequence #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1660
+ return nil
1661
+ end
1662
+
1663
+ def evaluate_rule_term
1664
+ chunk = ThunkChunk.new
1665
+ chunk.pos = @cur
1666
+ chunk.pos_loc = @cur_loc
1667
+ debug { warn "#{ " " * @level}EVAL term #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1668
+ @level += 1
1669
+ chunk.resize_captures(0)
1670
+ chunk.values = []
1671
+ catch(0) do
1672
+ catch(1) do |; pos, p_loc, n|
1673
+ pos = @cur
1674
+ p_loc = @cur_loc
1675
+ n = chunk.thunks.length
1676
+ catch(2) do
1677
+ if !apply_rule(:evaluate_rule_pred, chunk.thunks, chunk.values, 0)
1678
+ throw(2)
1679
+ end
1680
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1681
+ throw(2)
1682
+ end
1683
+ if (
1684
+ refill_buffer(1) < 1 ||
1685
+ @buffer[@cur] != "~"
1686
+ )
1687
+ throw(2)
1688
+ end
1689
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1690
+ @cur += 1
1691
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1692
+ throw(2)
1693
+ end
1694
+ if !apply_rule(:evaluate_rule_lang_code_block, chunk.thunks, chunk.values, 1)
1695
+ throw(2)
1696
+ end
1697
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1698
+ thunk = ThunkLeaf.new(:action_term_0)
1699
+ capt0 = thunk.capt0
1700
+ values = chunk.values
1701
+ value_refs = thunk.value_refs
1702
+ value = values[0]
1703
+ value_refs[0] = value
1704
+ value = values[1]
1705
+ value_refs[1] = value
1706
+ capt0.range_start = chunk.pos
1707
+ capt0.range_end = @cur
1708
+ capt0.start_loc = chunk.pos_loc
1709
+ capt0.end_loc = @cur_loc
1710
+ chunk.thunks.push(thunk)
1711
+ end
1712
+ throw(1)
1713
+ end
1714
+ @cur = pos
1715
+ @cur_loc = p_loc
1716
+ chunk.thunks[n..-1] = []
1717
+ catch(3) do
1718
+ if !apply_rule(:evaluate_rule_pred, chunk.thunks, chunk.values, 0)
1719
+ throw(3)
1720
+ end
1721
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1722
+ thunk = ThunkLeaf.new(:action_term_1)
1723
+ capt0 = thunk.capt0
1724
+ values = chunk.values
1725
+ value_refs = thunk.value_refs
1726
+ value = values[0]
1727
+ value_refs[0] = value
1728
+ capt0.range_start = chunk.pos
1729
+ capt0.range_end = @cur
1730
+ capt0.start_loc = chunk.pos_loc
1731
+ capt0.end_loc = @cur_loc
1732
+ chunk.thunks.push(thunk)
1733
+ end
1734
+ throw(1)
1735
+ end
1736
+ @cur = pos
1737
+ @cur_loc = p_loc
1738
+ chunk.thunks[n..-1] = []
1739
+ throw(0)
1740
+ end
1741
+ debug { warn "#{ " " * @level}MATCH term #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1742
+ return chunk
1743
+ ensure
1744
+ @level -= 1
1745
+ end
1746
+ debug { warn "#{ " " * @level}NOMATCH term #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1747
+ return nil
1748
+ end
1749
+
1750
+ def evaluate_rule_pred
1751
+ chunk = ThunkChunk.new
1752
+ chunk.pos = @cur
1753
+ chunk.pos_loc = @cur_loc
1754
+ debug { warn "#{ " " * @level}EVAL pred #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1755
+ @level += 1
1756
+ chunk.resize_captures(0)
1757
+ chunk.values = []
1758
+ catch(0) do
1759
+ catch(1) do |; pos, p_loc, n|
1760
+ pos = @cur
1761
+ p_loc = @cur_loc
1762
+ n = chunk.thunks.length
1763
+ catch(2) do
1764
+ if (
1765
+ refill_buffer(1) < 1 ||
1766
+ @buffer[@cur] != "&"
1767
+ )
1768
+ throw(2)
1769
+ end
1770
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1771
+ @cur += 1
1772
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1773
+ throw(2)
1774
+ end
1775
+ if !apply_rule(:evaluate_rule_quantity, chunk.thunks, chunk.values, 0)
1776
+ throw(2)
1777
+ end
1778
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1779
+ thunk = ThunkLeaf.new(:action_pred_0)
1780
+ capt0 = thunk.capt0
1781
+ values = chunk.values
1782
+ value_refs = thunk.value_refs
1783
+ value = values[0]
1784
+ value_refs[0] = value
1785
+ capt0.range_start = chunk.pos
1786
+ capt0.range_end = @cur
1787
+ capt0.start_loc = chunk.pos_loc
1788
+ capt0.end_loc = @cur_loc
1789
+ chunk.thunks.push(thunk)
1790
+ end
1791
+ throw(1)
1792
+ end
1793
+ @cur = pos
1794
+ @cur_loc = p_loc
1795
+ chunk.thunks[n..-1] = []
1796
+ catch(3) do
1797
+ if (
1798
+ refill_buffer(1) < 1 ||
1799
+ @buffer[@cur] != "!"
1800
+ )
1801
+ throw(3)
1802
+ end
1803
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1804
+ @cur += 1
1805
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1806
+ throw(3)
1807
+ end
1808
+ if !apply_rule(:evaluate_rule_quantity, chunk.thunks, chunk.values, 0)
1809
+ throw(3)
1810
+ end
1811
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1812
+ thunk = ThunkLeaf.new(:action_pred_1)
1813
+ capt0 = thunk.capt0
1814
+ values = chunk.values
1815
+ value_refs = thunk.value_refs
1816
+ value = values[0]
1817
+ value_refs[0] = value
1818
+ capt0.range_start = chunk.pos
1819
+ capt0.range_end = @cur
1820
+ capt0.start_loc = chunk.pos_loc
1821
+ capt0.end_loc = @cur_loc
1822
+ chunk.thunks.push(thunk)
1823
+ end
1824
+ throw(1)
1825
+ end
1826
+ @cur = pos
1827
+ @cur_loc = p_loc
1828
+ chunk.thunks[n..-1] = []
1829
+ catch(4) do
1830
+ if !apply_rule(:evaluate_rule_quantity, chunk.thunks, chunk.values, 0)
1831
+ throw(4)
1832
+ end
1833
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1834
+ thunk = ThunkLeaf.new(:action_pred_2)
1835
+ capt0 = thunk.capt0
1836
+ values = chunk.values
1837
+ value_refs = thunk.value_refs
1838
+ value = values[0]
1839
+ value_refs[0] = value
1840
+ capt0.range_start = chunk.pos
1841
+ capt0.range_end = @cur
1842
+ capt0.start_loc = chunk.pos_loc
1843
+ capt0.end_loc = @cur_loc
1844
+ chunk.thunks.push(thunk)
1845
+ end
1846
+ throw(1)
1847
+ end
1848
+ @cur = pos
1849
+ @cur_loc = p_loc
1850
+ chunk.thunks[n..-1] = []
1851
+ throw(0)
1852
+ end
1853
+ debug { warn "#{ " " * @level}MATCH pred #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1854
+ return chunk
1855
+ ensure
1856
+ @level -= 1
1857
+ end
1858
+ debug { warn "#{ " " * @level}NOMATCH pred #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1859
+ return nil
1860
+ end
1861
+
1862
+ def evaluate_rule_quantity
1863
+ chunk = ThunkChunk.new
1864
+ chunk.pos = @cur
1865
+ chunk.pos_loc = @cur_loc
1866
+ debug { warn "#{ " " * @level}EVAL quantity #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1867
+ @level += 1
1868
+ chunk.resize_captures(0)
1869
+ chunk.values = []
1870
+ catch(0) do
1871
+ catch(1) do |; pos, p_loc, n|
1872
+ pos = @cur
1873
+ p_loc = @cur_loc
1874
+ n = chunk.thunks.length
1875
+ catch(2) do
1876
+ if !apply_rule(:evaluate_rule_primary, chunk.thunks, chunk.values, 0)
1877
+ throw(2)
1878
+ end
1879
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1880
+ throw(2)
1881
+ end
1882
+ if (
1883
+ refill_buffer(1) < 1 ||
1884
+ @buffer[@cur] != "*"
1885
+ )
1886
+ throw(2)
1887
+ end
1888
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1889
+ @cur += 1
1890
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1891
+ thunk = ThunkLeaf.new(:action_quantity_0)
1892
+ capt0 = thunk.capt0
1893
+ values = chunk.values
1894
+ value_refs = thunk.value_refs
1895
+ value = values[0]
1896
+ value_refs[0] = value
1897
+ capt0.range_start = chunk.pos
1898
+ capt0.range_end = @cur
1899
+ capt0.start_loc = chunk.pos_loc
1900
+ capt0.end_loc = @cur_loc
1901
+ chunk.thunks.push(thunk)
1902
+ end
1903
+ throw(1)
1904
+ end
1905
+ @cur = pos
1906
+ @cur_loc = p_loc
1907
+ chunk.thunks[n..-1] = []
1908
+ catch(3) do
1909
+ if !apply_rule(:evaluate_rule_primary, chunk.thunks, chunk.values, 0)
1910
+ throw(3)
1911
+ end
1912
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1913
+ throw(3)
1914
+ end
1915
+ if (
1916
+ refill_buffer(1) < 1 ||
1917
+ @buffer[@cur] != "+"
1918
+ )
1919
+ throw(3)
1920
+ end
1921
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1922
+ @cur += 1
1923
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1924
+ thunk = ThunkLeaf.new(:action_quantity_1)
1925
+ capt0 = thunk.capt0
1926
+ values = chunk.values
1927
+ value_refs = thunk.value_refs
1928
+ value = values[0]
1929
+ value_refs[0] = value
1930
+ capt0.range_start = chunk.pos
1931
+ capt0.range_end = @cur
1932
+ capt0.start_loc = chunk.pos_loc
1933
+ capt0.end_loc = @cur_loc
1934
+ chunk.thunks.push(thunk)
1935
+ end
1936
+ throw(1)
1937
+ end
1938
+ @cur = pos
1939
+ @cur_loc = p_loc
1940
+ chunk.thunks[n..-1] = []
1941
+ catch(4) do
1942
+ if !apply_rule(:evaluate_rule_primary, chunk.thunks, chunk.values, 0)
1943
+ throw(4)
1944
+ end
1945
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
1946
+ throw(4)
1947
+ end
1948
+ if (
1949
+ refill_buffer(1) < 1 ||
1950
+ @buffer[@cur] != "?"
1951
+ )
1952
+ throw(4)
1953
+ end
1954
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
1955
+ @cur += 1
1956
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1957
+ thunk = ThunkLeaf.new(:action_quantity_2)
1958
+ capt0 = thunk.capt0
1959
+ values = chunk.values
1960
+ value_refs = thunk.value_refs
1961
+ value = values[0]
1962
+ value_refs[0] = value
1963
+ capt0.range_start = chunk.pos
1964
+ capt0.range_end = @cur
1965
+ capt0.start_loc = chunk.pos_loc
1966
+ capt0.end_loc = @cur_loc
1967
+ chunk.thunks.push(thunk)
1968
+ end
1969
+ throw(1)
1970
+ end
1971
+ @cur = pos
1972
+ @cur_loc = p_loc
1973
+ chunk.thunks[n..-1] = []
1974
+ catch(5) do
1975
+ if !apply_rule(:evaluate_rule_primary, chunk.thunks, chunk.values, 0)
1976
+ throw(5)
1977
+ end
1978
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
1979
+ thunk = ThunkLeaf.new(:action_quantity_3)
1980
+ capt0 = thunk.capt0
1981
+ values = chunk.values
1982
+ value_refs = thunk.value_refs
1983
+ value = values[0]
1984
+ value_refs[0] = value
1985
+ capt0.range_start = chunk.pos
1986
+ capt0.range_end = @cur
1987
+ capt0.start_loc = chunk.pos_loc
1988
+ capt0.end_loc = @cur_loc
1989
+ chunk.thunks.push(thunk)
1990
+ end
1991
+ throw(1)
1992
+ end
1993
+ @cur = pos
1994
+ @cur_loc = p_loc
1995
+ chunk.thunks[n..-1] = []
1996
+ throw(0)
1997
+ end
1998
+ debug { warn "#{ " " * @level}MATCH quantity #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1999
+ return chunk
2000
+ ensure
2001
+ @level -= 1
2002
+ end
2003
+ debug { warn "#{ " " * @level}NOMATCH quantity #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2004
+ return nil
2005
+ end
2006
+
2007
+ def evaluate_rule_primary
2008
+ chunk = ThunkChunk.new
2009
+ chunk.pos = @cur
2010
+ chunk.pos_loc = @cur_loc
2011
+ debug { warn "#{ " " * @level}EVAL primary #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2012
+ @level += 1
2013
+ chunk.resize_captures(1)
2014
+ chunk.values = []
2015
+ catch(0) do
2016
+ catch(1) do |; pos, p_loc, n|
2017
+ pos = @cur
2018
+ p_loc = @cur_loc
2019
+ n = chunk.thunks.length
2020
+ catch(2) do
2021
+ if !apply_rule(:evaluate_rule_identifier, chunk.thunks, chunk.values, 0)
2022
+ throw(2)
2023
+ end
2024
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
2025
+ throw(2)
2026
+ end
2027
+ if (
2028
+ refill_buffer(1) < 1 ||
2029
+ @buffer[@cur] != ":"
2030
+ )
2031
+ throw(2)
2032
+ end
2033
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2034
+ @cur += 1
2035
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
2036
+ throw(2)
2037
+ end
2038
+ if !apply_rule(:evaluate_rule_identifier, chunk.thunks, chunk.values, 1)
2039
+ throw(2)
2040
+ end
2041
+ 1.times do |;pos, p_loc|
2042
+ pos = @cur
2043
+ p_loc = @cur_loc
2044
+ catch(3) do
2045
+ 1.times do |;p0, p0_loc, n0, i|
2046
+ i = -1
2047
+ loop do |;pos, p_loc, n, stat|
2048
+ i += 1
2049
+ pos = @cur
2050
+ p_loc = @cur_loc
2051
+ n = chunk.thunks.length
2052
+ stat = nil
2053
+ catch(4) do
2054
+ 1.times do |;u, n|
2055
+ if refill_buffer(1) < 1
2056
+ throw(4)
2057
+ end
2058
+ u = @buffer[@cur]
2059
+ if (!(
2060
+ u == " " ||
2061
+ u == "\t" ||
2062
+ u == "\v" ||
2063
+ u == "\f" ||
2064
+ u == "\r" ||
2065
+ u == "\n"
2066
+ ))
2067
+ throw(4)
2068
+ end
2069
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2070
+ @cur += 1
2071
+ end
2072
+ if @cur == pos
2073
+ stat = :break
2074
+ else
2075
+ stat = :continue
2076
+ end
2077
+ end
2078
+ if stat == :break
2079
+ break
2080
+ elsif stat != :continue
2081
+ @cur = pos
2082
+ @cur_loc = p_loc
2083
+ chunk.thunks[n..-1] = []
2084
+ break
2085
+ end
2086
+ end
2087
+ end
2088
+ if (
2089
+ refill_buffer(2) < 2 ||
2090
+ @buffer[@cur, 2] != "<-"
2091
+ )
2092
+ throw(3)
2093
+ end
2094
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
2095
+ @cur += 2
2096
+ @cur = pos
2097
+ @cur_loc = p_loc
2098
+ throw(2)
2099
+ end
2100
+ @cur = pos
2101
+ @cur_loc = p_loc
2102
+ end
2103
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2104
+ thunk = ThunkLeaf.new(:action_primary_0)
2105
+ capt0 = thunk.capt0
2106
+ values = chunk.values
2107
+ value_refs = thunk.value_refs
2108
+ value = values[0]
2109
+ value_refs[0] = value
2110
+ value = values[1]
2111
+ value_refs[1] = value
2112
+ capt0.range_start = chunk.pos
2113
+ capt0.range_end = @cur
2114
+ capt0.start_loc = chunk.pos_loc
2115
+ capt0.end_loc = @cur_loc
2116
+ chunk.thunks.push(thunk)
2117
+ end
2118
+ throw(1)
2119
+ end
2120
+ @cur = pos
2121
+ @cur_loc = p_loc
2122
+ chunk.thunks[n..-1] = []
2123
+ catch(5) do
2124
+ if !apply_rule(:evaluate_rule_identifier, chunk.thunks, chunk.values, 1)
2125
+ throw(5)
2126
+ end
2127
+ 1.times do |;pos, p_loc|
2128
+ pos = @cur
2129
+ p_loc = @cur_loc
2130
+ catch(6) do
2131
+ 1.times do |;p0, p0_loc, n0, i|
2132
+ i = -1
2133
+ loop do |;pos, p_loc, n, stat|
2134
+ i += 1
2135
+ pos = @cur
2136
+ p_loc = @cur_loc
2137
+ n = chunk.thunks.length
2138
+ stat = nil
2139
+ catch(7) do
2140
+ 1.times do |;u, n|
2141
+ if refill_buffer(1) < 1
2142
+ throw(7)
2143
+ end
2144
+ u = @buffer[@cur]
2145
+ if (!(
2146
+ u == " " ||
2147
+ u == "\t" ||
2148
+ u == "\v" ||
2149
+ u == "\f" ||
2150
+ u == "\r" ||
2151
+ u == "\n"
2152
+ ))
2153
+ throw(7)
2154
+ end
2155
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2156
+ @cur += 1
2157
+ end
2158
+ if @cur == pos
2159
+ stat = :break
2160
+ else
2161
+ stat = :continue
2162
+ end
2163
+ end
2164
+ if stat == :break
2165
+ break
2166
+ elsif stat != :continue
2167
+ @cur = pos
2168
+ @cur_loc = p_loc
2169
+ chunk.thunks[n..-1] = []
2170
+ break
2171
+ end
2172
+ end
2173
+ end
2174
+ if (
2175
+ refill_buffer(2) < 2 ||
2176
+ @buffer[@cur, 2] != "<-"
2177
+ )
2178
+ throw(6)
2179
+ end
2180
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
2181
+ @cur += 2
2182
+ @cur = pos
2183
+ @cur_loc = p_loc
2184
+ throw(5)
2185
+ end
2186
+ @cur = pos
2187
+ @cur_loc = p_loc
2188
+ end
2189
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2190
+ thunk = ThunkLeaf.new(:action_primary_1)
2191
+ capt0 = thunk.capt0
2192
+ values = chunk.values
2193
+ value_refs = thunk.value_refs
2194
+ value = values[1]
2195
+ value_refs[1] = value
2196
+ capt0.range_start = chunk.pos
2197
+ capt0.range_end = @cur
2198
+ capt0.start_loc = chunk.pos_loc
2199
+ capt0.end_loc = @cur_loc
2200
+ chunk.thunks.push(thunk)
2201
+ end
2202
+ throw(1)
2203
+ end
2204
+ @cur = pos
2205
+ @cur_loc = p_loc
2206
+ chunk.thunks[n..-1] = []
2207
+ catch(8) do
2208
+ if (
2209
+ refill_buffer(1) < 1 ||
2210
+ @buffer[@cur] != "("
2211
+ )
2212
+ throw(8)
2213
+ end
2214
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2215
+ @cur += 1
2216
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
2217
+ throw(8)
2218
+ end
2219
+ if !apply_rule(:evaluate_rule_expression, chunk.thunks, chunk.values, 2)
2220
+ throw(8)
2221
+ end
2222
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
2223
+ throw(8)
2224
+ end
2225
+ if (
2226
+ refill_buffer(1) < 1 ||
2227
+ @buffer[@cur] != ")"
2228
+ )
2229
+ throw(8)
2230
+ end
2231
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2232
+ @cur += 1
2233
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2234
+ thunk = ThunkLeaf.new(:action_primary_2)
2235
+ capt0 = thunk.capt0
2236
+ values = chunk.values
2237
+ value_refs = thunk.value_refs
2238
+ value = values[2]
2239
+ value_refs[2] = value
2240
+ capt0.range_start = chunk.pos
2241
+ capt0.range_end = @cur
2242
+ capt0.start_loc = chunk.pos_loc
2243
+ capt0.end_loc = @cur_loc
2244
+ chunk.thunks.push(thunk)
2245
+ end
2246
+ throw(1)
2247
+ end
2248
+ @cur = pos
2249
+ @cur_loc = p_loc
2250
+ chunk.thunks[n..-1] = []
2251
+ catch(9) do
2252
+ if (
2253
+ refill_buffer(1) < 1 ||
2254
+ @buffer[@cur] != "<"
2255
+ )
2256
+ throw(9)
2257
+ end
2258
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2259
+ @cur += 1
2260
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
2261
+ throw(9)
2262
+ end
2263
+ if !apply_rule(:evaluate_rule_expression, chunk.thunks, chunk.values, 2)
2264
+ throw(9)
2265
+ end
2266
+ if !apply_rule(:evaluate_rule_opt_spaces_or_comments, chunk.thunks, nil, 0)
2267
+ throw(9)
2268
+ end
2269
+ if (
2270
+ refill_buffer(1) < 1 ||
2271
+ @buffer[@cur] != ">"
2272
+ )
2273
+ throw(9)
2274
+ end
2275
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2276
+ @cur += 1
2277
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2278
+ thunk = ThunkLeaf.new(:action_primary_3)
2279
+ capt0 = thunk.capt0
2280
+ values = chunk.values
2281
+ value_refs = thunk.value_refs
2282
+ value = values[2]
2283
+ value_refs[2] = value
2284
+ capt0.range_start = chunk.pos
2285
+ capt0.range_end = @cur
2286
+ capt0.start_loc = chunk.pos_loc
2287
+ capt0.end_loc = @cur_loc
2288
+ chunk.thunks.push(thunk)
2289
+ end
2290
+ throw(1)
2291
+ end
2292
+ @cur = pos
2293
+ @cur_loc = p_loc
2294
+ chunk.thunks[n..-1] = []
2295
+ catch(10) do
2296
+ if (
2297
+ refill_buffer(1) < 1 ||
2298
+ @buffer[@cur] != "$"
2299
+ )
2300
+ throw(10)
2301
+ end
2302
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2303
+ @cur += 1
2304
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2305
+ pos = @cur
2306
+ p_loc = @cur_loc
2307
+ 1.times do |;u, n|
2308
+ if refill_buffer(1) < 1
2309
+ throw(10)
2310
+ end
2311
+ u = @buffer[@cur]
2312
+ if (!(
2313
+ (u >= "1" && u <= "9")
2314
+ ))
2315
+ throw(10)
2316
+ end
2317
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2318
+ @cur += 1
2319
+ end
2320
+ 1.times do |;p0, p0_loc, n0, i|
2321
+ i = -1
2322
+ loop do |;pos, p_loc, n, stat|
2323
+ i += 1
2324
+ pos = @cur
2325
+ p_loc = @cur_loc
2326
+ n = chunk.thunks.length
2327
+ stat = nil
2328
+ catch(11) do
2329
+ 1.times do |;u, n|
2330
+ if refill_buffer(1) < 1
2331
+ throw(11)
2332
+ end
2333
+ u = @buffer[@cur]
2334
+ if (!(
2335
+ (u >= "0" && u <= "9")
2336
+ ))
2337
+ throw(11)
2338
+ end
2339
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2340
+ @cur += 1
2341
+ end
2342
+ if @cur == pos
2343
+ stat = :break
2344
+ else
2345
+ stat = :continue
2346
+ end
2347
+ end
2348
+ if stat == :break
2349
+ break
2350
+ elsif stat != :continue
2351
+ @cur = pos
2352
+ @cur_loc = p_loc
2353
+ chunk.thunks[n..-1] = []
2354
+ break
2355
+ end
2356
+ end
2357
+ end
2358
+ q = @cur
2359
+ capt = chunk.capts[0]
2360
+ capt.range_start = pos
2361
+ capt.range_end = q
2362
+ q_loc = @cur_loc
2363
+ capt.start_loc = p_loc
2364
+ capt.end_loc = q_loc
2365
+ end
2366
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2367
+ thunk = ThunkLeaf.new(:action_primary_4)
2368
+ capt0 = thunk.capt0
2369
+ capt = chunk.capts[0]
2370
+ thunk.capts[0] = capt
2371
+ capt0.range_start = chunk.pos
2372
+ capt0.range_end = @cur
2373
+ capt0.start_loc = chunk.pos_loc
2374
+ capt0.end_loc = @cur_loc
2375
+ chunk.thunks.push(thunk)
2376
+ end
2377
+ throw(1)
2378
+ end
2379
+ @cur = pos
2380
+ @cur_loc = p_loc
2381
+ chunk.thunks[n..-1] = []
2382
+ catch(12) do
2383
+ if (
2384
+ refill_buffer(1) < 1 ||
2385
+ @buffer[@cur] != "."
2386
+ )
2387
+ throw(12)
2388
+ end
2389
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2390
+ @cur += 1
2391
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2392
+ thunk = ThunkLeaf.new(:action_primary_5)
2393
+ capt0 = thunk.capt0
2394
+ capt0.range_start = chunk.pos
2395
+ capt0.range_end = @cur
2396
+ capt0.start_loc = chunk.pos_loc
2397
+ capt0.end_loc = @cur_loc
2398
+ chunk.thunks.push(thunk)
2399
+ end
2400
+ throw(1)
2401
+ end
2402
+ @cur = pos
2403
+ @cur_loc = p_loc
2404
+ chunk.thunks[n..-1] = []
2405
+ catch(13) do
2406
+ if !apply_rule(:evaluate_rule_character_class, chunk.thunks, chunk.values, 3)
2407
+ throw(13)
2408
+ end
2409
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2410
+ thunk = ThunkLeaf.new(:action_primary_6)
2411
+ capt0 = thunk.capt0
2412
+ values = chunk.values
2413
+ value_refs = thunk.value_refs
2414
+ value = values[3]
2415
+ value_refs[3] = value
2416
+ capt0.range_start = chunk.pos
2417
+ capt0.range_end = @cur
2418
+ capt0.start_loc = chunk.pos_loc
2419
+ capt0.end_loc = @cur_loc
2420
+ chunk.thunks.push(thunk)
2421
+ end
2422
+ throw(1)
2423
+ end
2424
+ @cur = pos
2425
+ @cur_loc = p_loc
2426
+ chunk.thunks[n..-1] = []
2427
+ catch(14) do
2428
+ if !apply_rule(:evaluate_rule_quotation_single, chunk.thunks, chunk.values, 3)
2429
+ throw(14)
2430
+ end
2431
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2432
+ thunk = ThunkLeaf.new(:action_primary_7)
2433
+ capt0 = thunk.capt0
2434
+ values = chunk.values
2435
+ value_refs = thunk.value_refs
2436
+ value = values[3]
2437
+ value_refs[3] = value
2438
+ capt0.range_start = chunk.pos
2439
+ capt0.range_end = @cur
2440
+ capt0.start_loc = chunk.pos_loc
2441
+ capt0.end_loc = @cur_loc
2442
+ chunk.thunks.push(thunk)
2443
+ end
2444
+ throw(1)
2445
+ end
2446
+ @cur = pos
2447
+ @cur_loc = p_loc
2448
+ chunk.thunks[n..-1] = []
2449
+ catch(15) do
2450
+ if !apply_rule(:evaluate_rule_quotation_double, chunk.thunks, chunk.values, 3)
2451
+ throw(15)
2452
+ end
2453
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2454
+ thunk = ThunkLeaf.new(:action_primary_8)
2455
+ capt0 = thunk.capt0
2456
+ values = chunk.values
2457
+ value_refs = thunk.value_refs
2458
+ value = values[3]
2459
+ value_refs[3] = value
2460
+ capt0.range_start = chunk.pos
2461
+ capt0.range_end = @cur
2462
+ capt0.start_loc = chunk.pos_loc
2463
+ capt0.end_loc = @cur_loc
2464
+ chunk.thunks.push(thunk)
2465
+ end
2466
+ throw(1)
2467
+ end
2468
+ @cur = pos
2469
+ @cur_loc = p_loc
2470
+ chunk.thunks[n..-1] = []
2471
+ catch(16) do
2472
+ if !apply_rule(:evaluate_rule_lang_code_block, chunk.thunks, chunk.values, 4)
2473
+ throw(16)
2474
+ end
2475
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2476
+ thunk = ThunkLeaf.new(:action_primary_9)
2477
+ capt0 = thunk.capt0
2478
+ values = chunk.values
2479
+ value_refs = thunk.value_refs
2480
+ value = values[4]
2481
+ value_refs[4] = value
2482
+ capt0.range_start = chunk.pos
2483
+ capt0.range_end = @cur
2484
+ capt0.start_loc = chunk.pos_loc
2485
+ capt0.end_loc = @cur_loc
2486
+ chunk.thunks.push(thunk)
2487
+ end
2488
+ throw(1)
2489
+ end
2490
+ @cur = pos
2491
+ @cur_loc = p_loc
2492
+ chunk.thunks[n..-1] = []
2493
+ throw(0)
2494
+ end
2495
+ debug { warn "#{ " " * @level}MATCH primary #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2496
+ return chunk
2497
+ ensure
2498
+ @level -= 1
2499
+ end
2500
+ debug { warn "#{ " " * @level}NOMATCH primary #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2501
+ return nil
2502
+ end
2503
+
2504
+ def evaluate_rule_character_class
2505
+ chunk = ThunkChunk.new
2506
+ chunk.pos = @cur
2507
+ chunk.pos_loc = @cur_loc
2508
+ debug { warn "#{ " " * @level}EVAL character_class #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2509
+ @level += 1
2510
+ chunk.resize_captures(1)
2511
+ catch(0) do
2512
+ if (
2513
+ refill_buffer(1) < 1 ||
2514
+ @buffer[@cur] != "["
2515
+ )
2516
+ throw(0)
2517
+ end
2518
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2519
+ @cur += 1
2520
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2521
+ pos = @cur
2522
+ p_loc = @cur_loc
2523
+ 1.times do |;p0, p0_loc, n0, i|
2524
+ i = -1
2525
+ loop do |;pos, p_loc, n, stat|
2526
+ i += 1
2527
+ pos = @cur
2528
+ p_loc = @cur_loc
2529
+ n = chunk.thunks.length
2530
+ stat = nil
2531
+ catch(1) do
2532
+ catch(2) do |; pos, p_loc, n|
2533
+ pos = @cur
2534
+ p_loc = @cur_loc
2535
+ n = chunk.thunks.length
2536
+ catch(3) do
2537
+ 1.times do |;u, n|
2538
+ if refill_buffer(1) < 1
2539
+ throw(3)
2540
+ end
2541
+ u = @buffer[@cur]
2542
+ if (
2543
+ u == "\\" ||
2544
+ u == "[" ||
2545
+ u == "]"
2546
+ )
2547
+ throw(3)
2548
+ end
2549
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2550
+ @cur += 1
2551
+ end
2552
+ throw(2)
2553
+ end
2554
+ @cur = pos
2555
+ @cur_loc = p_loc
2556
+ chunk.thunks[n..-1] = []
2557
+ catch(4) do
2558
+ if (
2559
+ refill_buffer(2) < 2 ||
2560
+ @buffer[@cur, 2] != "\\["
2561
+ )
2562
+ throw(4)
2563
+ end
2564
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
2565
+ @cur += 2
2566
+ throw(2)
2567
+ end
2568
+ @cur = pos
2569
+ @cur_loc = p_loc
2570
+ chunk.thunks[n..-1] = []
2571
+ catch(5) do
2572
+ if (
2573
+ refill_buffer(2) < 2 ||
2574
+ @buffer[@cur, 2] != "\\]"
2575
+ )
2576
+ throw(5)
2577
+ end
2578
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
2579
+ @cur += 2
2580
+ throw(2)
2581
+ end
2582
+ @cur = pos
2583
+ @cur_loc = p_loc
2584
+ chunk.thunks[n..-1] = []
2585
+ catch(6) do
2586
+ if (
2587
+ refill_buffer(1) < 1 ||
2588
+ @buffer[@cur] != "\\"
2589
+ )
2590
+ throw(6)
2591
+ end
2592
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2593
+ @cur += 1
2594
+ throw(2)
2595
+ end
2596
+ @cur = pos
2597
+ @cur_loc = p_loc
2598
+ chunk.thunks[n..-1] = []
2599
+ throw(1)
2600
+ end
2601
+ if @cur == pos
2602
+ stat = :break
2603
+ else
2604
+ stat = :continue
2605
+ end
2606
+ end
2607
+ if stat == :break
2608
+ break
2609
+ elsif stat != :continue
2610
+ @cur = pos
2611
+ @cur_loc = p_loc
2612
+ chunk.thunks[n..-1] = []
2613
+ break
2614
+ end
2615
+ end
2616
+ end
2617
+ q = @cur
2618
+ capt = chunk.capts[0]
2619
+ capt.range_start = pos
2620
+ capt.range_end = q
2621
+ q_loc = @cur_loc
2622
+ capt.start_loc = p_loc
2623
+ capt.end_loc = q_loc
2624
+ end
2625
+ if (
2626
+ refill_buffer(1) < 1 ||
2627
+ @buffer[@cur] != "]"
2628
+ )
2629
+ throw(0)
2630
+ end
2631
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2632
+ @cur += 1
2633
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2634
+ thunk = ThunkLeaf.new(:action_character_class_0)
2635
+ capt0 = thunk.capt0
2636
+ capt = chunk.capts[0]
2637
+ thunk.capts[0] = capt
2638
+ capt0.range_start = chunk.pos
2639
+ capt0.range_end = @cur
2640
+ capt0.start_loc = chunk.pos_loc
2641
+ capt0.end_loc = @cur_loc
2642
+ chunk.thunks.push(thunk)
2643
+ end
2644
+ debug { warn "#{ " " * @level}MATCH character_class #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2645
+ return chunk
2646
+ ensure
2647
+ @level -= 1
2648
+ end
2649
+ debug { warn "#{ " " * @level}NOMATCH character_class #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2650
+ return nil
2651
+ end
2652
+
2653
+ def evaluate_rule_lang_code_block
2654
+ chunk = ThunkChunk.new
2655
+ chunk.pos = @cur
2656
+ chunk.pos_loc = @cur_loc
2657
+ debug { warn "#{ " " * @level}EVAL lang_code_block #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2658
+ @level += 1
2659
+ chunk.resize_captures(1)
2660
+ chunk.values = []
2661
+ catch(0) do
2662
+ catch(1) do |; pos, p_loc, n|
2663
+ pos = @cur
2664
+ p_loc = @cur_loc
2665
+ n = chunk.thunks.length
2666
+ catch(2) do
2667
+ if !apply_rule(:evaluate_rule_code_block, chunk.thunks, chunk.values, 0)
2668
+ throw(2)
2669
+ end
2670
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2671
+ thunk = ThunkLeaf.new(:action_lang_code_block_0)
2672
+ capt0 = thunk.capt0
2673
+ values = chunk.values
2674
+ value_refs = thunk.value_refs
2675
+ value = values[0]
2676
+ value_refs[0] = value
2677
+ capt0.range_start = chunk.pos
2678
+ capt0.range_end = @cur
2679
+ capt0.start_loc = chunk.pos_loc
2680
+ capt0.end_loc = @cur_loc
2681
+ chunk.thunks.push(thunk)
2682
+ end
2683
+ throw(1)
2684
+ end
2685
+ @cur = pos
2686
+ @cur_loc = p_loc
2687
+ chunk.thunks[n..-1] = []
2688
+ catch(3) do
2689
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2690
+ pos = @cur
2691
+ p_loc = @cur_loc
2692
+ if !apply_rule(:evaluate_rule_identifier, chunk.thunks, nil, 0)
2693
+ throw(3)
2694
+ end
2695
+ q = @cur
2696
+ capt = chunk.capts[0]
2697
+ capt.range_start = pos
2698
+ capt.range_end = q
2699
+ q_loc = @cur_loc
2700
+ capt.start_loc = p_loc
2701
+ capt.end_loc = q_loc
2702
+ end
2703
+ if (
2704
+ refill_buffer(2) < 2 ||
2705
+ @buffer[@cur, 2] != "->"
2706
+ )
2707
+ throw(3)
2708
+ end
2709
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
2710
+ @cur += 2
2711
+ if !apply_rule(:evaluate_rule_code_block, chunk.thunks, chunk.values, 0)
2712
+ throw(3)
2713
+ end
2714
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2715
+ thunk = ThunkLeaf.new(:action_lang_code_block_1)
2716
+ capt0 = thunk.capt0
2717
+ values = chunk.values
2718
+ value_refs = thunk.value_refs
2719
+ value = values[0]
2720
+ value_refs[0] = value
2721
+ capt = chunk.capts[0]
2722
+ thunk.capts[0] = capt
2723
+ capt0.range_start = chunk.pos
2724
+ capt0.range_end = @cur
2725
+ capt0.start_loc = chunk.pos_loc
2726
+ capt0.end_loc = @cur_loc
2727
+ chunk.thunks.push(thunk)
2728
+ end
2729
+ throw(1)
2730
+ end
2731
+ @cur = pos
2732
+ @cur_loc = p_loc
2733
+ chunk.thunks[n..-1] = []
2734
+ throw(0)
2735
+ end
2736
+ debug { warn "#{ " " * @level}MATCH lang_code_block #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2737
+ return chunk
2738
+ ensure
2739
+ @level -= 1
2740
+ end
2741
+ debug { warn "#{ " " * @level}NOMATCH lang_code_block #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2742
+ return nil
2743
+ end
2744
+
2745
+ def evaluate_rule_code_block
2746
+ chunk = ThunkChunk.new
2747
+ chunk.pos = @cur
2748
+ chunk.pos_loc = @cur_loc
2749
+ debug { warn "#{ " " * @level}EVAL code_block #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2750
+ @level += 1
2751
+ chunk.resize_captures(0)
2752
+ chunk.values = []
2753
+ catch(0) do
2754
+ catch(1) do |; pos, p_loc, n|
2755
+ pos = @cur
2756
+ p_loc = @cur_loc
2757
+ n = chunk.thunks.length
2758
+ catch(2) do
2759
+ if (
2760
+ refill_buffer(1) < 1 ||
2761
+ @buffer[@cur] != "$"
2762
+ )
2763
+ throw(2)
2764
+ end
2765
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2766
+ @cur += 1
2767
+ if !apply_rule(:evaluate_rule_plain_code_block, chunk.thunks, chunk.values, 0)
2768
+ throw(2)
2769
+ end
2770
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2771
+ thunk = ThunkLeaf.new(:action_code_block_0)
2772
+ capt0 = thunk.capt0
2773
+ values = chunk.values
2774
+ value_refs = thunk.value_refs
2775
+ value = values[0]
2776
+ value_refs[0] = value
2777
+ capt0.range_start = chunk.pos
2778
+ capt0.range_end = @cur
2779
+ capt0.start_loc = chunk.pos_loc
2780
+ capt0.end_loc = @cur_loc
2781
+ chunk.thunks.push(thunk)
2782
+ end
2783
+ throw(1)
2784
+ end
2785
+ @cur = pos
2786
+ @cur_loc = p_loc
2787
+ chunk.thunks[n..-1] = []
2788
+ catch(3) do
2789
+ if !apply_rule(:evaluate_rule_plain_code_block, chunk.thunks, chunk.values, 0)
2790
+ throw(3)
2791
+ end
2792
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2793
+ thunk = ThunkLeaf.new(:action_code_block_1)
2794
+ capt0 = thunk.capt0
2795
+ values = chunk.values
2796
+ value_refs = thunk.value_refs
2797
+ value = values[0]
2798
+ value_refs[0] = value
2799
+ capt0.range_start = chunk.pos
2800
+ capt0.range_end = @cur
2801
+ capt0.start_loc = chunk.pos_loc
2802
+ capt0.end_loc = @cur_loc
2803
+ chunk.thunks.push(thunk)
2804
+ end
2805
+ throw(1)
2806
+ end
2807
+ @cur = pos
2808
+ @cur_loc = p_loc
2809
+ chunk.thunks[n..-1] = []
2810
+ throw(0)
2811
+ end
2812
+ debug { warn "#{ " " * @level}MATCH code_block #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2813
+ return chunk
2814
+ ensure
2815
+ @level -= 1
2816
+ end
2817
+ debug { warn "#{ " " * @level}NOMATCH code_block #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2818
+ return nil
2819
+ end
2820
+
2821
+ def evaluate_rule_plain_code_block
2822
+ chunk = ThunkChunk.new
2823
+ chunk.pos = @cur
2824
+ chunk.pos_loc = @cur_loc
2825
+ debug { warn "#{ " " * @level}EVAL plain_code_block #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2826
+ @level += 1
2827
+ chunk.resize_captures(1)
2828
+ catch(0) do
2829
+ if (
2830
+ refill_buffer(1) < 1 ||
2831
+ @buffer[@cur] != "{"
2832
+ )
2833
+ throw(0)
2834
+ end
2835
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2836
+ @cur += 1
2837
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2838
+ pos = @cur
2839
+ p_loc = @cur_loc
2840
+ 1.times do |;pos, p_loc, n|
2841
+ pos = @cur
2842
+ p_loc = @cur_loc
2843
+ n = chunk.thunks.length
2844
+ catch(2) do
2845
+ catch(1) do
2846
+ if !apply_rule(:evaluate_rule_codes, chunk.thunks, nil, 0)
2847
+ throw(1)
2848
+ end
2849
+ throw(2)
2850
+ end
2851
+ @cur_loc = p_loc
2852
+ @cur = pos
2853
+ chunk.thunks[n..-1] = []
2854
+ end
2855
+ end
2856
+ q = @cur
2857
+ capt = chunk.capts[0]
2858
+ capt.range_start = pos
2859
+ capt.range_end = q
2860
+ q_loc = @cur_loc
2861
+ capt.start_loc = p_loc
2862
+ capt.end_loc = q_loc
2863
+ end
2864
+ if (
2865
+ refill_buffer(1) < 1 ||
2866
+ @buffer[@cur] != "}"
2867
+ )
2868
+ throw(0)
2869
+ end
2870
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2871
+ @cur += 1
2872
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
2873
+ thunk = ThunkLeaf.new(:action_plain_code_block_0)
2874
+ capt0 = thunk.capt0
2875
+ capt = chunk.capts[0]
2876
+ thunk.capts[0] = capt
2877
+ capt0.range_start = chunk.pos
2878
+ capt0.range_end = @cur
2879
+ capt0.start_loc = chunk.pos_loc
2880
+ capt0.end_loc = @cur_loc
2881
+ chunk.thunks.push(thunk)
2882
+ end
2883
+ debug { warn "#{ " " * @level}MATCH plain_code_block #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2884
+ return chunk
2885
+ ensure
2886
+ @level -= 1
2887
+ end
2888
+ debug { warn "#{ " " * @level}NOMATCH plain_code_block #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2889
+ return nil
2890
+ end
2891
+
2892
+ def evaluate_rule_codes
2893
+ chunk = ThunkChunk.new
2894
+ chunk.pos = @cur
2895
+ chunk.pos_loc = @cur_loc
2896
+ debug { warn "#{ " " * @level}EVAL codes #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2897
+ @level += 1
2898
+ chunk.resize_captures(0)
2899
+ catch(0) do
2900
+ 1.times do |;p0, p0_loc, n0, i|
2901
+ p0 = @cur
2902
+ p0_loc = @cur_loc
2903
+ n0 = chunk.thunks.length
2904
+ i = -1
2905
+ loop do |;pos, p_loc, n, stat|
2906
+ i += 1
2907
+ pos = @cur
2908
+ p_loc = @cur_loc
2909
+ n = chunk.thunks.length
2910
+ stat = nil
2911
+ catch(1) do
2912
+ 1.times do |;p0, p0_loc, n0, i|
2913
+ i = -1
2914
+ loop do |;pos, p_loc, n, stat|
2915
+ i += 1
2916
+ pos = @cur
2917
+ p_loc = @cur_loc
2918
+ n = chunk.thunks.length
2919
+ stat = nil
2920
+ catch(2) do
2921
+ 1.times do |;u, n|
2922
+ if refill_buffer(1) < 1
2923
+ throw(2)
2924
+ end
2925
+ u = @buffer[@cur]
2926
+ if (!(
2927
+ u == " " ||
2928
+ u == "\t" ||
2929
+ u == "\v" ||
2930
+ u == "\f" ||
2931
+ u == "\r" ||
2932
+ u == "\n"
2933
+ ))
2934
+ throw(2)
2935
+ end
2936
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
2937
+ @cur += 1
2938
+ end
2939
+ if @cur == pos
2940
+ stat = :break
2941
+ else
2942
+ stat = :continue
2943
+ end
2944
+ end
2945
+ if stat == :break
2946
+ break
2947
+ elsif stat != :continue
2948
+ @cur = pos
2949
+ @cur_loc = p_loc
2950
+ chunk.thunks[n..-1] = []
2951
+ break
2952
+ end
2953
+ end
2954
+ end
2955
+ if !apply_rule(:evaluate_rule_code, chunk.thunks, nil, 0)
2956
+ throw(1)
2957
+ end
2958
+ if @cur == pos
2959
+ stat = :break
2960
+ else
2961
+ stat = :continue
2962
+ end
2963
+ end
2964
+ if stat == :break
2965
+ break
2966
+ elsif stat != :continue
2967
+ @cur = pos
2968
+ @cur_loc = p_loc
2969
+ chunk.thunks[n..-1] = []
2970
+ break
2971
+ end
2972
+ end
2973
+ if i < 1
2974
+ @cur = p0
2975
+ @cur_loc = p0_loc
2976
+ chunk.thunks[n0..-1] = []
2977
+ throw(0)
2978
+ end
2979
+ end
2980
+ 1.times do |;p0, p0_loc, n0, i|
2981
+ i = -1
2982
+ loop do |;pos, p_loc, n, stat|
2983
+ i += 1
2984
+ pos = @cur
2985
+ p_loc = @cur_loc
2986
+ n = chunk.thunks.length
2987
+ stat = nil
2988
+ catch(3) do
2989
+ 1.times do |;u, n|
2990
+ if refill_buffer(1) < 1
2991
+ throw(3)
2992
+ end
2993
+ u = @buffer[@cur]
2994
+ if (!(
2995
+ u == " " ||
2996
+ u == "\t" ||
2997
+ u == "\v" ||
2998
+ u == "\f" ||
2999
+ u == "\r" ||
3000
+ u == "\n"
3001
+ ))
3002
+ throw(3)
3003
+ end
3004
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3005
+ @cur += 1
3006
+ end
3007
+ if @cur == pos
3008
+ stat = :break
3009
+ else
3010
+ stat = :continue
3011
+ end
3012
+ end
3013
+ if stat == :break
3014
+ break
3015
+ elsif stat != :continue
3016
+ @cur = pos
3017
+ @cur_loc = p_loc
3018
+ chunk.thunks[n..-1] = []
3019
+ break
3020
+ end
3021
+ end
3022
+ end
3023
+ debug { warn "#{ " " * @level}MATCH codes #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3024
+ return chunk
3025
+ ensure
3026
+ @level -= 1
3027
+ end
3028
+ debug { warn "#{ " " * @level}NOMATCH codes #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3029
+ return nil
3030
+ end
3031
+
3032
+ def evaluate_rule_code
3033
+ chunk = ThunkChunk.new
3034
+ chunk.pos = @cur
3035
+ chunk.pos_loc = @cur_loc
3036
+ debug { warn "#{ " " * @level}EVAL code #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3037
+ @level += 1
3038
+ chunk.resize_captures(0)
3039
+ catch(0) do
3040
+ catch(1) do |; pos, p_loc, n|
3041
+ pos = @cur
3042
+ p_loc = @cur_loc
3043
+ n = chunk.thunks.length
3044
+ catch(2) do
3045
+ 1.times do |;p0, p0_loc, n0, i|
3046
+ p0 = @cur
3047
+ p0_loc = @cur_loc
3048
+ n0 = chunk.thunks.length
3049
+ i = -1
3050
+ loop do |;pos, p_loc, n, stat|
3051
+ i += 1
3052
+ pos = @cur
3053
+ p_loc = @cur_loc
3054
+ n = chunk.thunks.length
3055
+ stat = nil
3056
+ catch(3) do
3057
+ if !apply_rule(:evaluate_rule_codechar, chunk.thunks, nil, 0)
3058
+ throw(3)
3059
+ end
3060
+ if @cur == pos
3061
+ stat = :break
3062
+ else
3063
+ stat = :continue
3064
+ end
3065
+ end
3066
+ if stat == :break
3067
+ break
3068
+ elsif stat != :continue
3069
+ @cur = pos
3070
+ @cur_loc = p_loc
3071
+ chunk.thunks[n..-1] = []
3072
+ break
3073
+ end
3074
+ end
3075
+ if i < 1
3076
+ @cur = p0
3077
+ @cur_loc = p0_loc
3078
+ chunk.thunks[n0..-1] = []
3079
+ throw(2)
3080
+ end
3081
+ end
3082
+ throw(1)
3083
+ end
3084
+ @cur = pos
3085
+ @cur_loc = p_loc
3086
+ chunk.thunks[n..-1] = []
3087
+ catch(4) do
3088
+ if !apply_rule(:evaluate_rule_quotation_single, chunk.thunks, nil, 0)
3089
+ throw(4)
3090
+ end
3091
+ throw(1)
3092
+ end
3093
+ @cur = pos
3094
+ @cur_loc = p_loc
3095
+ chunk.thunks[n..-1] = []
3096
+ catch(5) do
3097
+ if !apply_rule(:evaluate_rule_quotation_double, chunk.thunks, nil, 0)
3098
+ throw(5)
3099
+ end
3100
+ throw(1)
3101
+ end
3102
+ @cur = pos
3103
+ @cur_loc = p_loc
3104
+ chunk.thunks[n..-1] = []
3105
+ catch(6) do
3106
+ if (
3107
+ refill_buffer(1) < 1 ||
3108
+ @buffer[@cur] != "{"
3109
+ )
3110
+ throw(6)
3111
+ end
3112
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3113
+ @cur += 1
3114
+ 1.times do |;p0, p0_loc, n0, i|
3115
+ i = -1
3116
+ loop do |;pos, p_loc, n, stat|
3117
+ i += 1
3118
+ pos = @cur
3119
+ p_loc = @cur_loc
3120
+ n = chunk.thunks.length
3121
+ stat = nil
3122
+ catch(7) do
3123
+ if !apply_rule(:evaluate_rule_code, chunk.thunks, nil, 0)
3124
+ throw(7)
3125
+ end
3126
+ if @cur == pos
3127
+ stat = :break
3128
+ else
3129
+ stat = :continue
3130
+ end
3131
+ end
3132
+ if stat == :break
3133
+ break
3134
+ elsif stat != :continue
3135
+ @cur = pos
3136
+ @cur_loc = p_loc
3137
+ chunk.thunks[n..-1] = []
3138
+ break
3139
+ end
3140
+ end
3141
+ end
3142
+ if (
3143
+ refill_buffer(1) < 1 ||
3144
+ @buffer[@cur] != "}"
3145
+ )
3146
+ throw(6)
3147
+ end
3148
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3149
+ @cur += 1
3150
+ throw(1)
3151
+ end
3152
+ @cur = pos
3153
+ @cur_loc = p_loc
3154
+ chunk.thunks[n..-1] = []
3155
+ throw(0)
3156
+ end
3157
+ debug { warn "#{ " " * @level}MATCH code #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3158
+ return chunk
3159
+ ensure
3160
+ @level -= 1
3161
+ end
3162
+ debug { warn "#{ " " * @level}NOMATCH code #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3163
+ return nil
3164
+ end
3165
+
3166
+ def evaluate_rule_codechar
3167
+ chunk = ThunkChunk.new
3168
+ chunk.pos = @cur
3169
+ chunk.pos_loc = @cur_loc
3170
+ debug { warn "#{ " " * @level}EVAL codechar #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3171
+ @level += 1
3172
+ chunk.resize_captures(0)
3173
+ catch(0) do
3174
+ catch(1) do |; pos, p_loc, n|
3175
+ pos = @cur
3176
+ p_loc = @cur_loc
3177
+ n = chunk.thunks.length
3178
+ catch(2) do
3179
+ 1.times do |;u, n|
3180
+ if refill_buffer(1) < 1
3181
+ throw(2)
3182
+ end
3183
+ u = @buffer[@cur]
3184
+ if (
3185
+ u == "{" ||
3186
+ u == "}" ||
3187
+ u == "\"" ||
3188
+ u == "'"
3189
+ )
3190
+ throw(2)
3191
+ end
3192
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3193
+ @cur += 1
3194
+ end
3195
+ throw(1)
3196
+ end
3197
+ @cur = pos
3198
+ @cur_loc = p_loc
3199
+ chunk.thunks[n..-1] = []
3200
+ catch(3) do
3201
+ if (
3202
+ refill_buffer(2) < 2 ||
3203
+ @buffer[@cur, 2] != "\\\""
3204
+ )
3205
+ throw(3)
3206
+ end
3207
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3208
+ @cur += 2
3209
+ throw(1)
3210
+ end
3211
+ @cur = pos
3212
+ @cur_loc = p_loc
3213
+ chunk.thunks[n..-1] = []
3214
+ catch(4) do
3215
+ if (
3216
+ refill_buffer(2) < 2 ||
3217
+ @buffer[@cur, 2] != "\\'"
3218
+ )
3219
+ throw(4)
3220
+ end
3221
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3222
+ @cur += 2
3223
+ throw(1)
3224
+ end
3225
+ @cur = pos
3226
+ @cur_loc = p_loc
3227
+ chunk.thunks[n..-1] = []
3228
+ catch(5) do
3229
+ if (
3230
+ refill_buffer(2) < 2 ||
3231
+ @buffer[@cur, 2] != "\\{"
3232
+ )
3233
+ throw(5)
3234
+ end
3235
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3236
+ @cur += 2
3237
+ throw(1)
3238
+ end
3239
+ @cur = pos
3240
+ @cur_loc = p_loc
3241
+ chunk.thunks[n..-1] = []
3242
+ catch(6) do
3243
+ if (
3244
+ refill_buffer(2) < 2 ||
3245
+ @buffer[@cur, 2] != "\\}"
3246
+ )
3247
+ throw(6)
3248
+ end
3249
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3250
+ @cur += 2
3251
+ throw(1)
3252
+ end
3253
+ @cur = pos
3254
+ @cur_loc = p_loc
3255
+ chunk.thunks[n..-1] = []
3256
+ throw(0)
3257
+ end
3258
+ debug { warn "#{ " " * @level}MATCH codechar #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3259
+ return chunk
3260
+ ensure
3261
+ @level -= 1
3262
+ end
3263
+ debug { warn "#{ " " * @level}NOMATCH codechar #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3264
+ return nil
3265
+ end
3266
+
3267
+ def evaluate_rule_quotation_single
3268
+ chunk = ThunkChunk.new
3269
+ chunk.pos = @cur
3270
+ chunk.pos_loc = @cur_loc
3271
+ debug { warn "#{ " " * @level}EVAL quotation_single #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3272
+ @level += 1
3273
+ chunk.resize_captures(1)
3274
+ catch(0) do
3275
+ if (
3276
+ refill_buffer(1) < 1 ||
3277
+ @buffer[@cur] != "\'"
3278
+ )
3279
+ throw(0)
3280
+ end
3281
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3282
+ @cur += 1
3283
+ 1.times do |;pos, q, capt, p_loc, q_loc|
3284
+ pos = @cur
3285
+ p_loc = @cur_loc
3286
+ 1.times do |;p0, p0_loc, n0, i|
3287
+ i = -1
3288
+ loop do |;pos, p_loc, n, stat|
3289
+ i += 1
3290
+ pos = @cur
3291
+ p_loc = @cur_loc
3292
+ n = chunk.thunks.length
3293
+ stat = nil
3294
+ catch(1) do
3295
+ catch(2) do |; pos, p_loc, n|
3296
+ pos = @cur
3297
+ p_loc = @cur_loc
3298
+ n = chunk.thunks.length
3299
+ catch(3) do
3300
+ 1.times do |;u, n|
3301
+ if refill_buffer(1) < 1
3302
+ throw(3)
3303
+ end
3304
+ u = @buffer[@cur]
3305
+ if (
3306
+ u == "\\" ||
3307
+ u == "'" ||
3308
+ u == "\n"
3309
+ )
3310
+ throw(3)
3311
+ end
3312
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3313
+ @cur += 1
3314
+ end
3315
+ throw(2)
3316
+ end
3317
+ @cur = pos
3318
+ @cur_loc = p_loc
3319
+ chunk.thunks[n..-1] = []
3320
+ catch(4) do
3321
+ if (
3322
+ refill_buffer(2) < 2 ||
3323
+ @buffer[@cur, 2] != "\\'"
3324
+ )
3325
+ throw(4)
3326
+ end
3327
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3328
+ @cur += 2
3329
+ throw(2)
3330
+ end
3331
+ @cur = pos
3332
+ @cur_loc = p_loc
3333
+ chunk.thunks[n..-1] = []
3334
+ catch(5) do
3335
+ if (
3336
+ refill_buffer(2) < 2 ||
3337
+ @buffer[@cur, 2] != "\\\n"
3338
+ )
3339
+ throw(5)
3340
+ end
3341
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3342
+ @cur += 2
3343
+ throw(2)
3344
+ end
3345
+ @cur = pos
3346
+ @cur_loc = p_loc
3347
+ chunk.thunks[n..-1] = []
3348
+ catch(6) do
3349
+ if (
3350
+ refill_buffer(1) < 1 ||
3351
+ @buffer[@cur] != "\\"
3352
+ )
3353
+ throw(6)
3354
+ end
3355
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3356
+ @cur += 1
3357
+ 1.times do |;u, n|
3358
+ if refill_buffer(1) < 1
3359
+ throw(6)
3360
+ end
3361
+ u = @buffer[@cur]
3362
+ if (
3363
+ u == "'" ||
3364
+ u == "\n"
3365
+ )
3366
+ throw(6)
3367
+ end
3368
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3369
+ @cur += 1
3370
+ end
3371
+ throw(2)
3372
+ end
3373
+ @cur = pos
3374
+ @cur_loc = p_loc
3375
+ chunk.thunks[n..-1] = []
3376
+ throw(1)
3377
+ end
3378
+ if @cur == pos
3379
+ stat = :break
3380
+ else
3381
+ stat = :continue
3382
+ end
3383
+ end
3384
+ if stat == :break
3385
+ break
3386
+ elsif stat != :continue
3387
+ @cur = pos
3388
+ @cur_loc = p_loc
3389
+ chunk.thunks[n..-1] = []
3390
+ break
3391
+ end
3392
+ end
3393
+ end
3394
+ q = @cur
3395
+ capt = chunk.capts[0]
3396
+ capt.range_start = pos
3397
+ capt.range_end = q
3398
+ q_loc = @cur_loc
3399
+ capt.start_loc = p_loc
3400
+ capt.end_loc = q_loc
3401
+ end
3402
+ if (
3403
+ refill_buffer(1) < 1 ||
3404
+ @buffer[@cur] != "\'"
3405
+ )
3406
+ throw(0)
3407
+ end
3408
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3409
+ @cur += 1
3410
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
3411
+ thunk = ThunkLeaf.new(:action_quotation_single_0)
3412
+ capt0 = thunk.capt0
3413
+ capt = chunk.capts[0]
3414
+ thunk.capts[0] = capt
3415
+ capt0.range_start = chunk.pos
3416
+ capt0.range_end = @cur
3417
+ capt0.start_loc = chunk.pos_loc
3418
+ capt0.end_loc = @cur_loc
3419
+ chunk.thunks.push(thunk)
3420
+ end
3421
+ debug { warn "#{ " " * @level}MATCH quotation_single #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3422
+ return chunk
3423
+ ensure
3424
+ @level -= 1
3425
+ end
3426
+ debug { warn "#{ " " * @level}NOMATCH quotation_single #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3427
+ return nil
3428
+ end
3429
+
3430
+ def evaluate_rule_quotation_double
3431
+ chunk = ThunkChunk.new
3432
+ chunk.pos = @cur
3433
+ chunk.pos_loc = @cur_loc
3434
+ debug { warn "#{ " " * @level}EVAL quotation_double #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3435
+ @level += 1
3436
+ chunk.resize_captures(1)
3437
+ catch(0) do
3438
+ if (
3439
+ refill_buffer(1) < 1 ||
3440
+ @buffer[@cur] != "\""
3441
+ )
3442
+ throw(0)
3443
+ end
3444
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3445
+ @cur += 1
3446
+ 1.times do |;pos, q, capt, p_loc, q_loc|
3447
+ pos = @cur
3448
+ p_loc = @cur_loc
3449
+ 1.times do |;p0, p0_loc, n0, i|
3450
+ i = -1
3451
+ loop do |;pos, p_loc, n, stat|
3452
+ i += 1
3453
+ pos = @cur
3454
+ p_loc = @cur_loc
3455
+ n = chunk.thunks.length
3456
+ stat = nil
3457
+ catch(1) do
3458
+ catch(2) do |; pos, p_loc, n|
3459
+ pos = @cur
3460
+ p_loc = @cur_loc
3461
+ n = chunk.thunks.length
3462
+ catch(3) do
3463
+ 1.times do |;u, n|
3464
+ if refill_buffer(1) < 1
3465
+ throw(3)
3466
+ end
3467
+ u = @buffer[@cur]
3468
+ if (
3469
+ u == "\\" ||
3470
+ u == "\"" ||
3471
+ u == "\n"
3472
+ )
3473
+ throw(3)
3474
+ end
3475
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3476
+ @cur += 1
3477
+ end
3478
+ throw(2)
3479
+ end
3480
+ @cur = pos
3481
+ @cur_loc = p_loc
3482
+ chunk.thunks[n..-1] = []
3483
+ catch(4) do
3484
+ if (
3485
+ refill_buffer(2) < 2 ||
3486
+ @buffer[@cur, 2] != "\\\""
3487
+ )
3488
+ throw(4)
3489
+ end
3490
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3491
+ @cur += 2
3492
+ throw(2)
3493
+ end
3494
+ @cur = pos
3495
+ @cur_loc = p_loc
3496
+ chunk.thunks[n..-1] = []
3497
+ catch(5) do
3498
+ if (
3499
+ refill_buffer(2) < 2 ||
3500
+ @buffer[@cur, 2] != "\\\n"
3501
+ )
3502
+ throw(5)
3503
+ end
3504
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3505
+ @cur += 2
3506
+ throw(2)
3507
+ end
3508
+ @cur = pos
3509
+ @cur_loc = p_loc
3510
+ chunk.thunks[n..-1] = []
3511
+ catch(6) do
3512
+ if (
3513
+ refill_buffer(1) < 1 ||
3514
+ @buffer[@cur] != "\\"
3515
+ )
3516
+ throw(6)
3517
+ end
3518
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3519
+ @cur += 1
3520
+ 1.times do |;u, n|
3521
+ if refill_buffer(1) < 1
3522
+ throw(6)
3523
+ end
3524
+ u = @buffer[@cur]
3525
+ if (
3526
+ u == "\"" ||
3527
+ u == "\n"
3528
+ )
3529
+ throw(6)
3530
+ end
3531
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3532
+ @cur += 1
3533
+ end
3534
+ throw(2)
3535
+ end
3536
+ @cur = pos
3537
+ @cur_loc = p_loc
3538
+ chunk.thunks[n..-1] = []
3539
+ throw(1)
3540
+ end
3541
+ if @cur == pos
3542
+ stat = :break
3543
+ else
3544
+ stat = :continue
3545
+ end
3546
+ end
3547
+ if stat == :break
3548
+ break
3549
+ elsif stat != :continue
3550
+ @cur = pos
3551
+ @cur_loc = p_loc
3552
+ chunk.thunks[n..-1] = []
3553
+ break
3554
+ end
3555
+ end
3556
+ end
3557
+ q = @cur
3558
+ capt = chunk.capts[0]
3559
+ capt.range_start = pos
3560
+ capt.range_end = q
3561
+ q_loc = @cur_loc
3562
+ capt.start_loc = p_loc
3563
+ capt.end_loc = q_loc
3564
+ end
3565
+ if (
3566
+ refill_buffer(1) < 1 ||
3567
+ @buffer[@cur] != "\""
3568
+ )
3569
+ throw(0)
3570
+ end
3571
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3572
+ @cur += 1
3573
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
3574
+ thunk = ThunkLeaf.new(:action_quotation_double_0)
3575
+ capt0 = thunk.capt0
3576
+ capt = chunk.capts[0]
3577
+ thunk.capts[0] = capt
3578
+ capt0.range_start = chunk.pos
3579
+ capt0.range_end = @cur
3580
+ capt0.start_loc = chunk.pos_loc
3581
+ capt0.end_loc = @cur_loc
3582
+ chunk.thunks.push(thunk)
3583
+ end
3584
+ debug { warn "#{ " " * @level}MATCH quotation_double #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3585
+ return chunk
3586
+ ensure
3587
+ @level -= 1
3588
+ end
3589
+ debug { warn "#{ " " * @level}NOMATCH quotation_double #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3590
+ return nil
3591
+ end
3592
+
3593
+ def evaluate_rule_identifier
3594
+ chunk = ThunkChunk.new
3595
+ chunk.pos = @cur
3596
+ chunk.pos_loc = @cur_loc
3597
+ debug { warn "#{ " " * @level}EVAL identifier #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3598
+ @level += 1
3599
+ chunk.resize_captures(0)
3600
+ catch(0) do
3601
+ 1.times do |;u, n|
3602
+ if refill_buffer(1) < 1
3603
+ throw(0)
3604
+ end
3605
+ u = @buffer[@cur]
3606
+ if (!(
3607
+ (u >= "a" && u <= "z") ||
3608
+ (u >= "A" && u <= "Z") ||
3609
+ u == "_"
3610
+ ))
3611
+ throw(0)
3612
+ end
3613
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3614
+ @cur += 1
3615
+ end
3616
+ 1.times do |;p0, p0_loc, n0, i|
3617
+ i = -1
3618
+ loop do |;pos, p_loc, n, stat|
3619
+ i += 1
3620
+ pos = @cur
3621
+ p_loc = @cur_loc
3622
+ n = chunk.thunks.length
3623
+ stat = nil
3624
+ catch(1) do
3625
+ 1.times do |;u, n|
3626
+ if refill_buffer(1) < 1
3627
+ throw(1)
3628
+ end
3629
+ u = @buffer[@cur]
3630
+ if (!(
3631
+ (u >= "a" && u <= "z") ||
3632
+ (u >= "A" && u <= "Z") ||
3633
+ u == "_" ||
3634
+ (u >= "0" && u <= "9")
3635
+ ))
3636
+ throw(1)
3637
+ end
3638
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3639
+ @cur += 1
3640
+ end
3641
+ if @cur == pos
3642
+ stat = :break
3643
+ else
3644
+ stat = :continue
3645
+ end
3646
+ end
3647
+ if stat == :break
3648
+ break
3649
+ elsif stat != :continue
3650
+ @cur = pos
3651
+ @cur_loc = p_loc
3652
+ chunk.thunks[n..-1] = []
3653
+ break
3654
+ end
3655
+ end
3656
+ end
3657
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
3658
+ thunk = ThunkLeaf.new(:action_identifier_0)
3659
+ capt0 = thunk.capt0
3660
+ capt0.range_start = chunk.pos
3661
+ capt0.range_end = @cur
3662
+ capt0.start_loc = chunk.pos_loc
3663
+ capt0.end_loc = @cur_loc
3664
+ chunk.thunks.push(thunk)
3665
+ end
3666
+ debug { warn "#{ " " * @level}MATCH identifier #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3667
+ return chunk
3668
+ ensure
3669
+ @level -= 1
3670
+ end
3671
+ debug { warn "#{ " " * @level}NOMATCH identifier #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3672
+ return nil
3673
+ end
3674
+
3675
+ def evaluate_rule_spaces
3676
+ chunk = ThunkChunk.new
3677
+ chunk.pos = @cur
3678
+ chunk.pos_loc = @cur_loc
3679
+ debug { warn "#{ " " * @level}EVAL spaces #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3680
+ @level += 1
3681
+ chunk.resize_captures(0)
3682
+ catch(0) do
3683
+ 1.times do |;p0, p0_loc, n0, i|
3684
+ p0 = @cur
3685
+ p0_loc = @cur_loc
3686
+ n0 = chunk.thunks.length
3687
+ i = -1
3688
+ loop do |;pos, p_loc, n, stat|
3689
+ i += 1
3690
+ pos = @cur
3691
+ p_loc = @cur_loc
3692
+ n = chunk.thunks.length
3693
+ stat = nil
3694
+ catch(1) do
3695
+ 1.times do |;u, n|
3696
+ if refill_buffer(1) < 1
3697
+ throw(1)
3698
+ end
3699
+ u = @buffer[@cur]
3700
+ if (!(
3701
+ u == " " ||
3702
+ u == "\t" ||
3703
+ u == "\v" ||
3704
+ u == "\f" ||
3705
+ u == "\r" ||
3706
+ u == "\n"
3707
+ ))
3708
+ throw(1)
3709
+ end
3710
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3711
+ @cur += 1
3712
+ end
3713
+ if @cur == pos
3714
+ stat = :break
3715
+ else
3716
+ stat = :continue
3717
+ end
3718
+ end
3719
+ if stat == :break
3720
+ break
3721
+ elsif stat != :continue
3722
+ @cur = pos
3723
+ @cur_loc = p_loc
3724
+ chunk.thunks[n..-1] = []
3725
+ break
3726
+ end
3727
+ end
3728
+ if i < 1
3729
+ @cur = p0
3730
+ @cur_loc = p0_loc
3731
+ chunk.thunks[n0..-1] = []
3732
+ throw(0)
3733
+ end
3734
+ end
3735
+ debug { warn "#{ " " * @level}MATCH spaces #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3736
+ return chunk
3737
+ ensure
3738
+ @level -= 1
3739
+ end
3740
+ debug { warn "#{ " " * @level}NOMATCH spaces #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3741
+ return nil
3742
+ end
3743
+
3744
+ def evaluate_rule_opt_spaces_or_comments
3745
+ chunk = ThunkChunk.new
3746
+ chunk.pos = @cur
3747
+ chunk.pos_loc = @cur_loc
3748
+ debug { warn "#{ " " * @level}EVAL opt_spaces_or_comments #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3749
+ @level += 1
3750
+ chunk.resize_captures(0)
3751
+ catch(0) do
3752
+ 1.times do |;p0, p0_loc, n0, i|
3753
+ i = -1
3754
+ loop do |;pos, p_loc, n, stat|
3755
+ i += 1
3756
+ pos = @cur
3757
+ p_loc = @cur_loc
3758
+ n = chunk.thunks.length
3759
+ stat = nil
3760
+ catch(1) do
3761
+ catch(2) do |; pos, p_loc, n|
3762
+ pos = @cur
3763
+ p_loc = @cur_loc
3764
+ n = chunk.thunks.length
3765
+ catch(3) do
3766
+ if !apply_rule(:evaluate_rule_comment, chunk.thunks, nil, 0)
3767
+ throw(3)
3768
+ end
3769
+ throw(2)
3770
+ end
3771
+ @cur = pos
3772
+ @cur_loc = p_loc
3773
+ chunk.thunks[n..-1] = []
3774
+ catch(4) do
3775
+ if !apply_rule(:evaluate_rule_spaces, chunk.thunks, nil, 0)
3776
+ throw(4)
3777
+ end
3778
+ throw(2)
3779
+ end
3780
+ @cur = pos
3781
+ @cur_loc = p_loc
3782
+ chunk.thunks[n..-1] = []
3783
+ throw(1)
3784
+ end
3785
+ if @cur == pos
3786
+ stat = :break
3787
+ else
3788
+ stat = :continue
3789
+ end
3790
+ end
3791
+ if stat == :break
3792
+ break
3793
+ elsif stat != :continue
3794
+ @cur = pos
3795
+ @cur_loc = p_loc
3796
+ chunk.thunks[n..-1] = []
3797
+ break
3798
+ end
3799
+ end
3800
+ end
3801
+ debug { warn "#{ " " * @level}MATCH opt_spaces_or_comments #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3802
+ return chunk
3803
+ ensure
3804
+ @level -= 1
3805
+ end
3806
+ end
3807
+
3808
+ def evaluate_rule_lf
3809
+ chunk = ThunkChunk.new
3810
+ chunk.pos = @cur
3811
+ chunk.pos_loc = @cur_loc
3812
+ debug { warn "#{ " " * @level}EVAL lf #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3813
+ @level += 1
3814
+ chunk.resize_captures(0)
3815
+ catch(0) do
3816
+ 1.times do |;pos, p_loc, n|
3817
+ pos = @cur
3818
+ p_loc = @cur_loc
3819
+ n = chunk.thunks.length
3820
+ catch(2) do
3821
+ catch(1) do
3822
+ if (
3823
+ refill_buffer(1) < 1 ||
3824
+ @buffer[@cur] != "\r"
3825
+ )
3826
+ throw(1)
3827
+ end
3828
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3829
+ @cur += 1
3830
+ throw(2)
3831
+ end
3832
+ @cur_loc = p_loc
3833
+ @cur = pos
3834
+ chunk.thunks[n..-1] = []
3835
+ end
3836
+ end
3837
+ if (
3838
+ refill_buffer(1) < 1 ||
3839
+ @buffer[@cur] != "\n"
3840
+ )
3841
+ throw(0)
3842
+ end
3843
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3844
+ @cur += 1
3845
+ debug { warn "#{ " " * @level}MATCH lf #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3846
+ return chunk
3847
+ ensure
3848
+ @level -= 1
3849
+ end
3850
+ debug { warn "#{ " " * @level}NOMATCH lf #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3851
+ return nil
3852
+ end
3853
+
3854
+ def evaluate_rule_footer
3855
+ chunk = ThunkChunk.new
3856
+ chunk.pos = @cur
3857
+ chunk.pos_loc = @cur_loc
3858
+ debug { warn "#{ " " * @level}EVAL footer #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
3859
+ @level += 1
3860
+ chunk.resize_captures(1)
3861
+ catch(0) do
3862
+ if (
3863
+ refill_buffer(2) < 2 ||
3864
+ @buffer[@cur, 2] != "%%"
3865
+ )
3866
+ throw(0)
3867
+ end
3868
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 2)
3869
+ @cur += 2
3870
+ if !apply_rule(:evaluate_rule_lf, chunk.thunks, nil, 0)
3871
+ throw(0)
3872
+ end
3873
+ 1.times do |;pos, q, capt, p_loc, q_loc|
3874
+ pos = @cur
3875
+ p_loc = @cur_loc
3876
+ 1.times do |;p0, p0_loc, n0, i|
3877
+ i = -1
3878
+ loop do |;pos, p_loc, n, stat|
3879
+ i += 1
3880
+ pos = @cur
3881
+ p_loc = @cur_loc
3882
+ n = chunk.thunks.length
3883
+ stat = nil
3884
+ catch(1) do
3885
+ 1.times do |;u, n|
3886
+ if refill_buffer(1) < 1
3887
+ throw(1)
3888
+ end
3889
+ u = @buffer[@cur]
3890
+ @cur_loc = @cur_loc.forward(@buffer, @cur, 1)
3891
+ @cur += 1
3892
+ end
3893
+ if @cur == pos
3894
+ stat = :break
3895
+ else
3896
+ stat = :continue
3897
+ end
3898
+ end
3899
+ if stat == :break
3900
+ break
3901
+ elsif stat != :continue
3902
+ @cur = pos
3903
+ @cur_loc = p_loc
3904
+ chunk.thunks[n..-1] = []
3905
+ break
3906
+ end
3907
+ end
3908
+ end
3909
+ q = @cur
3910
+ capt = chunk.capts[0]
3911
+ capt.range_start = pos
3912
+ capt.range_end = q
3913
+ q_loc = @cur_loc
3914
+ capt.start_loc = p_loc
3915
+ capt.end_loc = q_loc
3916
+ end
3917
+ 1.times do |;thunk, capt0, value, values, value_refs, capt|
3918
+ thunk = ThunkLeaf.new(:action_footer_0)
3919
+ capt0 = thunk.capt0
3920
+ capt = chunk.capts[0]
3921
+ thunk.capts[0] = capt
3922
+ capt0.range_start = chunk.pos
3923
+ capt0.range_end = @cur
3924
+ capt0.start_loc = chunk.pos_loc
3925
+ capt0.end_loc = @cur_loc
3926
+ chunk.thunks.push(thunk)
3927
+ end
3928
+ debug { warn "#{ " " * @level}MATCH footer #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3929
+ return chunk
3930
+ ensure
3931
+ @level -= 1
3932
+ end
3933
+ debug { warn "#{ " " * @level}NOMATCH footer #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
3934
+ return nil
3935
+ end
3936
+
3937
+
3938
+ def apply_rule(rule, thunks, values, index)
3939
+ pos = @pos + @cur
3940
+ p_loc = @pos_loc + @cur_loc
3941
+ b = true
3942
+ a = @lrtable.get_answer(pos, rule)
3943
+ h = @lrtable.get_head(pos)
3944
+ if h
3945
+ invol = h.invol
3946
+ if !a && rule != h.rule_name && !invol[rule]
3947
+ b = false
3948
+ c = nil
3949
+ else
3950
+ if h.eval.delete(rule)
3951
+ c = public_send(rule)
3952
+ b = false
3953
+ a = LrAnswer.new(:chunk, @pos + @cur, @pos_loc + @cur_loc)
3954
+ a.chunk = c
3955
+ @lrtable.hold_answer(pos, a)
3956
+ end
3957
+ end
3958
+ end
3959
+
3960
+ if b
3961
+ if a
3962
+ @cur = a.pos - @pos
3963
+ @cur_loc = a.pos_loc - @pos_loc
3964
+ type = a.type
3965
+ if type == :lr
3966
+ lr = a.lr
3967
+ head = lr.head
3968
+ if !head
3969
+ head = LrHead.new
3970
+ lr.head = head
3971
+ head.rule_name = rule
3972
+ @lrtable.hold_head(pos, head)
3973
+ end
3974
+ @lrstack.reverse_each do |lrentry|
3975
+ entry_head = lrentry.head
3976
+ lr = a.lr
3977
+ answer_head = lr.head
3978
+ if entry_head == answer_head
3979
+ break
3980
+ end
3981
+ lrentry.head = answer_head
3982
+ invol = answer_head.invol
3983
+ invol[lrentry.rule] = true
3984
+ end
3985
+ lr = a.lr
3986
+ c = lr.seed
3987
+ elsif type == :chunk
3988
+ c = a.chunk
3989
+ end
3990
+ else
3991
+ entry = LrEntry.new
3992
+ entry.rule = rule
3993
+ @lrstack.push(entry)
3994
+ a = LrAnswer.new(:lr, pos, p_loc)
3995
+ a.lr = entry
3996
+ @lrtable.set_answer(pos, rule, a)
3997
+ c = public_send(rule)
3998
+ @lrstack.pop
3999
+ a.pos = @pos + @cur
4000
+ a.pos_loc = @pos_loc + @cur_loc
4001
+ if !entry.head
4002
+ a.set_chunk(c)
4003
+ else
4004
+ lr = a.lr
4005
+ entry.seed = c
4006
+ h = lr.head
4007
+ if h.rule_name != rule
4008
+ c = lr.seed
4009
+ a = LrAnswer.new(:chunk, @pos + @cur, @pos_loc + @cur_loc)
4010
+ a.chunk = c
4011
+ @lrtable.hold_answer(pos, a)
4012
+ else
4013
+ seed = lr.seed
4014
+ a.set_chunk(seed)
4015
+ chunk = a.chunk
4016
+ if !chunk
4017
+ c = nil
4018
+ else
4019
+ @lrtable.set_head(pos, h)
4020
+ while true
4021
+ @cur = pos - @pos
4022
+ @cur_loc = p_loc - @pos_loc
4023
+ h.invol_to_eval
4024
+ c = public_send(rule)
4025
+ if !c || @pos + @cur <= a.pos
4026
+ break
4027
+ end
4028
+ a.set_chunk(c)
4029
+ a.pos = @pos + @cur
4030
+ a.pos_loc = @pos_loc + @cur_loc
4031
+ end
4032
+ @lrtable.set_head(pos, nil)
4033
+ @cur = a.pos - @pos
4034
+ @cur_loc = a.pos_loc - @pos_loc
4035
+ c = a.chunk
4036
+ end
4037
+ end
4038
+ end
4039
+ end
4040
+ end
4041
+
4042
+ if !c
4043
+ return false
4044
+ end
4045
+ t = ThunkNode.new(c.thunks, values, index)
4046
+ thunks << t
4047
+ return true
4048
+ end
4049
+
4050
+ def do_action(thunks, values, index)
4051
+ thunks.each do |thunk|
4052
+ case thunk.type
4053
+ when :leaf
4054
+ public_send(thunk.action, thunk, values, index)
4055
+ when :node
4056
+ do_action(thunk.thunks, thunk.values, thunk.index)
4057
+ end
4058
+ end
4059
+ end
4060
+
4061
+ class Location
4062
+ attr_reader :charnum, :linenum, :linepos
4063
+
4064
+ def initialize(charnum = 0, linenum = 0, linepos = 0)
4065
+ @charnum = charnum
4066
+ @linenum = linenum
4067
+ @linepos = linepos
4068
+ end
4069
+
4070
+ def +(other)
4071
+ Location.new(other.charnum, other.linenum)
4072
+ end
4073
+
4074
+ def -(other)
4075
+ Location.new(other.charnum, other.linenum)
4076
+ end
4077
+
4078
+ def forward(buffer, cur, n)
4079
+ Location.new(@charnum, @linenum).forward!(buffer, cur, n)
4080
+ end
4081
+
4082
+ def forward!(buffer, cur, n)
4083
+ buffer[cur, n].scan(/(.*)(\n)?/) do
4084
+ if Regexp.last_match[2]
4085
+ @linenum += 1
4086
+ @pos = 0
4087
+ else
4088
+ @charnum += Regexp.last_match[1].length
4089
+ end
4090
+ end
4091
+ self
4092
+ end
4093
+ end
4094
+
4095
+ class LrTable
4096
+ def initialize
4097
+ super
4098
+ @buf = []
4099
+ end
4100
+
4101
+ def shift(count)
4102
+ @buf[0, count] = []
4103
+ end
4104
+
4105
+ def resize(len)
4106
+ (@buf.length...len).each do |i|
4107
+ @buf << nil
4108
+ end
4109
+ end
4110
+
4111
+ def set_head(index, head)
4112
+ if index >= @buf.length
4113
+ resize(index + 1)
4114
+ end
4115
+ entry = @buf[index] ||= LrTableEntry.new
4116
+ entry.head = head
4117
+ end
4118
+
4119
+ def hold_head(index, head)
4120
+ if index >= @buf.length
4121
+ resize(index + 1)
4122
+ end
4123
+ entry = @buf[index] ||= LrTableEntry.new
4124
+ head.hold, entry.hold_h = entry.hold_h, head
4125
+ end
4126
+
4127
+ def set_answer(index, rule_name, answer)
4128
+ if index >= @buf.length
4129
+ resize(index + 1)
4130
+ end
4131
+ entry = @buf[index] ||= LrTableEntry.new
4132
+ entry.memos[rule_name] = answer
4133
+ end
4134
+
4135
+ def hold_answer(index, answer)
4136
+ if index >= @buf.length
4137
+ resize(index + 1)
4138
+ end
4139
+ entry = @buf[index] ||= LrTableEntry.new
4140
+ answer.hold, entry.hold_a = entry.hold_a, answer
4141
+ end
4142
+
4143
+ def get_head(index)
4144
+ @buf[index]&.head
4145
+ end
4146
+
4147
+ def get_answer(index, rule_name)
4148
+ if index >= @buf.length
4149
+ return nil
4150
+ end
4151
+ entry = @buf[index]
4152
+ if !entry
4153
+ return nil
4154
+ end
4155
+ memos = entry.memos
4156
+ memos[rule_name]
4157
+ end
4158
+ end
4159
+
4160
+ class LrTableEntry
4161
+ attr_accessor :head, :hold_a, :hold_h, :memos
4162
+
4163
+ def initialize
4164
+ @memos = {}
4165
+ end
4166
+ end
4167
+
4168
+ class LrHead
4169
+ attr_accessor :hold, :rule_name, :invol, :eval
4170
+
4171
+ def initialize
4172
+ @invol = {}
4173
+ @eval = {}
4174
+ end
4175
+
4176
+ def invol_to_eval
4177
+ @eval.clear
4178
+ @invol.each do |k, v|
4179
+ @eval[k] = true
4180
+ end
4181
+ end
4182
+ end
4183
+
4184
+ class ThunkChunk
4185
+ attr_accessor :thunks, :capts, :pos, :values
4186
+ attr_accessor :pos_loc
4187
+
4188
+ def initialize
4189
+ super
4190
+ @thunks = []
4191
+ @capts = []
4192
+ @pos = 0
4193
+ @values = []
4194
+ end
4195
+
4196
+ def resize_captures(len)
4197
+ (@capts.length...len).each do |i|
4198
+ @capts << Capture.new
4199
+ end
4200
+ end
4201
+ end
4202
+
4203
+ class Thunk
4204
+ attr_accessor :type
4205
+ end
4206
+
4207
+ class ThunkLeaf < Thunk
4208
+ attr_accessor :capt0, :capts, :value_refs, :action
4209
+
4210
+ def initialize(action)
4211
+ @type = :leaf
4212
+ @value_refs = []
4213
+ @capts = []
4214
+ @capt0 = Capture.new
4215
+ @action = action
4216
+ end
4217
+ end
4218
+
4219
+ class ThunkNode < Thunk
4220
+ attr_accessor :thunks, :values, :index
4221
+
4222
+ def initialize(thunks, values, index)
4223
+ @type = :node
4224
+ @thunks = thunks
4225
+ @values = values
4226
+ @index = index
4227
+ values[index] ||= Value.new if values
4228
+ end
4229
+ end
4230
+
4231
+ class LrEntry
4232
+ attr_accessor :rule, :head, :seed
4233
+ end
4234
+
4235
+ class Capture
4236
+ attr_accessor :range_start, :range_end
4237
+ attr_accessor :start_loc, :end_loc
4238
+
4239
+ def initialize
4240
+ @range_start = 0
4241
+ @range_end = 0
4242
+ @start_loc = Location.new
4243
+ @end_loc = Location.new
4244
+ end
4245
+
4246
+ def capture_string(buffer)
4247
+ @string ||= buffer[@range_start, @range_end - @range_start]
4248
+ end
4249
+ end
4250
+
4251
+ class LrAnswer
4252
+ attr_accessor :hold, :lr, :chunk, :pos, :type
4253
+ attr_accessor :pos_loc
4254
+
4255
+ def initialize(type, pos, pos_loc)
4256
+ @type = type
4257
+ @pos = pos
4258
+ @pos_loc = pos_loc
4259
+ end
4260
+
4261
+ def set_chunk(chunk)
4262
+ a = LrAnswer.new(@type, @pos, @pos_loc)
4263
+ if @type == :lr
4264
+ a.lr = @lr
4265
+ elsif @type == :chunk
4266
+ a.chunk = @chunk
4267
+ end
4268
+ a.hold = @hold
4269
+ @hold = a
4270
+ @type = :chunk
4271
+ @chunk = chunk
4272
+ end
4273
+ end
4274
+
4275
+ class Value
4276
+ attr_accessor :value
4277
+ end
4278
+ end
4279
+
4280
+ class Packcr::Parser
4281
+ attr_accessor :rules
4282
+
4283
+ def rule(name)
4284
+ @rulehash[name]
4285
+ end
4286
+
4287
+ def make_rulehash
4288
+ @rules.each do |rule|
4289
+ @rulehash[rule.name] = rule
4290
+ end
4291
+ end
4292
+ end