packcr 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/exe/packcr +3 -0
  3. data/lib/packcr/broadcast.rb +17 -0
  4. data/lib/packcr/cli.rb +25 -0
  5. data/lib/packcr/code_block.rb +2 -3
  6. data/lib/packcr/context.rb +59 -56
  7. data/lib/packcr/generator.rb +13 -11
  8. data/lib/packcr/node/action_node.rb +14 -5
  9. data/lib/packcr/node/alternate_node.rb +20 -12
  10. data/lib/packcr/node/capture_node.rb +11 -11
  11. data/lib/packcr/node/charclass_node.rb +37 -13
  12. data/lib/packcr/node/eof_node.rb +23 -0
  13. data/lib/packcr/node/error_node.rb +17 -12
  14. data/lib/packcr/node/expand_node.rb +11 -5
  15. data/lib/packcr/node/predicate_node.rb +15 -24
  16. data/lib/packcr/node/quantity_node.rb +23 -18
  17. data/lib/packcr/node/reference_node.rb +21 -5
  18. data/lib/packcr/node/root_node.rb +60 -0
  19. data/lib/packcr/node/rule_node.rb +26 -3
  20. data/lib/packcr/node/sequence_node.rb +46 -31
  21. data/lib/packcr/node/string_node.rb +12 -12
  22. data/lib/packcr/node.rb +35 -4
  23. data/lib/packcr/parser.rb +2939 -2661
  24. data/lib/packcr/stream.rb +8 -13
  25. data/lib/packcr/templates/context/header.c.erb +29 -0
  26. data/lib/packcr/templates/context/source.c.erb +1292 -0
  27. data/lib/packcr/templates/context/source.rb.erb +406 -0
  28. data/lib/packcr/templates/node/action.c.erb +16 -0
  29. data/lib/packcr/templates/node/action.rb.erb +21 -0
  30. data/lib/packcr/templates/node/alternate.c.erb +34 -0
  31. data/lib/packcr/templates/node/alternate.rb.erb +40 -0
  32. data/lib/packcr/templates/node/capture.c.erb +17 -0
  33. data/lib/packcr/templates/node/capture.rb.erb +14 -0
  34. data/lib/packcr/templates/node/charclass.c.erb +47 -0
  35. data/lib/packcr/templates/node/charclass.rb.erb +49 -0
  36. data/lib/packcr/templates/node/charclass_any.c.erb +5 -0
  37. data/lib/packcr/templates/node/charclass_any.rb.erb +7 -0
  38. data/lib/packcr/templates/node/charclass_fail.c.erb +1 -0
  39. data/lib/packcr/templates/node/charclass_fail.rb.erb +1 -0
  40. data/lib/packcr/templates/node/charclass_one.c.erb +19 -0
  41. data/lib/packcr/templates/node/charclass_one.rb.erb +23 -0
  42. data/lib/packcr/templates/node/charclass_utf8.c.erb +49 -0
  43. data/lib/packcr/templates/node/charclass_utf8.rb.erb +50 -0
  44. data/lib/packcr/templates/node/charclass_utf8_reverse.rb.erb +51 -0
  45. data/lib/packcr/templates/node/eof.c.erb +1 -0
  46. data/lib/packcr/templates/node/eof.rb.erb +3 -0
  47. data/lib/packcr/templates/node/error.c.erb +28 -0
  48. data/lib/packcr/templates/node/error.rb.erb +34 -0
  49. data/lib/packcr/templates/node/expand.c.erb +16 -0
  50. data/lib/packcr/templates/node/expand.rb.erb +16 -0
  51. data/lib/packcr/templates/node/predicate.c.erb +30 -0
  52. data/lib/packcr/templates/node/predicate.rb.erb +28 -0
  53. data/lib/packcr/templates/node/predicate_neg.c.erb +23 -0
  54. data/lib/packcr/templates/node/predicate_neg.rb.erb +22 -0
  55. data/lib/packcr/templates/node/quantify_many.c.erb +45 -0
  56. data/lib/packcr/templates/node/quantify_many.rb.erb +47 -0
  57. data/lib/packcr/templates/node/quantify_one.c.erb +21 -0
  58. data/lib/packcr/templates/node/quantify_one.rb.erb +23 -0
  59. data/lib/packcr/templates/node/reference.c.erb +5 -0
  60. data/lib/packcr/templates/node/reference.rb.erb +9 -0
  61. data/lib/packcr/templates/node/reference_reverse.rb.erb +9 -0
  62. data/lib/packcr/templates/node/rule.c.erb +19 -0
  63. data/lib/packcr/templates/node/rule.rb.erb +23 -0
  64. data/lib/packcr/templates/node/sequence.c.erb +12 -0
  65. data/lib/packcr/templates/node/sequence.rb.erb +12 -0
  66. data/lib/packcr/templates/node/string_many.c.erb +11 -0
  67. data/lib/packcr/templates/node/string_many.rb.erb +10 -0
  68. data/lib/packcr/templates/node/string_one.c.erb +8 -0
  69. data/lib/packcr/templates/node/string_one.rb.erb +10 -0
  70. data/lib/packcr/tokenizer.rb +2948 -0
  71. data/lib/packcr/util.rb +0 -8
  72. data/lib/packcr/version.rb +1 -1
  73. data/lib/packcr.rb +1 -2
  74. metadata +87 -8
  75. data/lib/packcr/buffer.rb +0 -47
