packcr 0.0.3 → 0.0.6

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