@@ -0,0 +1,2948 @@
1
+ # A packrat parser generated by PackCR 0.0.5
2
+
3
+ require "packcr"
4
+
5
+ class Packcr::Tokenizer
6
+ def initialize(debug: false)
7
+ @buffer = +""
8
+
9
+ @pos = 0
10
+ @cur = 0
11
+ @level = 0
12
+ @lrstack = []
13
+ @thunk = ThunkNode.new([], nil, 0)
14
+ @lrtable = LrTable.new
15
+ @debug = debug
16
+ @global_values = {}
17
+ @parser_buffer = +""
18
+ @ifile = open(File.join(__dir__, "parser.rb.peg"))
19
+ end
20
+
21
+ def debug
22
+ yield if @debug
23
+ end
24
+
25
+ def getc
26
+ $stdin.getc
27
+ end
28
+
29
+ def refill_buffer(num, mode = nil)
30
+ len = @buffer.length
31
+ if len >= @cur + num
32
+ return len - @cur
33
+ end
34
+ while len < @cur + num
35
+ c = getc
36
+ break if !c
37
+ @buffer << c
38
+ len = @buffer.length
39
+ end
40
+ return len - @cur
41
+ end
42
+
43
+ def commit_buffer
44
+ @buffer = @buffer[@cur, @buffer.length - @cur]
45
+ @pos += @cur
46
+ @lrtable.clear
47
+ @cur = 0
48
+ end
49
+
50
+ def parse
51
+ pos = @pos
52
+ if apply_rule(:evaluate_rule_TOKEN, @thunk.thunks, nil, 0)
53
+ @thunk.do_action(self, nil, 0)
54
+ else
55
+ raise SyntaxError, "can't parse"
56
+ end
57
+ commit_buffer
58
+ @thunk.clear
59
+ refill_buffer(1) >= 1 && pos != @pos
60
+ end
61
+
62
+ def run
63
+ nil while parse
64
+ end
65
+
66
+ def action_COMMENT_0(__pcc_in, __pcc_vars, __pcc_index)
67
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
68
+ __0 = __pcc_in.capt0.capture_string(@buffer)
69
+ __0s = @pos + __pcc_in.capt0.range_start
70
+ __0e = @pos + __pcc_in.capt0.range_end
71
+ @parser_buffer << "\x01"
72
+
73
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
74
+ end
75
+
76
+ def action_DIRECTIVE_ESOURCE_0(__pcc_in, __pcc_vars, __pcc_index)
77
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
78
+ __0 = __pcc_in.capt0.capture_string(@buffer)
79
+ __0s = @pos + __pcc_in.capt0.range_start
80
+ __0e = @pos + __pcc_in.capt0.range_end
81
+ @parser_buffer << "\x02"
82
+
83
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
84
+ end
85
+
86
+ def action_DIRECTIVE_SOURCE_0(__pcc_in, __pcc_vars, __pcc_index)
87
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
88
+ __0 = __pcc_in.capt0.capture_string(@buffer)
89
+ __0s = @pos + __pcc_in.capt0.range_start
90
+ __0e = @pos + __pcc_in.capt0.range_end
91
+ @parser_buffer << "\x03"
92
+
93
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
94
+ end
95
+
96
+ def action_DIRECTIVE_LHEADER_0(__pcc_in, __pcc_vars, __pcc_index)
97
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
98
+ __0 = __pcc_in.capt0.capture_string(@buffer)
99
+ __0s = @pos + __pcc_in.capt0.range_start
100
+ __0e = @pos + __pcc_in.capt0.range_end
101
+ @parser_buffer << "\x04"
102
+
103
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
104
+ end
105
+
106
+ def action_DIRECTIVE_LSOURCE_0(__pcc_in, __pcc_vars, __pcc_index)
107
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
108
+ __0 = __pcc_in.capt0.capture_string(@buffer)
109
+ __0s = @pos + __pcc_in.capt0.range_start
110
+ __0e = @pos + __pcc_in.capt0.range_end
111
+ @parser_buffer << "\x05"
112
+
113
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
114
+ end
115
+
116
+ def action_DIRECTIVE_HEADER_0(__pcc_in, __pcc_vars, __pcc_index)
117
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
118
+ __0 = __pcc_in.capt0.capture_string(@buffer)
119
+ __0s = @pos + __pcc_in.capt0.range_start
120
+ __0e = @pos + __pcc_in.capt0.range_end
121
+ @parser_buffer << "\x06"
122
+
123
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
124
+ end
125
+
126
+ def action_DIRECTIVE_LOC_0(__pcc_in, __pcc_vars, __pcc_index)
127
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
128
+ __0 = __pcc_in.capt0.capture_string(@buffer)
129
+ __0s = @pos + __pcc_in.capt0.range_start
130
+ __0e = @pos + __pcc_in.capt0.range_end
131
+ @parser_buffer << "\x07"
132
+
133
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
134
+ end
135
+
136
+ def action_DIRECTIVE_INIT_0(__pcc_in, __pcc_vars, __pcc_index)
137
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
138
+ __0 = __pcc_in.capt0.capture_string(@buffer)
139
+ __0s = @pos + __pcc_in.capt0.range_start
140
+ __0e = @pos + __pcc_in.capt0.range_end
141
+ @parser_buffer << "\x08"
142
+
143
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
144
+ end
145
+
146
+ def action_DIRECTIVE_ECOMMON_0(__pcc_in, __pcc_vars, __pcc_index)
147
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
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
+ @parser_buffer << "\x09"
152
+
153
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
154
+ end
155
+
156
+ def action_DIRECTIVE_COMMON_0(__pcc_in, __pcc_vars, __pcc_index)
157
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
158
+ __0 = __pcc_in.capt0.capture_string(@buffer)
159
+ __0s = @pos + __pcc_in.capt0.range_start
160
+ __0e = @pos + __pcc_in.capt0.range_end
161
+ @parser_buffer << "\x0a"
162
+
163
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
164
+ end
165
+
166
+ def action_DIRECTIVE_VALUE_0(__pcc_in, __pcc_vars, __pcc_index)
167
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
168
+ __0 = __pcc_in.capt0.capture_string(@buffer)
169
+ __0s = @pos + __pcc_in.capt0.range_start
170
+ __0e = @pos + __pcc_in.capt0.range_end
171
+ @parser_buffer << "\x0b"
172
+
173
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
174
+ end
175
+
176
+ def action_DIRECTIVE_AUXIL_0(__pcc_in, __pcc_vars, __pcc_index)
177
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
178
+ __0 = __pcc_in.capt0.capture_string(@buffer)
179
+ __0s = @pos + __pcc_in.capt0.range_start
180
+ __0e = @pos + __pcc_in.capt0.range_end
181
+ @parser_buffer << "\x0c"
182
+
183
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
184
+ end
185
+
186
+ def action_DIRECTIVE_PREFIX_0(__pcc_in, __pcc_vars, __pcc_index)
187
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
188
+ __0 = __pcc_in.capt0.capture_string(@buffer)
189
+ __0s = @pos + __pcc_in.capt0.range_start
190
+ __0e = @pos + __pcc_in.capt0.range_end
191
+ @parser_buffer << "\x0d"
192
+
193
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
194
+ end
195
+
196
+ def action_DIRECTIVE_CAPT_0(__pcc_in, __pcc_vars, __pcc_index)
197
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
198
+ __0 = __pcc_in.capt0.capture_string(@buffer)
199
+ __0s = @pos + __pcc_in.capt0.range_start
200
+ __0e = @pos + __pcc_in.capt0.range_end
201
+ @parser_buffer << "\x0e"
202
+
203
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
204
+ end
205
+
206
+ def action_LARROW_0(__pcc_in, __pcc_vars, __pcc_index)
207
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
208
+ __0 = __pcc_in.capt0.capture_string(@buffer)
209
+ __0s = @pos + __pcc_in.capt0.range_start
210
+ __0e = @pos + __pcc_in.capt0.range_end
211
+ @parser_buffer << "\x0f"
212
+
213
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
214
+ end
215
+
216
+ def action_RARROW_0(__pcc_in, __pcc_vars, __pcc_index)
217
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
218
+ __0 = __pcc_in.capt0.capture_string(@buffer)
219
+ __0s = @pos + __pcc_in.capt0.range_start
220
+ __0e = @pos + __pcc_in.capt0.range_end
221
+ @parser_buffer << "\x10"
222
+
223
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
224
+ end
225
+
226
+ def action_SLASH_0(__pcc_in, __pcc_vars, __pcc_index)
227
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
228
+ __0 = __pcc_in.capt0.capture_string(@buffer)
229
+ __0s = @pos + __pcc_in.capt0.range_start
230
+ __0e = @pos + __pcc_in.capt0.range_end
231
+ @parser_buffer << "\x11"
232
+
233
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
234
+ end
235
+
236
+ def action_CUT_0(__pcc_in, __pcc_vars, __pcc_index)
237
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
238
+ __0 = __pcc_in.capt0.capture_string(@buffer)
239
+ __0s = @pos + __pcc_in.capt0.range_start
240
+ __0e = @pos + __pcc_in.capt0.range_end
241
+ @parser_buffer << "\x12"
242
+
243
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
244
+ end
245
+
246
+ def action_ERROR_0(__pcc_in, __pcc_vars, __pcc_index)
247
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
248
+ __0 = __pcc_in.capt0.capture_string(@buffer)
249
+ __0s = @pos + __pcc_in.capt0.range_start
250
+ __0e = @pos + __pcc_in.capt0.range_end
251
+ @parser_buffer << "\x13"
252
+
253
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
254
+ end
255
+
256
+ def action_AND_0(__pcc_in, __pcc_vars, __pcc_index)
257
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
258
+ __0 = __pcc_in.capt0.capture_string(@buffer)
259
+ __0s = @pos + __pcc_in.capt0.range_start
260
+ __0e = @pos + __pcc_in.capt0.range_end
261
+ @parser_buffer << "\x14"
262
+
263
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
264
+ end
265
+
266
+ def action_BANG_0(__pcc_in, __pcc_vars, __pcc_index)
267
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
268
+ __0 = __pcc_in.capt0.capture_string(@buffer)
269
+ __0s = @pos + __pcc_in.capt0.range_start
270
+ __0e = @pos + __pcc_in.capt0.range_end
271
+ @parser_buffer << "\x15"
272
+
273
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
274
+ end
275
+
276
+ def action_MULT_0(__pcc_in, __pcc_vars, __pcc_index)
277
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
278
+ __0 = __pcc_in.capt0.capture_string(@buffer)
279
+ __0s = @pos + __pcc_in.capt0.range_start
280
+ __0e = @pos + __pcc_in.capt0.range_end
281
+ @parser_buffer << "\x16"
282
+
283
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
284
+ end
285
+
286
+ def action_PLUS_0(__pcc_in, __pcc_vars, __pcc_index)
287
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
288
+ __0 = __pcc_in.capt0.capture_string(@buffer)
289
+ __0s = @pos + __pcc_in.capt0.range_start
290
+ __0e = @pos + __pcc_in.capt0.range_end
291
+ @parser_buffer << "\x17"
292
+
293
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
294
+ end
295
+
296
+ def action_QUESTION_0(__pcc_in, __pcc_vars, __pcc_index)
297
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
298
+ __0 = __pcc_in.capt0.capture_string(@buffer)
299
+ __0s = @pos + __pcc_in.capt0.range_start
300
+ __0e = @pos + __pcc_in.capt0.range_end
301
+ @parser_buffer << "\x18"
302
+
303
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
304
+ end
305
+
306
+ def action_COLON_0(__pcc_in, __pcc_vars, __pcc_index)
307
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
308
+ __0 = __pcc_in.capt0.capture_string(@buffer)
309
+ __0s = @pos + __pcc_in.capt0.range_start
310
+ __0e = @pos + __pcc_in.capt0.range_end
311
+ @parser_buffer << "\x19"
312
+
313
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
314
+ end
315
+
316
+ def action_DDOLLER_0(__pcc_in, __pcc_vars, __pcc_index)
317
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
318
+ __0 = __pcc_in.capt0.capture_string(@buffer)
319
+ __0s = @pos + __pcc_in.capt0.range_start
320
+ __0e = @pos + __pcc_in.capt0.range_end
321
+ @parser_buffer << "\x1a"
322
+
323
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
324
+ end
325
+
326
+ def action_NDOLLER_0(__pcc_in, __pcc_vars, __pcc_index)
327
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
328
+ __0 = __pcc_in.capt0.capture_string(@buffer)
329
+ __0s = @pos + __pcc_in.capt0.range_start
330
+ __0e = @pos + __pcc_in.capt0.range_end
331
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
332
+ __1s = @pos + __pcc_in.capts[0].range_start
333
+ __1e = @pos + __pcc_in.capts[0].range_end
334
+ @parser_buffer << "\x1b"
335
+
336
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
337
+ end
338
+
339
+ def action_NDOLLER_1(__pcc_in, __pcc_vars, __pcc_index)
340
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
341
+ __0 = __pcc_in.capt0.capture_string(@buffer)
342
+ __0s = @pos + __pcc_in.capt0.range_start
343
+ __0e = @pos + __pcc_in.capt0.range_end
344
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
345
+ __1s = @pos + __pcc_in.capts[0].range_start
346
+ __1e = @pos + __pcc_in.capts[0].range_end
347
+ ____ = __1.to_i
348
+
349
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
350
+ end
351
+
352
+ def action_LPAREN_0(__pcc_in, __pcc_vars, __pcc_index)
353
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
354
+ __0 = __pcc_in.capt0.capture_string(@buffer)
355
+ __0s = @pos + __pcc_in.capt0.range_start
356
+ __0e = @pos + __pcc_in.capt0.range_end
357
+ @parser_buffer << "\x1c"
358
+
359
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
360
+ end
361
+
362
+ def action_RPAREN_0(__pcc_in, __pcc_vars, __pcc_index)
363
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
364
+ __0 = __pcc_in.capt0.capture_string(@buffer)
365
+ __0s = @pos + __pcc_in.capt0.range_start
366
+ __0e = @pos + __pcc_in.capt0.range_end
367
+ @parser_buffer << "\x1d"
368
+
369
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
370
+ end
371
+
372
+ def action_LT_0(__pcc_in, __pcc_vars, __pcc_index)
373
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
374
+ __0 = __pcc_in.capt0.capture_string(@buffer)
375
+ __0s = @pos + __pcc_in.capt0.range_start
376
+ __0e = @pos + __pcc_in.capt0.range_end
377
+ @parser_buffer << "\x1e"
378
+
379
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
380
+ end
381
+
382
+ def action_GT_0(__pcc_in, __pcc_vars, __pcc_index)
383
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
384
+ __0 = __pcc_in.capt0.capture_string(@buffer)
385
+ __0s = @pos + __pcc_in.capt0.range_start
386
+ __0e = @pos + __pcc_in.capt0.range_end
387
+ @parser_buffer << "\x1f"
388
+
389
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
390
+ end
391
+
392
+ def action_DOT_0(__pcc_in, __pcc_vars, __pcc_index)
393
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
394
+ __0 = __pcc_in.capt0.capture_string(@buffer)
395
+ __0s = @pos + __pcc_in.capt0.range_start
396
+ __0e = @pos + __pcc_in.capt0.range_end
397
+ @parser_buffer << "\x20"
398
+
399
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
400
+ end
401
+
402
+ def action_CHARCLASS_0(__pcc_in, __pcc_vars, __pcc_index)
403
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
404
+ __0 = __pcc_in.capt0.capture_string(@buffer)
405
+ __0s = @pos + __pcc_in.capt0.range_start
406
+ __0e = @pos + __pcc_in.capt0.range_end
407
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
408
+ __1s = @pos + __pcc_in.capts[0].range_start
409
+ __1e = @pos + __pcc_in.capts[0].range_end
410
+ @parser_buffer << "\x21"
411
+
412
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
413
+ end
414
+
415
+ def action_CHARCLASS_1(__pcc_in, __pcc_vars, __pcc_index)
416
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
417
+ __0 = __pcc_in.capt0.capture_string(@buffer)
418
+ __0s = @pos + __pcc_in.capt0.range_start
419
+ __0e = @pos + __pcc_in.capt0.range_end
420
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
421
+ __1s = @pos + __pcc_in.capts[0].range_start
422
+ __1e = @pos + __pcc_in.capts[0].range_end
423
+ ____ = __1
424
+
425
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
426
+ end
427
+
428
+ def action_QUOTATION_SINGLE_0(__pcc_in, __pcc_vars, __pcc_index)
429
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
430
+ __0 = __pcc_in.capt0.capture_string(@buffer)
431
+ __0s = @pos + __pcc_in.capt0.range_start
432
+ __0e = @pos + __pcc_in.capt0.range_end
433
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
434
+ __1s = @pos + __pcc_in.capts[0].range_start
435
+ __1e = @pos + __pcc_in.capts[0].range_end
436
+ @parser_buffer << "\x22"
437
+
438
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
439
+ end
440
+
441
+ def action_QUOTATION_SINGLE_1(__pcc_in, __pcc_vars, __pcc_index)
442
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
443
+ __0 = __pcc_in.capt0.capture_string(@buffer)
444
+ __0s = @pos + __pcc_in.capt0.range_start
445
+ __0e = @pos + __pcc_in.capt0.range_end
446
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
447
+ __1s = @pos + __pcc_in.capts[0].range_start
448
+ __1e = @pos + __pcc_in.capts[0].range_end
449
+ ____ = __1
450
+
451
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
452
+ end
453
+
454
+ def action_QUOTATION_DOUBLE_0(__pcc_in, __pcc_vars, __pcc_index)
455
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
456
+ __0 = __pcc_in.capt0.capture_string(@buffer)
457
+ __0s = @pos + __pcc_in.capt0.range_start
458
+ __0e = @pos + __pcc_in.capt0.range_end
459
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
460
+ __1s = @pos + __pcc_in.capts[0].range_start
461
+ __1e = @pos + __pcc_in.capts[0].range_end
462
+ @parser_buffer << "\x23"
463
+
464
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
465
+ end
466
+
467
+ def action_QUOTATION_DOUBLE_1(__pcc_in, __pcc_vars, __pcc_index)
468
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
469
+ __0 = __pcc_in.capt0.capture_string(@buffer)
470
+ __0s = @pos + __pcc_in.capt0.range_start
471
+ __0e = @pos + __pcc_in.capt0.range_end
472
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
473
+ __1s = @pos + __pcc_in.capts[0].range_start
474
+ __1e = @pos + __pcc_in.capts[0].range_end
475
+ ____ = __1
476
+
477
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
478
+ end
479
+
480
+ def action_FOOTER_0(__pcc_in, __pcc_vars, __pcc_index)
481
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
482
+ __0 = __pcc_in.capt0.capture_string(@buffer)
483
+ __0s = @pos + __pcc_in.capt0.range_start
484
+ __0e = @pos + __pcc_in.capt0.range_end
485
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
486
+ __1s = @pos + __pcc_in.capts[0].range_start
487
+ __1e = @pos + __pcc_in.capts[0].range_end
488
+ @parser_buffer << "\x24"
489
+
490
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
491
+ end
492
+
493
+ def action_IDENTIFIER_0(__pcc_in, __pcc_vars, __pcc_index)
494
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
495
+ __0 = __pcc_in.capt0.capture_string(@buffer)
496
+ __0s = @pos + __pcc_in.capt0.range_start
497
+ __0e = @pos + __pcc_in.capt0.range_end
498
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
499
+ __1s = @pos + __pcc_in.capts[0].range_start
500
+ __1e = @pos + __pcc_in.capts[0].range_end
501
+ @parser_buffer << "\x25"
502
+
503
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
504
+ end
505
+
506
+ def action_IDENTIFIER_1(__pcc_in, __pcc_vars, __pcc_index)
507
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
508
+ __0 = __pcc_in.capt0.capture_string(@buffer)
509
+ __0s = @pos + __pcc_in.capt0.range_start
510
+ __0e = @pos + __pcc_in.capt0.range_end
511
+ __1 = __pcc_in.capts[0].capture_string(@buffer)
512
+ __1s = @pos + __pcc_in.capts[0].range_start
513
+ __1e = @pos + __pcc_in.capts[0].range_end
514
+ ____ = __1
515
+
516
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
517
+ end
518
+
519
+ def action_SPACES_0(__pcc_in, __pcc_vars, __pcc_index)
520
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
521
+ __0 = __pcc_in.capt0.capture_string(@buffer)
522
+ __0s = @pos + __pcc_in.capt0.range_start
523
+ __0e = @pos + __pcc_in.capt0.range_end
524
+ @parser_buffer << "\x26"
525
+
526
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
527
+ end
528
+
529
+ def action_LBRACE_0(__pcc_in, __pcc_vars, __pcc_index)
530
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
531
+ __0 = __pcc_in.capt0.capture_string(@buffer)
532
+ __0s = @pos + __pcc_in.capt0.range_start
533
+ __0e = @pos + __pcc_in.capt0.range_end
534
+ @parser_buffer << "\x27"
535
+
536
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
537
+ end
538
+
539
+ def action_RBRACE_0(__pcc_in, __pcc_vars, __pcc_index)
540
+ ____ = (__pcc_vars[__pcc_index] ||= Value.new).value if __pcc_vars
541
+ __0 = __pcc_in.capt0.capture_string(@buffer)
542
+ __0s = @pos + __pcc_in.capt0.range_start
543
+ __0e = @pos + __pcc_in.capt0.range_end
544
+ @parser_buffer << "\x28"
545
+
546
+ __pcc_vars[__pcc_index].value = ____ if __pcc_vars
547
+ end
548
+
549
+ def evaluate_rule_TOKEN
550
+ chunk = ThunkChunk.new
551
+ chunk.pos = @cur
552
+ debug { warn "#{ " " * @level}EVAL TOKEN #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
553
+ @level += 1
554
+ chunk.resize_captures(0)
555
+ catch(0) do
556
+ catch(1) do |; pos, p_loc, n|
557
+ pos = @cur
558
+ n = chunk.thunks.length
559
+ if apply_rule(:evaluate_rule_COMMENT, chunk.thunks, nil, 0)
560
+ throw(1)
561
+ end
562
+ @cur = pos
563
+ chunk.thunks[n..-1] = []
564
+ if apply_rule(:evaluate_rule_DIRECTIVE_ESOURCE, chunk.thunks, nil, 0)
565
+ throw(1)
566
+ end
567
+ @cur = pos
568
+ chunk.thunks[n..-1] = []
569
+ if apply_rule(:evaluate_rule_DIRECTIVE_SOURCE, chunk.thunks, nil, 0)
570
+ throw(1)
571
+ end
572
+ @cur = pos
573
+ chunk.thunks[n..-1] = []
574
+ if apply_rule(:evaluate_rule_DIRECTIVE_LHEADER, chunk.thunks, nil, 0)
575
+ throw(1)
576
+ end
577
+ @cur = pos
578
+ chunk.thunks[n..-1] = []
579
+ if apply_rule(:evaluate_rule_DIRECTIVE_LSOURCE, chunk.thunks, nil, 0)
580
+ throw(1)
581
+ end
582
+ @cur = pos
583
+ chunk.thunks[n..-1] = []
584
+ if apply_rule(:evaluate_rule_DIRECTIVE_HEADER, chunk.thunks, nil, 0)
585
+ throw(1)
586
+ end
587
+ @cur = pos
588
+ chunk.thunks[n..-1] = []
589
+ if apply_rule(:evaluate_rule_DIRECTIVE_LOC, chunk.thunks, nil, 0)
590
+ throw(1)
591
+ end
592
+ @cur = pos
593
+ chunk.thunks[n..-1] = []
594
+ if apply_rule(:evaluate_rule_DIRECTIVE_INIT, chunk.thunks, nil, 0)
595
+ throw(1)
596
+ end
597
+ @cur = pos
598
+ chunk.thunks[n..-1] = []
599
+ if apply_rule(:evaluate_rule_DIRECTIVE_ECOMMON, chunk.thunks, nil, 0)
600
+ throw(1)
601
+ end
602
+ @cur = pos
603
+ chunk.thunks[n..-1] = []
604
+ if apply_rule(:evaluate_rule_DIRECTIVE_COMMON, chunk.thunks, nil, 0)
605
+ throw(1)
606
+ end
607
+ @cur = pos
608
+ chunk.thunks[n..-1] = []
609
+ if apply_rule(:evaluate_rule_DIRECTIVE_VALUE, chunk.thunks, nil, 0)
610
+ throw(1)
611
+ end
612
+ @cur = pos
613
+ chunk.thunks[n..-1] = []
614
+ if apply_rule(:evaluate_rule_DIRECTIVE_AUXIL, chunk.thunks, nil, 0)
615
+ throw(1)
616
+ end
617
+ @cur = pos
618
+ chunk.thunks[n..-1] = []
619
+ if apply_rule(:evaluate_rule_DIRECTIVE_PREFIX, chunk.thunks, nil, 0)
620
+ throw(1)
621
+ end
622
+ @cur = pos
623
+ chunk.thunks[n..-1] = []
624
+ if apply_rule(:evaluate_rule_DIRECTIVE_CAPT, chunk.thunks, nil, 0)
625
+ throw(1)
626
+ end
627
+ @cur = pos
628
+ chunk.thunks[n..-1] = []
629
+ if apply_rule(:evaluate_rule_LARROW, chunk.thunks, nil, 0)
630
+ throw(1)
631
+ end
632
+ @cur = pos
633
+ chunk.thunks[n..-1] = []
634
+ if apply_rule(:evaluate_rule_RARROW, chunk.thunks, nil, 0)
635
+ throw(1)
636
+ end
637
+ @cur = pos
638
+ chunk.thunks[n..-1] = []
639
+ if apply_rule(:evaluate_rule_SLASH, chunk.thunks, nil, 0)
640
+ throw(1)
641
+ end
642
+ @cur = pos
643
+ chunk.thunks[n..-1] = []
644
+ if apply_rule(:evaluate_rule_CUT, chunk.thunks, nil, 0)
645
+ throw(1)
646
+ end
647
+ @cur = pos
648
+ chunk.thunks[n..-1] = []
649
+ if apply_rule(:evaluate_rule_ERROR, chunk.thunks, nil, 0)
650
+ throw(1)
651
+ end
652
+ @cur = pos
653
+ chunk.thunks[n..-1] = []
654
+ if apply_rule(:evaluate_rule_AND, chunk.thunks, nil, 0)
655
+ throw(1)
656
+ end
657
+ @cur = pos
658
+ chunk.thunks[n..-1] = []
659
+ if apply_rule(:evaluate_rule_BANG, chunk.thunks, nil, 0)
660
+ throw(1)
661
+ end
662
+ @cur = pos
663
+ chunk.thunks[n..-1] = []
664
+ if apply_rule(:evaluate_rule_MULT, chunk.thunks, nil, 0)
665
+ throw(1)
666
+ end
667
+ @cur = pos
668
+ chunk.thunks[n..-1] = []
669
+ if apply_rule(:evaluate_rule_PLUS, chunk.thunks, nil, 0)
670
+ throw(1)
671
+ end
672
+ @cur = pos
673
+ chunk.thunks[n..-1] = []
674
+ if apply_rule(:evaluate_rule_QUESTION, chunk.thunks, nil, 0)
675
+ throw(1)
676
+ end
677
+ @cur = pos
678
+ chunk.thunks[n..-1] = []
679
+ if apply_rule(:evaluate_rule_COLON, chunk.thunks, nil, 0)
680
+ throw(1)
681
+ end
682
+ @cur = pos
683
+ chunk.thunks[n..-1] = []
684
+ if apply_rule(:evaluate_rule_DDOLLER, chunk.thunks, nil, 0)
685
+ throw(1)
686
+ end
687
+ @cur = pos
688
+ chunk.thunks[n..-1] = []
689
+ if apply_rule(:evaluate_rule_NDOLLER, chunk.thunks, nil, 0)
690
+ throw(1)
691
+ end
692
+ @cur = pos
693
+ chunk.thunks[n..-1] = []
694
+ if apply_rule(:evaluate_rule_LPAREN, chunk.thunks, nil, 0)
695
+ throw(1)
696
+ end
697
+ @cur = pos
698
+ chunk.thunks[n..-1] = []
699
+ if apply_rule(:evaluate_rule_RPAREN, chunk.thunks, nil, 0)
700
+ throw(1)
701
+ end
702
+ @cur = pos
703
+ chunk.thunks[n..-1] = []
704
+ if apply_rule(:evaluate_rule_LT, chunk.thunks, nil, 0)
705
+ throw(1)
706
+ end
707
+ @cur = pos
708
+ chunk.thunks[n..-1] = []
709
+ if apply_rule(:evaluate_rule_GT, chunk.thunks, nil, 0)
710
+ throw(1)
711
+ end
712
+ @cur = pos
713
+ chunk.thunks[n..-1] = []
714
+ if apply_rule(:evaluate_rule_DOT, chunk.thunks, nil, 0)
715
+ throw(1)
716
+ end
717
+ @cur = pos
718
+ chunk.thunks[n..-1] = []
719
+ if apply_rule(:evaluate_rule_CHARCLASS, chunk.thunks, nil, 0)
720
+ throw(1)
721
+ end
722
+ @cur = pos
723
+ chunk.thunks[n..-1] = []
724
+ if apply_rule(:evaluate_rule_QUOTATION_SINGLE, chunk.thunks, nil, 0)
725
+ throw(1)
726
+ end
727
+ @cur = pos
728
+ chunk.thunks[n..-1] = []
729
+ if apply_rule(:evaluate_rule_QUOTATION_DOUBLE, chunk.thunks, nil, 0)
730
+ throw(1)
731
+ end
732
+ @cur = pos
733
+ chunk.thunks[n..-1] = []
734
+ if apply_rule(:evaluate_rule_FOOTER, chunk.thunks, nil, 0)
735
+ throw(1)
736
+ end
737
+ @cur = pos
738
+ chunk.thunks[n..-1] = []
739
+ if apply_rule(:evaluate_rule_IDENTIFIER, chunk.thunks, nil, 0)
740
+ throw(1)
741
+ end
742
+ @cur = pos
743
+ chunk.thunks[n..-1] = []
744
+ if apply_rule(:evaluate_rule_SPACES, chunk.thunks, nil, 0)
745
+ throw(1)
746
+ end
747
+ @cur = pos
748
+ chunk.thunks[n..-1] = []
749
+ if apply_rule(:evaluate_rule_LBRACE, chunk.thunks, nil, 0)
750
+ throw(1)
751
+ end
752
+ @cur = pos
753
+ chunk.thunks[n..-1] = []
754
+ if apply_rule(:evaluate_rule_RBRACE, chunk.thunks, nil, 0)
755
+ throw(1)
756
+ end
757
+ @cur = pos
758
+ chunk.thunks[n..-1] = []
759
+ throw(0)
760
+ end
761
+ @level -= 1
762
+ debug { warn "#{ " " * @level}MATCH TOKEN #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
763
+ return chunk
764
+ end
765
+ @level -= 1
766
+ debug { warn "#{ " " * @level}NOMATCH TOKEN #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
767
+ return nil
768
+ end
769
+
770
+ def evaluate_rule_COMMENT
771
+ chunk = ThunkChunk.new
772
+ chunk.pos = @cur
773
+ debug { warn "#{ " " * @level}EVAL COMMENT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
774
+ @level += 1
775
+ chunk.resize_captures(0)
776
+ catch(0) do
777
+ if (
778
+ refill_buffer(1) < 1 ||
779
+ @buffer[@cur] != "#"
780
+ )
781
+ throw(0)
782
+ end
783
+ @cur += 1
784
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
785
+ i = 0
786
+ catch(1) do
787
+ pos = @cur
788
+ n = chunk.thunks.length
789
+ 1.times do |;u, n|
790
+ if refill_buffer(1) < 1
791
+ throw(1)
792
+ end
793
+ u = @buffer[@cur]
794
+ if (
795
+ u == "\n"
796
+ )
797
+ throw(1)
798
+ end
799
+ @cur += 1
800
+ end
801
+ i += 1
802
+ if @cur != pos
803
+ redo
804
+ end
805
+ pos = nil
806
+ end
807
+ if pos
808
+ @cur = pos
809
+ chunk.thunks[n..-1] = []
810
+ end
811
+ end
812
+ catch(2) do |; pos, p_loc, n|
813
+ pos = @cur
814
+ n = chunk.thunks.length
815
+ catch(3) do
816
+ 1.times do |;pos, p_loc, n|
817
+ pos = @cur
818
+ n = chunk.thunks.length
819
+ catch(5) do
820
+ catch(4) do
821
+ if (
822
+ refill_buffer(1) < 1 ||
823
+ @buffer[@cur] != "\r"
824
+ )
825
+ throw(4)
826
+ end
827
+ @cur += 1
828
+ throw(5)
829
+ end
830
+ @cur = pos
831
+ chunk.thunks[n..-1] = []
832
+ end
833
+ end
834
+ if (
835
+ refill_buffer(1) < 1 ||
836
+ @buffer[@cur] != "\n"
837
+ )
838
+ throw(3)
839
+ end
840
+ @cur += 1
841
+ throw(2)
842
+ end
843
+ @cur = pos
844
+ chunk.thunks[n..-1] = []
845
+ if apply_rule(:evaluate_rule_EOF, chunk.thunks, nil, 0)
846
+ throw(2)
847
+ end
848
+ @cur = pos
849
+ chunk.thunks[n..-1] = []
850
+ throw(0)
851
+ end
852
+ chunk.thunks.push(
853
+ ThunkLeaf.new(
854
+ :action_COMMENT_0,
855
+ Capture.new(
856
+ chunk.pos, @cur,
857
+ ),
858
+ {},
859
+ {},
860
+ )
861
+ )
862
+ @level -= 1
863
+ debug { warn "#{ " " * @level}MATCH COMMENT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
864
+ return chunk
865
+ end
866
+ @level -= 1
867
+ debug { warn "#{ " " * @level}NOMATCH COMMENT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
868
+ return nil
869
+ end
870
+
871
+ def evaluate_rule_DIRECTIVE_ESOURCE
872
+ chunk = ThunkChunk.new
873
+ chunk.pos = @cur
874
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_ESOURCE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
875
+ @level += 1
876
+ chunk.resize_captures(0)
877
+ catch(0) do
878
+ if (
879
+ refill_buffer(12) < 12 ||
880
+ @buffer[@cur, 12] != "%earlysource"
881
+ )
882
+ throw(0)
883
+ end
884
+ @cur += 12
885
+ chunk.thunks.push(
886
+ ThunkLeaf.new(
887
+ :action_DIRECTIVE_ESOURCE_0,
888
+ Capture.new(
889
+ chunk.pos, @cur,
890
+ ),
891
+ {},
892
+ {},
893
+ )
894
+ )
895
+ @level -= 1
896
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_ESOURCE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
897
+ return chunk
898
+ end
899
+ @level -= 1
900
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_ESOURCE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
901
+ return nil
902
+ end
903
+
904
+ def evaluate_rule_DIRECTIVE_SOURCE
905
+ chunk = ThunkChunk.new
906
+ chunk.pos = @cur
907
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_SOURCE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
908
+ @level += 1
909
+ chunk.resize_captures(0)
910
+ catch(0) do
911
+ if (
912
+ refill_buffer(7) < 7 ||
913
+ @buffer[@cur, 7] != "%source"
914
+ )
915
+ throw(0)
916
+ end
917
+ @cur += 7
918
+ chunk.thunks.push(
919
+ ThunkLeaf.new(
920
+ :action_DIRECTIVE_SOURCE_0,
921
+ Capture.new(
922
+ chunk.pos, @cur,
923
+ ),
924
+ {},
925
+ {},
926
+ )
927
+ )
928
+ @level -= 1
929
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_SOURCE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
930
+ return chunk
931
+ end
932
+ @level -= 1
933
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_SOURCE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
934
+ return nil
935
+ end
936
+
937
+ def evaluate_rule_DIRECTIVE_LHEADER
938
+ chunk = ThunkChunk.new
939
+ chunk.pos = @cur
940
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_LHEADER #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
941
+ @level += 1
942
+ chunk.resize_captures(0)
943
+ catch(0) do
944
+ if (
945
+ refill_buffer(11) < 11 ||
946
+ @buffer[@cur, 11] != "%lateheader"
947
+ )
948
+ throw(0)
949
+ end
950
+ @cur += 11
951
+ chunk.thunks.push(
952
+ ThunkLeaf.new(
953
+ :action_DIRECTIVE_LHEADER_0,
954
+ Capture.new(
955
+ chunk.pos, @cur,
956
+ ),
957
+ {},
958
+ {},
959
+ )
960
+ )
961
+ @level -= 1
962
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_LHEADER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
963
+ return chunk
964
+ end
965
+ @level -= 1
966
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_LHEADER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
967
+ return nil
968
+ end
969
+
970
+ def evaluate_rule_DIRECTIVE_LSOURCE
971
+ chunk = ThunkChunk.new
972
+ chunk.pos = @cur
973
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_LSOURCE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
974
+ @level += 1
975
+ chunk.resize_captures(0)
976
+ catch(0) do
977
+ if (
978
+ refill_buffer(11) < 11 ||
979
+ @buffer[@cur, 11] != "%latesource"
980
+ )
981
+ throw(0)
982
+ end
983
+ @cur += 11
984
+ chunk.thunks.push(
985
+ ThunkLeaf.new(
986
+ :action_DIRECTIVE_LSOURCE_0,
987
+ Capture.new(
988
+ chunk.pos, @cur,
989
+ ),
990
+ {},
991
+ {},
992
+ )
993
+ )
994
+ @level -= 1
995
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_LSOURCE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
996
+ return chunk
997
+ end
998
+ @level -= 1
999
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_LSOURCE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1000
+ return nil
1001
+ end
1002
+
1003
+ def evaluate_rule_DIRECTIVE_HEADER
1004
+ chunk = ThunkChunk.new
1005
+ chunk.pos = @cur
1006
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_HEADER #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1007
+ @level += 1
1008
+ chunk.resize_captures(0)
1009
+ catch(0) do
1010
+ if (
1011
+ refill_buffer(7) < 7 ||
1012
+ @buffer[@cur, 7] != "%header"
1013
+ )
1014
+ throw(0)
1015
+ end
1016
+ @cur += 7
1017
+ chunk.thunks.push(
1018
+ ThunkLeaf.new(
1019
+ :action_DIRECTIVE_HEADER_0,
1020
+ Capture.new(
1021
+ chunk.pos, @cur,
1022
+ ),
1023
+ {},
1024
+ {},
1025
+ )
1026
+ )
1027
+ @level -= 1
1028
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_HEADER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1029
+ return chunk
1030
+ end
1031
+ @level -= 1
1032
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_HEADER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1033
+ return nil
1034
+ end
1035
+
1036
+ def evaluate_rule_DIRECTIVE_LOC
1037
+ chunk = ThunkChunk.new
1038
+ chunk.pos = @cur
1039
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_LOC #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1040
+ @level += 1
1041
+ chunk.resize_captures(0)
1042
+ catch(0) do
1043
+ if (
1044
+ refill_buffer(9) < 9 ||
1045
+ @buffer[@cur, 9] != "%location"
1046
+ )
1047
+ throw(0)
1048
+ end
1049
+ @cur += 9
1050
+ chunk.thunks.push(
1051
+ ThunkLeaf.new(
1052
+ :action_DIRECTIVE_LOC_0,
1053
+ Capture.new(
1054
+ chunk.pos, @cur,
1055
+ ),
1056
+ {},
1057
+ {},
1058
+ )
1059
+ )
1060
+ @level -= 1
1061
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_LOC #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1062
+ return chunk
1063
+ end
1064
+ @level -= 1
1065
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_LOC #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1066
+ return nil
1067
+ end
1068
+
1069
+ def evaluate_rule_DIRECTIVE_INIT
1070
+ chunk = ThunkChunk.new
1071
+ chunk.pos = @cur
1072
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_INIT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1073
+ @level += 1
1074
+ chunk.resize_captures(0)
1075
+ catch(0) do
1076
+ if (
1077
+ refill_buffer(11) < 11 ||
1078
+ @buffer[@cur, 11] != "%initialize"
1079
+ )
1080
+ throw(0)
1081
+ end
1082
+ @cur += 11
1083
+ chunk.thunks.push(
1084
+ ThunkLeaf.new(
1085
+ :action_DIRECTIVE_INIT_0,
1086
+ Capture.new(
1087
+ chunk.pos, @cur,
1088
+ ),
1089
+ {},
1090
+ {},
1091
+ )
1092
+ )
1093
+ @level -= 1
1094
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_INIT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1095
+ return chunk
1096
+ end
1097
+ @level -= 1
1098
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_INIT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1099
+ return nil
1100
+ end
1101
+
1102
+ def evaluate_rule_DIRECTIVE_ECOMMON
1103
+ chunk = ThunkChunk.new
1104
+ chunk.pos = @cur
1105
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_ECOMMON #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1106
+ @level += 1
1107
+ chunk.resize_captures(0)
1108
+ catch(0) do
1109
+ if (
1110
+ refill_buffer(12) < 12 ||
1111
+ @buffer[@cur, 12] != "%earlycommon"
1112
+ )
1113
+ throw(0)
1114
+ end
1115
+ @cur += 12
1116
+ chunk.thunks.push(
1117
+ ThunkLeaf.new(
1118
+ :action_DIRECTIVE_ECOMMON_0,
1119
+ Capture.new(
1120
+ chunk.pos, @cur,
1121
+ ),
1122
+ {},
1123
+ {},
1124
+ )
1125
+ )
1126
+ @level -= 1
1127
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_ECOMMON #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1128
+ return chunk
1129
+ end
1130
+ @level -= 1
1131
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_ECOMMON #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1132
+ return nil
1133
+ end
1134
+
1135
+ def evaluate_rule_DIRECTIVE_COMMON
1136
+ chunk = ThunkChunk.new
1137
+ chunk.pos = @cur
1138
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_COMMON #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1139
+ @level += 1
1140
+ chunk.resize_captures(0)
1141
+ catch(0) do
1142
+ if (
1143
+ refill_buffer(7) < 7 ||
1144
+ @buffer[@cur, 7] != "%common"
1145
+ )
1146
+ throw(0)
1147
+ end
1148
+ @cur += 7
1149
+ chunk.thunks.push(
1150
+ ThunkLeaf.new(
1151
+ :action_DIRECTIVE_COMMON_0,
1152
+ Capture.new(
1153
+ chunk.pos, @cur,
1154
+ ),
1155
+ {},
1156
+ {},
1157
+ )
1158
+ )
1159
+ @level -= 1
1160
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_COMMON #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1161
+ return chunk
1162
+ end
1163
+ @level -= 1
1164
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_COMMON #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1165
+ return nil
1166
+ end
1167
+
1168
+ def evaluate_rule_DIRECTIVE_VALUE
1169
+ chunk = ThunkChunk.new
1170
+ chunk.pos = @cur
1171
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_VALUE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1172
+ @level += 1
1173
+ chunk.resize_captures(0)
1174
+ catch(0) do
1175
+ if (
1176
+ refill_buffer(6) < 6 ||
1177
+ @buffer[@cur, 6] != "%value"
1178
+ )
1179
+ throw(0)
1180
+ end
1181
+ @cur += 6
1182
+ chunk.thunks.push(
1183
+ ThunkLeaf.new(
1184
+ :action_DIRECTIVE_VALUE_0,
1185
+ Capture.new(
1186
+ chunk.pos, @cur,
1187
+ ),
1188
+ {},
1189
+ {},
1190
+ )
1191
+ )
1192
+ @level -= 1
1193
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_VALUE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1194
+ return chunk
1195
+ end
1196
+ @level -= 1
1197
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_VALUE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1198
+ return nil
1199
+ end
1200
+
1201
+ def evaluate_rule_DIRECTIVE_AUXIL
1202
+ chunk = ThunkChunk.new
1203
+ chunk.pos = @cur
1204
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_AUXIL #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1205
+ @level += 1
1206
+ chunk.resize_captures(0)
1207
+ catch(0) do
1208
+ if (
1209
+ refill_buffer(6) < 6 ||
1210
+ @buffer[@cur, 6] != "%auxil"
1211
+ )
1212
+ throw(0)
1213
+ end
1214
+ @cur += 6
1215
+ chunk.thunks.push(
1216
+ ThunkLeaf.new(
1217
+ :action_DIRECTIVE_AUXIL_0,
1218
+ Capture.new(
1219
+ chunk.pos, @cur,
1220
+ ),
1221
+ {},
1222
+ {},
1223
+ )
1224
+ )
1225
+ @level -= 1
1226
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_AUXIL #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1227
+ return chunk
1228
+ end
1229
+ @level -= 1
1230
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_AUXIL #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1231
+ return nil
1232
+ end
1233
+
1234
+ def evaluate_rule_DIRECTIVE_PREFIX
1235
+ chunk = ThunkChunk.new
1236
+ chunk.pos = @cur
1237
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_PREFIX #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1238
+ @level += 1
1239
+ chunk.resize_captures(0)
1240
+ catch(0) do
1241
+ if (
1242
+ refill_buffer(7) < 7 ||
1243
+ @buffer[@cur, 7] != "%prefix"
1244
+ )
1245
+ throw(0)
1246
+ end
1247
+ @cur += 7
1248
+ chunk.thunks.push(
1249
+ ThunkLeaf.new(
1250
+ :action_DIRECTIVE_PREFIX_0,
1251
+ Capture.new(
1252
+ chunk.pos, @cur,
1253
+ ),
1254
+ {},
1255
+ {},
1256
+ )
1257
+ )
1258
+ @level -= 1
1259
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_PREFIX #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1260
+ return chunk
1261
+ end
1262
+ @level -= 1
1263
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_PREFIX #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1264
+ return nil
1265
+ end
1266
+
1267
+ def evaluate_rule_DIRECTIVE_CAPT
1268
+ chunk = ThunkChunk.new
1269
+ chunk.pos = @cur
1270
+ debug { warn "#{ " " * @level}EVAL DIRECTIVE_CAPT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1271
+ @level += 1
1272
+ chunk.resize_captures(0)
1273
+ catch(0) do
1274
+ if (
1275
+ refill_buffer(8) < 8 ||
1276
+ @buffer[@cur, 8] != "%capture"
1277
+ )
1278
+ throw(0)
1279
+ end
1280
+ @cur += 8
1281
+ chunk.thunks.push(
1282
+ ThunkLeaf.new(
1283
+ :action_DIRECTIVE_CAPT_0,
1284
+ Capture.new(
1285
+ chunk.pos, @cur,
1286
+ ),
1287
+ {},
1288
+ {},
1289
+ )
1290
+ )
1291
+ @level -= 1
1292
+ debug { warn "#{ " " * @level}MATCH DIRECTIVE_CAPT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1293
+ return chunk
1294
+ end
1295
+ @level -= 1
1296
+ debug { warn "#{ " " * @level}NOMATCH DIRECTIVE_CAPT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1297
+ return nil
1298
+ end
1299
+
1300
+ def evaluate_rule_LARROW
1301
+ chunk = ThunkChunk.new
1302
+ chunk.pos = @cur
1303
+ debug { warn "#{ " " * @level}EVAL LARROW #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1304
+ @level += 1
1305
+ chunk.resize_captures(0)
1306
+ catch(0) do
1307
+ if (
1308
+ refill_buffer(2) < 2 ||
1309
+ @buffer[@cur, 2] != "<-"
1310
+ )
1311
+ throw(0)
1312
+ end
1313
+ @cur += 2
1314
+ chunk.thunks.push(
1315
+ ThunkLeaf.new(
1316
+ :action_LARROW_0,
1317
+ Capture.new(
1318
+ chunk.pos, @cur,
1319
+ ),
1320
+ {},
1321
+ {},
1322
+ )
1323
+ )
1324
+ @level -= 1
1325
+ debug { warn "#{ " " * @level}MATCH LARROW #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1326
+ return chunk
1327
+ end
1328
+ @level -= 1
1329
+ debug { warn "#{ " " * @level}NOMATCH LARROW #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1330
+ return nil
1331
+ end
1332
+
1333
+ def evaluate_rule_RARROW
1334
+ chunk = ThunkChunk.new
1335
+ chunk.pos = @cur
1336
+ debug { warn "#{ " " * @level}EVAL RARROW #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1337
+ @level += 1
1338
+ chunk.resize_captures(0)
1339
+ catch(0) do
1340
+ if (
1341
+ refill_buffer(2) < 2 ||
1342
+ @buffer[@cur, 2] != "->"
1343
+ )
1344
+ throw(0)
1345
+ end
1346
+ @cur += 2
1347
+ chunk.thunks.push(
1348
+ ThunkLeaf.new(
1349
+ :action_RARROW_0,
1350
+ Capture.new(
1351
+ chunk.pos, @cur,
1352
+ ),
1353
+ {},
1354
+ {},
1355
+ )
1356
+ )
1357
+ @level -= 1
1358
+ debug { warn "#{ " " * @level}MATCH RARROW #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1359
+ return chunk
1360
+ end
1361
+ @level -= 1
1362
+ debug { warn "#{ " " * @level}NOMATCH RARROW #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1363
+ return nil
1364
+ end
1365
+
1366
+ def evaluate_rule_SLASH
1367
+ chunk = ThunkChunk.new
1368
+ chunk.pos = @cur
1369
+ debug { warn "#{ " " * @level}EVAL SLASH #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1370
+ @level += 1
1371
+ chunk.resize_captures(0)
1372
+ catch(0) do
1373
+ if (
1374
+ refill_buffer(1) < 1 ||
1375
+ @buffer[@cur] != "/"
1376
+ )
1377
+ throw(0)
1378
+ end
1379
+ @cur += 1
1380
+ chunk.thunks.push(
1381
+ ThunkLeaf.new(
1382
+ :action_SLASH_0,
1383
+ Capture.new(
1384
+ chunk.pos, @cur,
1385
+ ),
1386
+ {},
1387
+ {},
1388
+ )
1389
+ )
1390
+ @level -= 1
1391
+ debug { warn "#{ " " * @level}MATCH SLASH #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1392
+ return chunk
1393
+ end
1394
+ @level -= 1
1395
+ debug { warn "#{ " " * @level}NOMATCH SLASH #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1396
+ return nil
1397
+ end
1398
+
1399
+ def evaluate_rule_CUT
1400
+ chunk = ThunkChunk.new
1401
+ chunk.pos = @cur
1402
+ debug { warn "#{ " " * @level}EVAL CUT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1403
+ @level += 1
1404
+ chunk.resize_captures(0)
1405
+ catch(0) do
1406
+ if (
1407
+ refill_buffer(2) < 2 ||
1408
+ @buffer[@cur, 2] != "8<"
1409
+ )
1410
+ throw(0)
1411
+ end
1412
+ @cur += 2
1413
+ chunk.thunks.push(
1414
+ ThunkLeaf.new(
1415
+ :action_CUT_0,
1416
+ Capture.new(
1417
+ chunk.pos, @cur,
1418
+ ),
1419
+ {},
1420
+ {},
1421
+ )
1422
+ )
1423
+ @level -= 1
1424
+ debug { warn "#{ " " * @level}MATCH CUT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1425
+ return chunk
1426
+ end
1427
+ @level -= 1
1428
+ debug { warn "#{ " " * @level}NOMATCH CUT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1429
+ return nil
1430
+ end
1431
+
1432
+ def evaluate_rule_ERROR
1433
+ chunk = ThunkChunk.new
1434
+ chunk.pos = @cur
1435
+ debug { warn "#{ " " * @level}EVAL ERROR #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1436
+ @level += 1
1437
+ chunk.resize_captures(0)
1438
+ catch(0) do
1439
+ if (
1440
+ refill_buffer(1) < 1 ||
1441
+ @buffer[@cur] != "~"
1442
+ )
1443
+ throw(0)
1444
+ end
1445
+ @cur += 1
1446
+ chunk.thunks.push(
1447
+ ThunkLeaf.new(
1448
+ :action_ERROR_0,
1449
+ Capture.new(
1450
+ chunk.pos, @cur,
1451
+ ),
1452
+ {},
1453
+ {},
1454
+ )
1455
+ )
1456
+ @level -= 1
1457
+ debug { warn "#{ " " * @level}MATCH ERROR #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1458
+ return chunk
1459
+ end
1460
+ @level -= 1
1461
+ debug { warn "#{ " " * @level}NOMATCH ERROR #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1462
+ return nil
1463
+ end
1464
+
1465
+ def evaluate_rule_AND
1466
+ chunk = ThunkChunk.new
1467
+ chunk.pos = @cur
1468
+ debug { warn "#{ " " * @level}EVAL AND #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1469
+ @level += 1
1470
+ chunk.resize_captures(0)
1471
+ catch(0) do
1472
+ if (
1473
+ refill_buffer(1) < 1 ||
1474
+ @buffer[@cur] != "&"
1475
+ )
1476
+ throw(0)
1477
+ end
1478
+ @cur += 1
1479
+ chunk.thunks.push(
1480
+ ThunkLeaf.new(
1481
+ :action_AND_0,
1482
+ Capture.new(
1483
+ chunk.pos, @cur,
1484
+ ),
1485
+ {},
1486
+ {},
1487
+ )
1488
+ )
1489
+ @level -= 1
1490
+ debug { warn "#{ " " * @level}MATCH AND #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1491
+ return chunk
1492
+ end
1493
+ @level -= 1
1494
+ debug { warn "#{ " " * @level}NOMATCH AND #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1495
+ return nil
1496
+ end
1497
+
1498
+ def evaluate_rule_BANG
1499
+ chunk = ThunkChunk.new
1500
+ chunk.pos = @cur
1501
+ debug { warn "#{ " " * @level}EVAL BANG #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1502
+ @level += 1
1503
+ chunk.resize_captures(0)
1504
+ catch(0) do
1505
+ if (
1506
+ refill_buffer(1) < 1 ||
1507
+ @buffer[@cur] != "!"
1508
+ )
1509
+ throw(0)
1510
+ end
1511
+ @cur += 1
1512
+ chunk.thunks.push(
1513
+ ThunkLeaf.new(
1514
+ :action_BANG_0,
1515
+ Capture.new(
1516
+ chunk.pos, @cur,
1517
+ ),
1518
+ {},
1519
+ {},
1520
+ )
1521
+ )
1522
+ @level -= 1
1523
+ debug { warn "#{ " " * @level}MATCH BANG #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1524
+ return chunk
1525
+ end
1526
+ @level -= 1
1527
+ debug { warn "#{ " " * @level}NOMATCH BANG #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1528
+ return nil
1529
+ end
1530
+
1531
+ def evaluate_rule_MULT
1532
+ chunk = ThunkChunk.new
1533
+ chunk.pos = @cur
1534
+ debug { warn "#{ " " * @level}EVAL MULT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1535
+ @level += 1
1536
+ chunk.resize_captures(0)
1537
+ catch(0) do
1538
+ if (
1539
+ refill_buffer(1) < 1 ||
1540
+ @buffer[@cur] != "*"
1541
+ )
1542
+ throw(0)
1543
+ end
1544
+ @cur += 1
1545
+ chunk.thunks.push(
1546
+ ThunkLeaf.new(
1547
+ :action_MULT_0,
1548
+ Capture.new(
1549
+ chunk.pos, @cur,
1550
+ ),
1551
+ {},
1552
+ {},
1553
+ )
1554
+ )
1555
+ @level -= 1
1556
+ debug { warn "#{ " " * @level}MATCH MULT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1557
+ return chunk
1558
+ end
1559
+ @level -= 1
1560
+ debug { warn "#{ " " * @level}NOMATCH MULT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1561
+ return nil
1562
+ end
1563
+
1564
+ def evaluate_rule_PLUS
1565
+ chunk = ThunkChunk.new
1566
+ chunk.pos = @cur
1567
+ debug { warn "#{ " " * @level}EVAL PLUS #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1568
+ @level += 1
1569
+ chunk.resize_captures(0)
1570
+ catch(0) do
1571
+ if (
1572
+ refill_buffer(1) < 1 ||
1573
+ @buffer[@cur] != "+"
1574
+ )
1575
+ throw(0)
1576
+ end
1577
+ @cur += 1
1578
+ chunk.thunks.push(
1579
+ ThunkLeaf.new(
1580
+ :action_PLUS_0,
1581
+ Capture.new(
1582
+ chunk.pos, @cur,
1583
+ ),
1584
+ {},
1585
+ {},
1586
+ )
1587
+ )
1588
+ @level -= 1
1589
+ debug { warn "#{ " " * @level}MATCH PLUS #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1590
+ return chunk
1591
+ end
1592
+ @level -= 1
1593
+ debug { warn "#{ " " * @level}NOMATCH PLUS #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1594
+ return nil
1595
+ end
1596
+
1597
+ def evaluate_rule_QUESTION
1598
+ chunk = ThunkChunk.new
1599
+ chunk.pos = @cur
1600
+ debug { warn "#{ " " * @level}EVAL QUESTION #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1601
+ @level += 1
1602
+ chunk.resize_captures(0)
1603
+ catch(0) do
1604
+ if (
1605
+ refill_buffer(1) < 1 ||
1606
+ @buffer[@cur] != "?"
1607
+ )
1608
+ throw(0)
1609
+ end
1610
+ @cur += 1
1611
+ chunk.thunks.push(
1612
+ ThunkLeaf.new(
1613
+ :action_QUESTION_0,
1614
+ Capture.new(
1615
+ chunk.pos, @cur,
1616
+ ),
1617
+ {},
1618
+ {},
1619
+ )
1620
+ )
1621
+ @level -= 1
1622
+ debug { warn "#{ " " * @level}MATCH QUESTION #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1623
+ return chunk
1624
+ end
1625
+ @level -= 1
1626
+ debug { warn "#{ " " * @level}NOMATCH QUESTION #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1627
+ return nil
1628
+ end
1629
+
1630
+ def evaluate_rule_COLON
1631
+ chunk = ThunkChunk.new
1632
+ chunk.pos = @cur
1633
+ debug { warn "#{ " " * @level}EVAL COLON #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1634
+ @level += 1
1635
+ chunk.resize_captures(0)
1636
+ catch(0) do
1637
+ if (
1638
+ refill_buffer(1) < 1 ||
1639
+ @buffer[@cur] != ":"
1640
+ )
1641
+ throw(0)
1642
+ end
1643
+ @cur += 1
1644
+ chunk.thunks.push(
1645
+ ThunkLeaf.new(
1646
+ :action_COLON_0,
1647
+ Capture.new(
1648
+ chunk.pos, @cur,
1649
+ ),
1650
+ {},
1651
+ {},
1652
+ )
1653
+ )
1654
+ @level -= 1
1655
+ debug { warn "#{ " " * @level}MATCH COLON #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1656
+ return chunk
1657
+ end
1658
+ @level -= 1
1659
+ debug { warn "#{ " " * @level}NOMATCH COLON #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1660
+ return nil
1661
+ end
1662
+
1663
+ def evaluate_rule_DDOLLER
1664
+ chunk = ThunkChunk.new
1665
+ chunk.pos = @cur
1666
+ debug { warn "#{ " " * @level}EVAL DDOLLER #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1667
+ @level += 1
1668
+ chunk.resize_captures(0)
1669
+ catch(0) do
1670
+ if (
1671
+ refill_buffer(2) < 2 ||
1672
+ @buffer[@cur, 2] != "$$"
1673
+ )
1674
+ throw(0)
1675
+ end
1676
+ @cur += 2
1677
+ chunk.thunks.push(
1678
+ ThunkLeaf.new(
1679
+ :action_DDOLLER_0,
1680
+ Capture.new(
1681
+ chunk.pos, @cur,
1682
+ ),
1683
+ {},
1684
+ {},
1685
+ )
1686
+ )
1687
+ @level -= 1
1688
+ debug { warn "#{ " " * @level}MATCH DDOLLER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1689
+ return chunk
1690
+ end
1691
+ @level -= 1
1692
+ debug { warn "#{ " " * @level}NOMATCH DDOLLER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1693
+ return nil
1694
+ end
1695
+
1696
+ def evaluate_rule_NDOLLER
1697
+ chunk = ThunkChunk.new
1698
+ chunk.pos = @cur
1699
+ debug { warn "#{ " " * @level}EVAL NDOLLER #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1700
+ @level += 1
1701
+ chunk.resize_captures(1)
1702
+ catch(0) do
1703
+ if (
1704
+ refill_buffer(1) < 1 ||
1705
+ @buffer[@cur] != "$"
1706
+ )
1707
+ throw(0)
1708
+ end
1709
+ @cur += 1
1710
+ 1.times do |;pos, q, capt, p_loc, q_loc|
1711
+ pos = @cur
1712
+ 1.times do |;u, n|
1713
+ if refill_buffer(1) < 1
1714
+ throw(0)
1715
+ end
1716
+ u = @buffer[@cur]
1717
+ if (!(
1718
+ (u >= "1" && u <= "9")
1719
+ ))
1720
+ throw(0)
1721
+ end
1722
+ @cur += 1
1723
+ end
1724
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
1725
+ i = 0
1726
+ catch(1) do
1727
+ pos = @cur
1728
+ n = chunk.thunks.length
1729
+ 1.times do |;u, n|
1730
+ if refill_buffer(1) < 1
1731
+ throw(1)
1732
+ end
1733
+ u = @buffer[@cur]
1734
+ if (!(
1735
+ (u >= "0" && u <= "9")
1736
+ ))
1737
+ throw(1)
1738
+ end
1739
+ @cur += 1
1740
+ end
1741
+ i += 1
1742
+ if @cur != pos
1743
+ redo
1744
+ end
1745
+ pos = nil
1746
+ end
1747
+ if pos
1748
+ @cur = pos
1749
+ chunk.thunks[n..-1] = []
1750
+ end
1751
+ end
1752
+ q = @cur
1753
+ capt = chunk.capts[0]
1754
+ capt.range_start = pos
1755
+ capt.range_end = q
1756
+ end
1757
+ chunk.thunks.push(
1758
+ ThunkLeaf.new(
1759
+ :action_NDOLLER_0,
1760
+ Capture.new(
1761
+ chunk.pos, @cur,
1762
+ ),
1763
+ {},
1764
+ chunk.capts.slice(0),
1765
+ )
1766
+ )
1767
+ chunk.thunks.push(
1768
+ ThunkLeaf.new(
1769
+ :action_NDOLLER_1,
1770
+ Capture.new(
1771
+ chunk.pos, @cur,
1772
+ ),
1773
+ {},
1774
+ chunk.capts.slice(0),
1775
+ )
1776
+ )
1777
+ @level -= 1
1778
+ debug { warn "#{ " " * @level}MATCH NDOLLER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1779
+ return chunk
1780
+ end
1781
+ @level -= 1
1782
+ debug { warn "#{ " " * @level}NOMATCH NDOLLER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1783
+ return nil
1784
+ end
1785
+
1786
+ def evaluate_rule_LPAREN
1787
+ chunk = ThunkChunk.new
1788
+ chunk.pos = @cur
1789
+ debug { warn "#{ " " * @level}EVAL LPAREN #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1790
+ @level += 1
1791
+ chunk.resize_captures(0)
1792
+ catch(0) do
1793
+ if (
1794
+ refill_buffer(1) < 1 ||
1795
+ @buffer[@cur] != "("
1796
+ )
1797
+ throw(0)
1798
+ end
1799
+ @cur += 1
1800
+ chunk.thunks.push(
1801
+ ThunkLeaf.new(
1802
+ :action_LPAREN_0,
1803
+ Capture.new(
1804
+ chunk.pos, @cur,
1805
+ ),
1806
+ {},
1807
+ {},
1808
+ )
1809
+ )
1810
+ @level -= 1
1811
+ debug { warn "#{ " " * @level}MATCH LPAREN #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1812
+ return chunk
1813
+ end
1814
+ @level -= 1
1815
+ debug { warn "#{ " " * @level}NOMATCH LPAREN #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1816
+ return nil
1817
+ end
1818
+
1819
+ def evaluate_rule_RPAREN
1820
+ chunk = ThunkChunk.new
1821
+ chunk.pos = @cur
1822
+ debug { warn "#{ " " * @level}EVAL RPAREN #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1823
+ @level += 1
1824
+ chunk.resize_captures(0)
1825
+ catch(0) do
1826
+ if (
1827
+ refill_buffer(1) < 1 ||
1828
+ @buffer[@cur] != ")"
1829
+ )
1830
+ throw(0)
1831
+ end
1832
+ @cur += 1
1833
+ chunk.thunks.push(
1834
+ ThunkLeaf.new(
1835
+ :action_RPAREN_0,
1836
+ Capture.new(
1837
+ chunk.pos, @cur,
1838
+ ),
1839
+ {},
1840
+ {},
1841
+ )
1842
+ )
1843
+ @level -= 1
1844
+ debug { warn "#{ " " * @level}MATCH RPAREN #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1845
+ return chunk
1846
+ end
1847
+ @level -= 1
1848
+ debug { warn "#{ " " * @level}NOMATCH RPAREN #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1849
+ return nil
1850
+ end
1851
+
1852
+ def evaluate_rule_LT
1853
+ chunk = ThunkChunk.new
1854
+ chunk.pos = @cur
1855
+ debug { warn "#{ " " * @level}EVAL LT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1856
+ @level += 1
1857
+ chunk.resize_captures(0)
1858
+ catch(0) do
1859
+ if (
1860
+ refill_buffer(1) < 1 ||
1861
+ @buffer[@cur] != "<"
1862
+ )
1863
+ throw(0)
1864
+ end
1865
+ @cur += 1
1866
+ chunk.thunks.push(
1867
+ ThunkLeaf.new(
1868
+ :action_LT_0,
1869
+ Capture.new(
1870
+ chunk.pos, @cur,
1871
+ ),
1872
+ {},
1873
+ {},
1874
+ )
1875
+ )
1876
+ @level -= 1
1877
+ debug { warn "#{ " " * @level}MATCH LT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1878
+ return chunk
1879
+ end
1880
+ @level -= 1
1881
+ debug { warn "#{ " " * @level}NOMATCH LT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1882
+ return nil
1883
+ end
1884
+
1885
+ def evaluate_rule_GT
1886
+ chunk = ThunkChunk.new
1887
+ chunk.pos = @cur
1888
+ debug { warn "#{ " " * @level}EVAL GT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1889
+ @level += 1
1890
+ chunk.resize_captures(0)
1891
+ catch(0) do
1892
+ if (
1893
+ refill_buffer(1) < 1 ||
1894
+ @buffer[@cur] != ">"
1895
+ )
1896
+ throw(0)
1897
+ end
1898
+ @cur += 1
1899
+ chunk.thunks.push(
1900
+ ThunkLeaf.new(
1901
+ :action_GT_0,
1902
+ Capture.new(
1903
+ chunk.pos, @cur,
1904
+ ),
1905
+ {},
1906
+ {},
1907
+ )
1908
+ )
1909
+ @level -= 1
1910
+ debug { warn "#{ " " * @level}MATCH GT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1911
+ return chunk
1912
+ end
1913
+ @level -= 1
1914
+ debug { warn "#{ " " * @level}NOMATCH GT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1915
+ return nil
1916
+ end
1917
+
1918
+ def evaluate_rule_DOT
1919
+ chunk = ThunkChunk.new
1920
+ chunk.pos = @cur
1921
+ debug { warn "#{ " " * @level}EVAL DOT #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1922
+ @level += 1
1923
+ chunk.resize_captures(0)
1924
+ catch(0) do
1925
+ if (
1926
+ refill_buffer(1) < 1 ||
1927
+ @buffer[@cur] != "."
1928
+ )
1929
+ throw(0)
1930
+ end
1931
+ @cur += 1
1932
+ chunk.thunks.push(
1933
+ ThunkLeaf.new(
1934
+ :action_DOT_0,
1935
+ Capture.new(
1936
+ chunk.pos, @cur,
1937
+ ),
1938
+ {},
1939
+ {},
1940
+ )
1941
+ )
1942
+ @level -= 1
1943
+ debug { warn "#{ " " * @level}MATCH DOT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1944
+ return chunk
1945
+ end
1946
+ @level -= 1
1947
+ debug { warn "#{ " " * @level}NOMATCH DOT #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
1948
+ return nil
1949
+ end
1950
+
1951
+ def evaluate_rule_CHARCLASS
1952
+ chunk = ThunkChunk.new
1953
+ chunk.pos = @cur
1954
+ debug { warn "#{ " " * @level}EVAL CHARCLASS #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
1955
+ @level += 1
1956
+ chunk.resize_captures(1)
1957
+ catch(0) do
1958
+ if (
1959
+ refill_buffer(1) < 1 ||
1960
+ @buffer[@cur] != "["
1961
+ )
1962
+ throw(0)
1963
+ end
1964
+ @cur += 1
1965
+ 1.times do |;pos, q, capt, p_loc, q_loc|
1966
+ pos = @cur
1967
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
1968
+ i = 0
1969
+ catch(1) do
1970
+ pos = @cur
1971
+ n = chunk.thunks.length
1972
+ catch(2) do |; pos, p_loc, n|
1973
+ pos = @cur
1974
+ n = chunk.thunks.length
1975
+ 1.times do |;u, n|
1976
+ if refill_buffer(1) >= 1
1977
+ u = @buffer[@cur]
1978
+ unless (
1979
+ u == "\\" ||
1980
+ u == "[" ||
1981
+ u == "]"
1982
+ )
1983
+ @cur += 1
1984
+ throw(2)
1985
+ end
1986
+ end
1987
+ end
1988
+ @cur = pos
1989
+ chunk.thunks[n..-1] = []
1990
+ catch(3) do
1991
+ if (
1992
+ refill_buffer(2) < 2 ||
1993
+ @buffer[@cur, 2] != "\\["
1994
+ )
1995
+ throw(3)
1996
+ end
1997
+ @cur += 2
1998
+ throw(2)
1999
+ end
2000
+ @cur = pos
2001
+ chunk.thunks[n..-1] = []
2002
+ catch(4) do
2003
+ if (
2004
+ refill_buffer(2) < 2 ||
2005
+ @buffer[@cur, 2] != "\\]"
2006
+ )
2007
+ throw(4)
2008
+ end
2009
+ @cur += 2
2010
+ throw(2)
2011
+ end
2012
+ @cur = pos
2013
+ chunk.thunks[n..-1] = []
2014
+ catch(5) do
2015
+ if (
2016
+ refill_buffer(1) < 1 ||
2017
+ @buffer[@cur] != "\\"
2018
+ )
2019
+ throw(5)
2020
+ end
2021
+ @cur += 1
2022
+ throw(2)
2023
+ end
2024
+ @cur = pos
2025
+ chunk.thunks[n..-1] = []
2026
+ throw(1)
2027
+ end
2028
+ i += 1
2029
+ if @cur != pos
2030
+ redo
2031
+ end
2032
+ pos = nil
2033
+ end
2034
+ if pos
2035
+ @cur = pos
2036
+ chunk.thunks[n..-1] = []
2037
+ end
2038
+ end
2039
+ q = @cur
2040
+ capt = chunk.capts[0]
2041
+ capt.range_start = pos
2042
+ capt.range_end = q
2043
+ end
2044
+ if (
2045
+ refill_buffer(1) < 1 ||
2046
+ @buffer[@cur] != "]"
2047
+ )
2048
+ throw(0)
2049
+ end
2050
+ @cur += 1
2051
+ chunk.thunks.push(
2052
+ ThunkLeaf.new(
2053
+ :action_CHARCLASS_0,
2054
+ Capture.new(
2055
+ chunk.pos, @cur,
2056
+ ),
2057
+ {},
2058
+ chunk.capts.slice(0),
2059
+ )
2060
+ )
2061
+ chunk.thunks.push(
2062
+ ThunkLeaf.new(
2063
+ :action_CHARCLASS_1,
2064
+ Capture.new(
2065
+ chunk.pos, @cur,
2066
+ ),
2067
+ {},
2068
+ chunk.capts.slice(0),
2069
+ )
2070
+ )
2071
+ @level -= 1
2072
+ debug { warn "#{ " " * @level}MATCH CHARCLASS #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2073
+ return chunk
2074
+ end
2075
+ @level -= 1
2076
+ debug { warn "#{ " " * @level}NOMATCH CHARCLASS #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2077
+ return nil
2078
+ end
2079
+
2080
+ def evaluate_rule_QUOTATION_SINGLE
2081
+ chunk = ThunkChunk.new
2082
+ chunk.pos = @cur
2083
+ debug { warn "#{ " " * @level}EVAL QUOTATION_SINGLE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2084
+ @level += 1
2085
+ chunk.resize_captures(1)
2086
+ catch(0) do
2087
+ if (
2088
+ refill_buffer(1) < 1 ||
2089
+ @buffer[@cur] != "\'"
2090
+ )
2091
+ throw(0)
2092
+ end
2093
+ @cur += 1
2094
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2095
+ pos = @cur
2096
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
2097
+ i = 0
2098
+ catch(1) do
2099
+ pos = @cur
2100
+ n = chunk.thunks.length
2101
+ catch(2) do |; pos, p_loc, n|
2102
+ pos = @cur
2103
+ n = chunk.thunks.length
2104
+ 1.times do |;u, n|
2105
+ if refill_buffer(1) >= 1
2106
+ u = @buffer[@cur]
2107
+ unless (
2108
+ u == "\\" ||
2109
+ u == "'" ||
2110
+ u == "\n"
2111
+ )
2112
+ @cur += 1
2113
+ throw(2)
2114
+ end
2115
+ end
2116
+ end
2117
+ @cur = pos
2118
+ chunk.thunks[n..-1] = []
2119
+ catch(3) do
2120
+ if (
2121
+ refill_buffer(2) < 2 ||
2122
+ @buffer[@cur, 2] != "\\'"
2123
+ )
2124
+ throw(3)
2125
+ end
2126
+ @cur += 2
2127
+ throw(2)
2128
+ end
2129
+ @cur = pos
2130
+ chunk.thunks[n..-1] = []
2131
+ catch(4) do
2132
+ if (
2133
+ refill_buffer(2) < 2 ||
2134
+ @buffer[@cur, 2] != "\\\n"
2135
+ )
2136
+ throw(4)
2137
+ end
2138
+ @cur += 2
2139
+ throw(2)
2140
+ end
2141
+ @cur = pos
2142
+ chunk.thunks[n..-1] = []
2143
+ catch(5) do
2144
+ if (
2145
+ refill_buffer(1) < 1 ||
2146
+ @buffer[@cur] != "\\"
2147
+ )
2148
+ throw(5)
2149
+ end
2150
+ @cur += 1
2151
+ 1.times do |;u, n|
2152
+ if refill_buffer(1) < 1
2153
+ throw(5)
2154
+ end
2155
+ u = @buffer[@cur]
2156
+ if (
2157
+ u == "'" ||
2158
+ u == "\n"
2159
+ )
2160
+ throw(5)
2161
+ end
2162
+ @cur += 1
2163
+ end
2164
+ throw(2)
2165
+ end
2166
+ @cur = pos
2167
+ chunk.thunks[n..-1] = []
2168
+ throw(1)
2169
+ end
2170
+ i += 1
2171
+ if @cur != pos
2172
+ redo
2173
+ end
2174
+ pos = nil
2175
+ end
2176
+ if pos
2177
+ @cur = pos
2178
+ chunk.thunks[n..-1] = []
2179
+ end
2180
+ end
2181
+ q = @cur
2182
+ capt = chunk.capts[0]
2183
+ capt.range_start = pos
2184
+ capt.range_end = q
2185
+ end
2186
+ if (
2187
+ refill_buffer(1) < 1 ||
2188
+ @buffer[@cur] != "\'"
2189
+ )
2190
+ throw(0)
2191
+ end
2192
+ @cur += 1
2193
+ chunk.thunks.push(
2194
+ ThunkLeaf.new(
2195
+ :action_QUOTATION_SINGLE_0,
2196
+ Capture.new(
2197
+ chunk.pos, @cur,
2198
+ ),
2199
+ {},
2200
+ chunk.capts.slice(0),
2201
+ )
2202
+ )
2203
+ chunk.thunks.push(
2204
+ ThunkLeaf.new(
2205
+ :action_QUOTATION_SINGLE_1,
2206
+ Capture.new(
2207
+ chunk.pos, @cur,
2208
+ ),
2209
+ {},
2210
+ chunk.capts.slice(0),
2211
+ )
2212
+ )
2213
+ @level -= 1
2214
+ debug { warn "#{ " " * @level}MATCH QUOTATION_SINGLE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2215
+ return chunk
2216
+ end
2217
+ @level -= 1
2218
+ debug { warn "#{ " " * @level}NOMATCH QUOTATION_SINGLE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2219
+ return nil
2220
+ end
2221
+
2222
+ def evaluate_rule_QUOTATION_DOUBLE
2223
+ chunk = ThunkChunk.new
2224
+ chunk.pos = @cur
2225
+ debug { warn "#{ " " * @level}EVAL QUOTATION_DOUBLE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2226
+ @level += 1
2227
+ chunk.resize_captures(1)
2228
+ catch(0) do
2229
+ if (
2230
+ refill_buffer(1) < 1 ||
2231
+ @buffer[@cur] != "\""
2232
+ )
2233
+ throw(0)
2234
+ end
2235
+ @cur += 1
2236
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2237
+ pos = @cur
2238
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
2239
+ i = 0
2240
+ catch(1) do
2241
+ pos = @cur
2242
+ n = chunk.thunks.length
2243
+ catch(2) do |; pos, p_loc, n|
2244
+ pos = @cur
2245
+ n = chunk.thunks.length
2246
+ 1.times do |;u, n|
2247
+ if refill_buffer(1) >= 1
2248
+ u = @buffer[@cur]
2249
+ unless (
2250
+ u == "\\" ||
2251
+ u == "\"" ||
2252
+ u == "\n"
2253
+ )
2254
+ @cur += 1
2255
+ throw(2)
2256
+ end
2257
+ end
2258
+ end
2259
+ @cur = pos
2260
+ chunk.thunks[n..-1] = []
2261
+ catch(3) do
2262
+ if (
2263
+ refill_buffer(2) < 2 ||
2264
+ @buffer[@cur, 2] != "\\\""
2265
+ )
2266
+ throw(3)
2267
+ end
2268
+ @cur += 2
2269
+ throw(2)
2270
+ end
2271
+ @cur = pos
2272
+ chunk.thunks[n..-1] = []
2273
+ catch(4) do
2274
+ if (
2275
+ refill_buffer(2) < 2 ||
2276
+ @buffer[@cur, 2] != "\\\n"
2277
+ )
2278
+ throw(4)
2279
+ end
2280
+ @cur += 2
2281
+ throw(2)
2282
+ end
2283
+ @cur = pos
2284
+ chunk.thunks[n..-1] = []
2285
+ catch(5) do
2286
+ if (
2287
+ refill_buffer(1) < 1 ||
2288
+ @buffer[@cur] != "\\"
2289
+ )
2290
+ throw(5)
2291
+ end
2292
+ @cur += 1
2293
+ 1.times do |;u, n|
2294
+ if refill_buffer(1) < 1
2295
+ throw(5)
2296
+ end
2297
+ u = @buffer[@cur]
2298
+ if (
2299
+ u == "\"" ||
2300
+ u == "\n"
2301
+ )
2302
+ throw(5)
2303
+ end
2304
+ @cur += 1
2305
+ end
2306
+ throw(2)
2307
+ end
2308
+ @cur = pos
2309
+ chunk.thunks[n..-1] = []
2310
+ throw(1)
2311
+ end
2312
+ i += 1
2313
+ if @cur != pos
2314
+ redo
2315
+ end
2316
+ pos = nil
2317
+ end
2318
+ if pos
2319
+ @cur = pos
2320
+ chunk.thunks[n..-1] = []
2321
+ end
2322
+ end
2323
+ q = @cur
2324
+ capt = chunk.capts[0]
2325
+ capt.range_start = pos
2326
+ capt.range_end = q
2327
+ end
2328
+ if (
2329
+ refill_buffer(1) < 1 ||
2330
+ @buffer[@cur] != "\""
2331
+ )
2332
+ throw(0)
2333
+ end
2334
+ @cur += 1
2335
+ chunk.thunks.push(
2336
+ ThunkLeaf.new(
2337
+ :action_QUOTATION_DOUBLE_0,
2338
+ Capture.new(
2339
+ chunk.pos, @cur,
2340
+ ),
2341
+ {},
2342
+ chunk.capts.slice(0),
2343
+ )
2344
+ )
2345
+ chunk.thunks.push(
2346
+ ThunkLeaf.new(
2347
+ :action_QUOTATION_DOUBLE_1,
2348
+ Capture.new(
2349
+ chunk.pos, @cur,
2350
+ ),
2351
+ {},
2352
+ chunk.capts.slice(0),
2353
+ )
2354
+ )
2355
+ @level -= 1
2356
+ debug { warn "#{ " " * @level}MATCH QUOTATION_DOUBLE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2357
+ return chunk
2358
+ end
2359
+ @level -= 1
2360
+ debug { warn "#{ " " * @level}NOMATCH QUOTATION_DOUBLE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2361
+ return nil
2362
+ end
2363
+
2364
+ def evaluate_rule_FOOTER
2365
+ chunk = ThunkChunk.new
2366
+ chunk.pos = @cur
2367
+ debug { warn "#{ " " * @level}EVAL FOOTER #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2368
+ @level += 1
2369
+ chunk.resize_captures(1)
2370
+ catch(0) do
2371
+ if (
2372
+ refill_buffer(2) < 2 ||
2373
+ @buffer[@cur, 2] != "%%"
2374
+ )
2375
+ throw(0)
2376
+ end
2377
+ @cur += 2
2378
+ catch(1) do |; pos, p_loc, n|
2379
+ pos = @cur
2380
+ n = chunk.thunks.length
2381
+ catch(2) do
2382
+ 1.times do |;pos, p_loc, n|
2383
+ pos = @cur
2384
+ n = chunk.thunks.length
2385
+ catch(4) do
2386
+ catch(3) do
2387
+ if (
2388
+ refill_buffer(1) < 1 ||
2389
+ @buffer[@cur] != "\r"
2390
+ )
2391
+ throw(3)
2392
+ end
2393
+ @cur += 1
2394
+ throw(4)
2395
+ end
2396
+ @cur = pos
2397
+ chunk.thunks[n..-1] = []
2398
+ end
2399
+ end
2400
+ if (
2401
+ refill_buffer(1) < 1 ||
2402
+ @buffer[@cur] != "\n"
2403
+ )
2404
+ throw(2)
2405
+ end
2406
+ @cur += 1
2407
+ throw(1)
2408
+ end
2409
+ @cur = pos
2410
+ chunk.thunks[n..-1] = []
2411
+ if apply_rule(:evaluate_rule_EOF, chunk.thunks, nil, 0)
2412
+ throw(1)
2413
+ end
2414
+ @cur = pos
2415
+ chunk.thunks[n..-1] = []
2416
+ throw(0)
2417
+ end
2418
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2419
+ pos = @cur
2420
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
2421
+ i = 0
2422
+ catch(5) do
2423
+ pos = @cur
2424
+ n = chunk.thunks.length
2425
+ 1.times do |;u, n|
2426
+ if refill_buffer(1) < 1
2427
+ throw(5)
2428
+ end
2429
+ u = @buffer[@cur]
2430
+ @cur += 1
2431
+ end
2432
+ i += 1
2433
+ if @cur != pos
2434
+ redo
2435
+ end
2436
+ pos = nil
2437
+ end
2438
+ if pos
2439
+ @cur = pos
2440
+ chunk.thunks[n..-1] = []
2441
+ end
2442
+ end
2443
+ q = @cur
2444
+ capt = chunk.capts[0]
2445
+ capt.range_start = pos
2446
+ capt.range_end = q
2447
+ end
2448
+ chunk.thunks.push(
2449
+ ThunkLeaf.new(
2450
+ :action_FOOTER_0,
2451
+ Capture.new(
2452
+ chunk.pos, @cur,
2453
+ ),
2454
+ {},
2455
+ chunk.capts.slice(0),
2456
+ )
2457
+ )
2458
+ @level -= 1
2459
+ debug { warn "#{ " " * @level}MATCH FOOTER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2460
+ return chunk
2461
+ end
2462
+ @level -= 1
2463
+ debug { warn "#{ " " * @level}NOMATCH FOOTER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2464
+ return nil
2465
+ end
2466
+
2467
+ def evaluate_rule_IDENTIFIER
2468
+ chunk = ThunkChunk.new
2469
+ chunk.pos = @cur
2470
+ debug { warn "#{ " " * @level}EVAL IDENTIFIER #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2471
+ @level += 1
2472
+ chunk.resize_captures(1)
2473
+ catch(0) do
2474
+ 1.times do |;pos, q, capt, p_loc, q_loc|
2475
+ pos = @cur
2476
+ 1.times do |;u, n|
2477
+ if refill_buffer(1) < 1
2478
+ throw(0)
2479
+ end
2480
+ u = @buffer[@cur]
2481
+ if (!(
2482
+ (u >= "a" && u <= "z") ||
2483
+ (u >= "A" && u <= "Z") ||
2484
+ u == "_"
2485
+ ))
2486
+ throw(0)
2487
+ end
2488
+ @cur += 1
2489
+ end
2490
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
2491
+ i = 0
2492
+ catch(1) do
2493
+ pos = @cur
2494
+ n = chunk.thunks.length
2495
+ 1.times do |;u, n|
2496
+ if refill_buffer(1) < 1
2497
+ throw(1)
2498
+ end
2499
+ u = @buffer[@cur]
2500
+ if (!(
2501
+ (u >= "a" && u <= "z") ||
2502
+ (u >= "A" && u <= "Z") ||
2503
+ u == "_" ||
2504
+ (u >= "0" && u <= "9")
2505
+ ))
2506
+ throw(1)
2507
+ end
2508
+ @cur += 1
2509
+ end
2510
+ i += 1
2511
+ if @cur != pos
2512
+ redo
2513
+ end
2514
+ pos = nil
2515
+ end
2516
+ if pos
2517
+ @cur = pos
2518
+ chunk.thunks[n..-1] = []
2519
+ end
2520
+ end
2521
+ q = @cur
2522
+ capt = chunk.capts[0]
2523
+ capt.range_start = pos
2524
+ capt.range_end = q
2525
+ end
2526
+ chunk.thunks.push(
2527
+ ThunkLeaf.new(
2528
+ :action_IDENTIFIER_0,
2529
+ Capture.new(
2530
+ chunk.pos, @cur,
2531
+ ),
2532
+ {},
2533
+ chunk.capts.slice(0),
2534
+ )
2535
+ )
2536
+ chunk.thunks.push(
2537
+ ThunkLeaf.new(
2538
+ :action_IDENTIFIER_1,
2539
+ Capture.new(
2540
+ chunk.pos, @cur,
2541
+ ),
2542
+ {},
2543
+ chunk.capts.slice(0),
2544
+ )
2545
+ )
2546
+ @level -= 1
2547
+ debug { warn "#{ " " * @level}MATCH IDENTIFIER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2548
+ return chunk
2549
+ end
2550
+ @level -= 1
2551
+ debug { warn "#{ " " * @level}NOMATCH IDENTIFIER #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2552
+ return nil
2553
+ end
2554
+
2555
+ def evaluate_rule_SPACES
2556
+ chunk = ThunkChunk.new
2557
+ chunk.pos = @cur
2558
+ debug { warn "#{ " " * @level}EVAL SPACES #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2559
+ @level += 1
2560
+ chunk.resize_captures(0)
2561
+ catch(0) do
2562
+ 1.times do |;p0, p0_loc, n0, i, pos, p_loc, n, stat|
2563
+ p0 = @cur
2564
+ n0 = chunk.thunks.length
2565
+ i = 0
2566
+ catch(1) do
2567
+ pos = @cur
2568
+ n = chunk.thunks.length
2569
+ 1.times do |;u, n|
2570
+ if refill_buffer(1) < 1
2571
+ throw(1)
2572
+ end
2573
+ u = @buffer[@cur]
2574
+ if (!(
2575
+ u == " " ||
2576
+ u == "\t" ||
2577
+ u == "\v" ||
2578
+ u == "\f" ||
2579
+ u == "\r" ||
2580
+ u == "\n"
2581
+ ))
2582
+ throw(1)
2583
+ end
2584
+ @cur += 1
2585
+ end
2586
+ i += 1
2587
+ if @cur != pos
2588
+ redo
2589
+ end
2590
+ pos = nil
2591
+ end
2592
+ if pos
2593
+ @cur = pos
2594
+ chunk.thunks[n..-1] = []
2595
+ end
2596
+ if i < 1
2597
+ @cur = p0
2598
+ chunk.thunks[n0..-1] = []
2599
+ throw(0)
2600
+ end
2601
+ end
2602
+ chunk.thunks.push(
2603
+ ThunkLeaf.new(
2604
+ :action_SPACES_0,
2605
+ Capture.new(
2606
+ chunk.pos, @cur,
2607
+ ),
2608
+ {},
2609
+ {},
2610
+ )
2611
+ )
2612
+ @level -= 1
2613
+ debug { warn "#{ " " * @level}MATCH SPACES #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2614
+ return chunk
2615
+ end
2616
+ @level -= 1
2617
+ debug { warn "#{ " " * @level}NOMATCH SPACES #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2618
+ return nil
2619
+ end
2620
+
2621
+ def evaluate_rule_LBRACE
2622
+ chunk = ThunkChunk.new
2623
+ chunk.pos = @cur
2624
+ debug { warn "#{ " " * @level}EVAL LBRACE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2625
+ @level += 1
2626
+ chunk.resize_captures(0)
2627
+ catch(0) do
2628
+ if (
2629
+ refill_buffer(1) < 1 ||
2630
+ @buffer[@cur] != "{"
2631
+ )
2632
+ throw(0)
2633
+ end
2634
+ @cur += 1
2635
+ chunk.thunks.push(
2636
+ ThunkLeaf.new(
2637
+ :action_LBRACE_0,
2638
+ Capture.new(
2639
+ chunk.pos, @cur,
2640
+ ),
2641
+ {},
2642
+ {},
2643
+ )
2644
+ )
2645
+ @level -= 1
2646
+ debug { warn "#{ " " * @level}MATCH LBRACE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2647
+ return chunk
2648
+ end
2649
+ @level -= 1
2650
+ debug { warn "#{ " " * @level}NOMATCH LBRACE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2651
+ return nil
2652
+ end
2653
+
2654
+ def evaluate_rule_RBRACE
2655
+ chunk = ThunkChunk.new
2656
+ chunk.pos = @cur
2657
+ debug { warn "#{ " " * @level}EVAL RBRACE #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2658
+ @level += 1
2659
+ chunk.resize_captures(0)
2660
+ catch(0) do
2661
+ if (
2662
+ refill_buffer(1) < 1 ||
2663
+ @buffer[@cur] != "}"
2664
+ )
2665
+ throw(0)
2666
+ end
2667
+ @cur += 1
2668
+ chunk.thunks.push(
2669
+ ThunkLeaf.new(
2670
+ :action_RBRACE_0,
2671
+ Capture.new(
2672
+ chunk.pos, @cur,
2673
+ ),
2674
+ {},
2675
+ {},
2676
+ )
2677
+ )
2678
+ @level -= 1
2679
+ debug { warn "#{ " " * @level}MATCH RBRACE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2680
+ return chunk
2681
+ end
2682
+ @level -= 1
2683
+ debug { warn "#{ " " * @level}NOMATCH RBRACE #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2684
+ return nil
2685
+ end
2686
+
2687
+ def evaluate_rule_EOF
2688
+ chunk = ThunkChunk.new
2689
+ chunk.pos = @cur
2690
+ debug { warn "#{ " " * @level}EVAL EOF #{chunk.pos} #{@buffer[chunk.pos..-1].inspect}" }
2691
+ @level += 1
2692
+ chunk.resize_captures(0)
2693
+ catch(0) do
2694
+ if refill_buffer(1) >= 1
2695
+ throw(0)
2696
+ end
2697
+ @level -= 1
2698
+ debug { warn "#{ " " * @level}MATCH EOF #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2699
+ return chunk
2700
+ end
2701
+ @level -= 1
2702
+ debug { warn "#{ " " * @level}NOMATCH EOF #{chunk.pos} #{@buffer[chunk.pos...@cur].inspect}" }
2703
+ return nil
2704
+ end
2705
+
2706
+
2707
+ def rule_chunk(rule, thunks, values, index)
2708
+ pos = @pos + @cur
2709
+ answer = @lrtable.answers[pos, rule]
2710
+ head = @lrtable.heads[pos]
2711
+
2712
+ if head
2713
+ if !answer && rule != head.rule_name && !head.invol[rule]
2714
+ return nil
2715
+ end
2716
+ if head.eval.delete(rule)
2717
+ return public_send(rule)
2718
+ end
2719
+ end
2720
+
2721
+ if answer
2722
+ @cur = answer.pos - @pos
2723
+ if !answer.lr
2724
+ return answer.chunk
2725
+ end
2726
+ answer.lr.head ||= LrHead.new(rule)
2727
+ @lrstack.reverse_each do |lrentry|
2728
+ answer_head = answer.lr.head
2729
+ if lrentry.head == answer_head
2730
+ break
2731
+ end
2732
+ lrentry.head = answer_head
2733
+ answer_head.invol[lrentry.rule] = true
2734
+ end
2735
+ return answer.lr.seed
2736
+ end
2737
+
2738
+ lr = LrEntry.new
2739
+ lr.rule = rule
2740
+ @lrstack.push(lr)
2741
+ answer = LrAnswer.new(lr, pos)
2742
+ @lrtable.answers[pos, rule] = answer
2743
+ chunk = public_send(rule)
2744
+ @lrstack.pop
2745
+ answer.pos = @pos + @cur
2746
+ if !lr.head
2747
+ answer.chunk = chunk
2748
+ return chunk
2749
+ end
2750
+
2751
+ lr.seed = chunk
2752
+ head = lr.head
2753
+ if head.rule_name != rule
2754
+ return chunk
2755
+ end
2756
+
2757
+ answer.chunk = chunk
2758
+ if !chunk
2759
+ return nil
2760
+ end
2761
+ @lrtable.heads[pos] = head
2762
+ while true
2763
+ @cur = pos - @pos
2764
+ head.invol_to_eval
2765
+ chunk = public_send(rule)
2766
+ if !chunk || @pos + @cur <= answer.pos
2767
+ break
2768
+ end
2769
+ answer.chunk = chunk
2770
+ answer.pos = @pos + @cur
2771
+ end
2772
+ @lrtable.heads[pos] = nil
2773
+ @cur = answer.pos - @pos
2774
+ answer.chunk
2775
+ end
2776
+
2777
+ def apply_rule(rule, thunks, values, index)
2778
+ chunk = rule_chunk(rule, thunks, values, index)
2779
+ if !chunk
2780
+ return false
2781
+ end
2782
+ values ||= @global_values
2783
+ thunks << ThunkNode.new(chunk.thunks, values, index)
2784
+ return true
2785
+ end
2786
+
2787
+ def do_action(thunks, values, index)
2788
+ thunks.each do |thunk|
2789
+ thunk.do_action(self, values, index)
2790
+ end
2791
+ end
2792
+
2793
+ class LrTable
2794
+ attr_reader :heads, :answers
2795
+
2796
+ def initialize
2797
+ @heads = {}
2798
+ @answers = LrAnswerTable.new
2799
+ end
2800
+
2801
+ def clear
2802
+ @heads.clear
2803
+ @answers.clear
2804
+ end
2805
+ end
2806
+
2807
+ class LrAnswerTable
2808
+ def initialize
2809
+ @answers = {}
2810
+ end
2811
+
2812
+ def clear
2813
+ @answers.clear
2814
+ end
2815
+
2816
+ def []=(index, rule_name, answer)
2817
+ entry = @answers[index] ||= {}
2818
+ entry[rule_name] = answer
2819
+ end
2820
+
2821
+ def [](index, rule_name)
2822
+ @answers.dig(index, rule_name)
2823
+ end
2824
+ end
2825
+
2826
+ class LrHead
2827
+ attr_accessor :rule_name, :invol, :eval
2828
+
2829
+ def initialize(rule_name)
2830
+ @rule_name = rule_name
2831
+ @invol = {}
2832
+ @eval = {}
2833
+ end
2834
+
2835
+ def invol_to_eval
2836
+ @eval.clear
2837
+ @invol.each do |k, v|
2838
+ @eval[k] = true
2839
+ end
2840
+ end
2841
+ end
2842
+
2843
+ class ThunkChunk
2844
+ attr_accessor :thunks, :capts, :pos, :values
2845
+
2846
+ def initialize
2847
+ super
2848
+ @thunks = []
2849
+ @capts = {}
2850
+ @pos = 0
2851
+ @values = {}
2852
+ end
2853
+
2854
+ def resize_captures(len)
2855
+ len.times do |i|
2856
+ @capts[i] = Capture.new
2857
+ end
2858
+ end
2859
+ end
2860
+
2861
+ class Thunk
2862
+ end
2863
+
2864
+ class ThunkLeaf < Thunk
2865
+ attr_accessor :capt0, :capts, :value_refs, :action
2866
+
2867
+ def initialize(action, capt0 = Capture.new, value_refs = {}, capts = {})
2868
+ @value_refs = value_refs
2869
+ @capts = capts
2870
+ @capt0 = capt0
2871
+ @action = action
2872
+ end
2873
+
2874
+ def do_action(ctx, values, index)
2875
+ ctx.public_send(action, self, values, index)
2876
+ end
2877
+ end
2878
+
2879
+ class ThunkNode < Thunk
2880
+ attr_accessor :thunks, :values, :index
2881
+
2882
+ def initialize(thunks, values, index)
2883
+ @thunks = thunks
2884
+ @values = values
2885
+ @index = index
2886
+ values[index] ||= Value.new if values
2887
+ end
2888
+
2889
+ def do_action(ctx, _values, _index)
2890
+ @thunks.each do |thunk|
2891
+ thunk.do_action(ctx, @values, @index)
2892
+ end
2893
+ end
2894
+
2895
+ def clear
2896
+ @thunks.clear
2897
+ end
2898
+ end
2899
+
2900
+ class LrEntry
2901
+ attr_accessor :rule, :head, :seed
2902
+ end
2903
+
2904
+ class Capture
2905
+ attr_accessor :range_start, :range_end
2906
+
2907
+ def initialize(range_start = 0, range_end = 0)
2908
+ @range_start = range_start
2909
+ @range_end = range_end
2910
+ end
2911
+
2912
+ def capture_string(buffer)
2913
+ @string ||= buffer[@range_start, @range_end - @range_start]
2914
+ end
2915
+ end
2916
+
2917
+ class LrAnswer
2918
+ attr_accessor :lr, :chunk, :pos
2919
+
2920
+ def initialize(lr, pos)
2921
+ @pos = pos
2922
+ @lr = lr
2923
+ end
2924
+
2925
+ def chunk=(chunk)
2926
+ @lr = nil
2927
+ @chunk = chunk
2928
+ end
2929
+ end
2930
+
2931
+ class Value
2932
+ attr_accessor :value
2933
+ end
2934
+ end
2935
+
2936
+ class Packcr::Tokenizer
2937
+ attr_accessor :parser_buffer
2938
+ def getc
2939
+ @ifile.getc
2940
+ end
2941
+ end
2942
+
2943
+ tokenizer = Packcr::Tokenizer.new(debug: true)
2944
+ begin
2945
+ tokenizer.run
2946
+ rescue SyntaxError
2947
+ end
2948
+ p tokenizer.parser_buffer.gsub!(/./) { |c| "%02x " % c.ord }