atomy 0.1.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +13 -0
  3. data/LICENSE.md +201 -0
  4. data/bin/atomy +16 -133
  5. data/kernel/array.ay +6 -0
  6. data/kernel/atomy.ay +18 -0
  7. data/kernel/condition.ay +171 -271
  8. data/kernel/control-flow.ay +197 -192
  9. data/kernel/core.ay +120 -0
  10. data/kernel/data.ay +83 -39
  11. data/kernel/define.ay +84 -93
  12. data/kernel/doc.ay +282 -449
  13. data/kernel/dynamic.ay +25 -29
  14. data/kernel/file.ay +9 -0
  15. data/kernel/grammar.ay +267 -0
  16. data/kernel/hash.ay +17 -0
  17. data/kernel/interpolation.ay +59 -0
  18. data/kernel/io.ay +70 -244
  19. data/kernel/let-macro.ay +24 -0
  20. data/kernel/let-pattern.ay +24 -0
  21. data/kernel/loop.ay +80 -0
  22. data/kernel/mutation.ay +53 -0
  23. data/kernel/particles.ay +176 -39
  24. data/kernel/patterns.ay +527 -191
  25. data/kernel/pretty.ay +311 -277
  26. data/kernel/quotes.ay +29 -0
  27. data/kernel/range.ay +4 -0
  28. data/kernel/regexp.ay +23 -0
  29. data/kernel/repl.ay +83 -109
  30. data/kernel/stack-local.ay +21 -0
  31. data/lib/atomy.rb +37 -0
  32. data/lib/atomy/bootstrap.rb +256 -0
  33. data/lib/atomy/code/assign.rb +64 -0
  34. data/lib/atomy/code/block.rb +98 -0
  35. data/lib/atomy/code/class_variable.rb +17 -0
  36. data/lib/atomy/code/constant.rb +21 -0
  37. data/lib/atomy/code/define.rb +242 -0
  38. data/lib/atomy/code/define_function.rb +51 -0
  39. data/lib/atomy/code/define_method.rb +20 -0
  40. data/lib/atomy/code/false.rb +9 -0
  41. data/lib/atomy/code/instance_variable.rb +15 -0
  42. data/lib/atomy/code/integer.rb +13 -0
  43. data/lib/atomy/code/list.rb +17 -0
  44. data/lib/atomy/code/nil.rb +9 -0
  45. data/lib/atomy/code/pattern.rb +23 -0
  46. data/lib/atomy/code/pattern/and.rb +61 -0
  47. data/lib/atomy/code/pattern/quasi_quote.rb +185 -0
  48. data/lib/atomy/code/pattern/splat.rb +29 -0
  49. data/lib/atomy/code/pattern/wildcard.rb +37 -0
  50. data/lib/atomy/code/quasi_quote.rb +118 -0
  51. data/lib/atomy/code/quote.rb +13 -0
  52. data/lib/atomy/code/self.rb +9 -0
  53. data/lib/atomy/code/send.rb +110 -0
  54. data/lib/atomy/code/sequence.rb +23 -0
  55. data/lib/atomy/code/string_literal.rb +53 -0
  56. data/lib/atomy/code/symbol.rb +13 -0
  57. data/lib/atomy/code/true.rb +9 -0
  58. data/lib/atomy/code/undefined.rb +9 -0
  59. data/lib/atomy/code/variable.rb +17 -0
  60. data/lib/atomy/codeloader.rb +218 -0
  61. data/lib/atomy/compiler.rb +57 -0
  62. data/lib/atomy/errors.rb +54 -0
  63. data/lib/atomy/grammar.rb +2278 -0
  64. data/lib/atomy/locals.rb +75 -0
  65. data/lib/atomy/message_structure.rb +277 -0
  66. data/lib/atomy/method.rb +343 -0
  67. data/lib/atomy/module.rb +144 -0
  68. data/lib/atomy/node/constructable.rb +169 -0
  69. data/lib/atomy/node/equality.rb +113 -0
  70. data/lib/atomy/node/meta.rb +206 -0
  71. data/lib/atomy/node/pretty.rb +108 -0
  72. data/lib/atomy/parser.rb +21 -0
  73. data/lib/atomy/pattern.rb +26 -0
  74. data/lib/atomy/pattern/and.rb +59 -0
  75. data/lib/atomy/pattern/attribute.rb +16 -0
  76. data/lib/atomy/pattern/class_variable.rb +15 -0
  77. data/lib/atomy/pattern/equality.rb +42 -0
  78. data/lib/atomy/pattern/instance_variable.rb +15 -0
  79. data/lib/atomy/pattern/kind_of.rb +20 -0
  80. data/lib/atomy/pattern/or.rb +48 -0
  81. data/lib/atomy/pattern/quasi_quote.rb +164 -0
  82. data/lib/atomy/pattern/splat.rb +15 -0
  83. data/lib/atomy/pattern/wildcard.rb +18 -0
  84. data/lib/atomy/rubygems.rb +48 -0
  85. data/lib/atomy/version.rb +3 -0
  86. metadata +169 -134
  87. data/COPYING +0 -30
  88. data/README.md +0 -1
  89. data/kernel/block.ay +0 -30
  90. data/kernel/boot.ay +0 -10
  91. data/kernel/comparison.ay +0 -61
  92. data/kernel/concurrency.ay +0 -84
  93. data/kernel/cosmetics.ay +0 -3
  94. data/kernel/data-delta.ay +0 -105
  95. data/kernel/documentation.ay +0 -135
  96. data/kernel/errors.ay +0 -6
  97. data/kernel/format.ay +0 -13
  98. data/kernel/format/data.ay +0 -89
  99. data/kernel/format/formatter.ay +0 -345
  100. data/kernel/format/parser.ay +0 -13
  101. data/kernel/hashes.ay +0 -39
  102. data/kernel/namespaces.ay +0 -63
  103. data/kernel/node.ay +0 -48
  104. data/kernel/operators.ay +0 -28
  105. data/kernel/precision.ay +0 -148
  106. data/kernel/therie.ay +0 -204
  107. data/lib/ast/binary_send.rb +0 -44
  108. data/lib/ast/block.rb +0 -268
  109. data/lib/ast/constant.rb +0 -88
  110. data/lib/ast/internal/assign.rb +0 -19
  111. data/lib/ast/internal/block_pass.rb +0 -21
  112. data/lib/ast/internal/catch.rb +0 -247
  113. data/lib/ast/internal/class.rb +0 -30
  114. data/lib/ast/internal/class_variable.rb +0 -23
  115. data/lib/ast/internal/define.rb +0 -174
  116. data/lib/ast/internal/ensure.rb +0 -135
  117. data/lib/ast/internal/file.rb +0 -14
  118. data/lib/ast/internal/global_variable.rb +0 -20
  119. data/lib/ast/internal/if_then_else.rb +0 -24
  120. data/lib/ast/internal/instance_variable.rb +0 -17
  121. data/lib/ast/internal/let_macro.rb +0 -35
  122. data/lib/ast/internal/macro_quote.rb +0 -23
  123. data/lib/ast/internal/match.rb +0 -53
  124. data/lib/ast/internal/module.rb +0 -30
  125. data/lib/ast/internal/pattern.rb +0 -17
  126. data/lib/ast/internal/return.rb +0 -29
  127. data/lib/ast/internal/set.rb +0 -19
  128. data/lib/ast/internal/singleton_class.rb +0 -18
  129. data/lib/ast/internal/splat.rb +0 -14
  130. data/lib/ast/internal/when.rb +0 -24
  131. data/lib/ast/list.rb +0 -25
  132. data/lib/ast/macro.rb +0 -37
  133. data/lib/ast/node.rb +0 -599
  134. data/lib/ast/operator.rb +0 -21
  135. data/lib/ast/particle.rb +0 -13
  136. data/lib/ast/primitive.rb +0 -20
  137. data/lib/ast/quasi_quote.rb +0 -20
  138. data/lib/ast/quote.rb +0 -13
  139. data/lib/ast/send.rb +0 -104
  140. data/lib/ast/splice.rb +0 -32
  141. data/lib/ast/string.rb +0 -23
  142. data/lib/ast/unary.rb +0 -44
  143. data/lib/ast/unquote.rb +0 -45
  144. data/lib/ast/variable.rb +0 -64
  145. data/lib/atomy.kpeg.rb +0 -3995
  146. data/lib/code_loader.rb +0 -137
  147. data/lib/compiler/compiler.rb +0 -155
  148. data/lib/compiler/stages.rb +0 -81
  149. data/lib/formatter.kpeg.rb +0 -1394
  150. data/lib/macros.rb +0 -317
  151. data/lib/method.rb +0 -261
  152. data/lib/namespace.rb +0 -236
  153. data/lib/parser.rb +0 -28
  154. data/lib/patterns.rb +0 -276
  155. data/lib/patterns/any.rb +0 -21
  156. data/lib/patterns/attribute.rb +0 -59
  157. data/lib/patterns/block_pass.rb +0 -54
  158. data/lib/patterns/constant.rb +0 -33
  159. data/lib/patterns/default.rb +0 -44
  160. data/lib/patterns/head_tail.rb +0 -63
  161. data/lib/patterns/list.rb +0 -77
  162. data/lib/patterns/match.rb +0 -45
  163. data/lib/patterns/named.rb +0 -55
  164. data/lib/patterns/named_class.rb +0 -46
  165. data/lib/patterns/named_global.rb +0 -46
  166. data/lib/patterns/named_instance.rb +0 -46
  167. data/lib/patterns/particle.rb +0 -29
  168. data/lib/patterns/quasi_quote.rb +0 -184
  169. data/lib/patterns/quote.rb +0 -33
  170. data/lib/patterns/singleton_class.rb +0 -31
  171. data/lib/patterns/splat.rb +0 -57
  172. data/lib/util.rb +0 -37
@@ -0,0 +1,57 @@
1
+ require "atomy/locals"
2
+ require "rubinius/compiler"
3
+
4
+ module Atomy
5
+ module Compiler
6
+ module_function
7
+
8
+ def compile(node, mod, state = LocalState.new)
9
+ package(mod.file, 0, state) do |gen|
10
+ mod.compile(gen, node)
11
+ end
12
+ end
13
+
14
+ def package(file, line = 0, state = LocalState.new, &blk)
15
+ generate(file, line, state, &blk).package(Rubinius::CompiledCode).tap do |code|
16
+ if ENV["DEBUG"]
17
+ printer = CodeTools::Compiler::MethodPrinter.new
18
+ printer.bytecode = true
19
+ printer.print_method(code)
20
+ end
21
+ end
22
+ end
23
+
24
+ def generate(file, line = 0, state = LocalState.new)
25
+ gen = CodeTools::Generator.new
26
+ gen.file = file
27
+ gen.set_line(line)
28
+
29
+ gen.push_state(state)
30
+
31
+ yield gen
32
+
33
+ gen.ret
34
+
35
+ gen.close
36
+
37
+ gen.local_count = gen.state.scope.local_count
38
+ gen.local_names = gen.state.scope.local_names
39
+
40
+ gen.encode
41
+
42
+ gen
43
+ end
44
+
45
+ def construct_block(code, binding)
46
+ code = code.dup
47
+ code.scope = binding.constant_scope
48
+ code.name = binding.variables.method.name
49
+ code.scope.script =
50
+ Rubinius::CompiledCode::Script.new(code, code.file.to_s, true)
51
+
52
+ block = Rubinius::BlockEnvironment.new
53
+ block.under_context(binding.variables, code)
54
+ block
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,54 @@
1
+ require "atomy/node/pretty"
2
+
3
+ module Atomy
4
+ class UnknownPattern < RuntimeError
5
+ attr_reader :node
6
+
7
+ def initialize(node)
8
+ @node = node
9
+ end
10
+
11
+ def to_s
12
+ "unknown pattern: #{node}"
13
+ end
14
+ end
15
+
16
+ class UnknownCode < RuntimeError
17
+ attr_reader :node
18
+
19
+ def initialize(node)
20
+ @node = node
21
+ end
22
+
23
+ def to_s
24
+ "unknown code: #{node}"
25
+ end
26
+ end
27
+
28
+ class PatternMismatch < RuntimeError
29
+ attr_reader :pattern, :value
30
+
31
+ def initialize(pattern, value)
32
+ @pattern = pattern
33
+ @value = value
34
+ end
35
+
36
+ def to_s
37
+ "pattern `#{pattern}' did not match value `#{value.inspect}'"
38
+ end
39
+ end
40
+
41
+ class MessageMismatch < RuntimeError
42
+ attr_reader :name, :receiver, :arguments
43
+
44
+ def initialize(name, receiver, arguments = [])
45
+ @name = name
46
+ @receiver = receiver
47
+ @arguments = arguments
48
+ end
49
+
50
+ def to_s
51
+ "message `#{@name}(#{@arguments.collect(&:inspect).join(", ")})' was not understood by #{@receiver.inspect} (#{@receiver.class})"
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,2278 @@
1
+ require 'kpeg/compiled_parser'
2
+
3
+ class Atomy::Grammar < KPeg::CompiledParser
4
+
5
+
6
+ module AST
7
+ class Node
8
+ attr_accessor :line
9
+ end
10
+ end
11
+
12
+ def make(what, line, *args)
13
+ node = send(what, *args)
14
+ node.line ||= line
15
+ node
16
+ end
17
+
18
+ def current_position(target = pos)
19
+ cur_offset = 0
20
+ cur_line = 0
21
+
22
+ line_lengths.each do |len|
23
+ cur_line += 1
24
+ return [cur_line, target - cur_offset] if cur_offset + len > target
25
+ cur_offset += len
26
+ end
27
+
28
+ [cur_line, cur_offset]
29
+ end
30
+
31
+ def line_lengths
32
+ @line_lengths ||= lines.collect { |l| l.size }
33
+ end
34
+
35
+ def current_line(x = pos)
36
+ current_position(x)[0]
37
+ end
38
+
39
+ def current_column(x = pos)
40
+ current_position(x)[1]
41
+ end
42
+
43
+ def continue?(x)
44
+ y = current_position
45
+ y[0] >= x[0] && y[1] > x[1]
46
+ end
47
+
48
+ def set_lang(n)
49
+ require "atomy/codeloader"
50
+ @_grammar_lang = Atomy::CodeLoader.require("#{n}/language/parser")::Parser.new(nil)
51
+ end
52
+
53
+
54
+ # :stopdoc:
55
+
56
+ module AST
57
+ class Node; end
58
+ class Apply < Node
59
+ def initialize(node, arguments)
60
+ @node = node
61
+ @arguments = arguments
62
+ end
63
+ attr_reader :node
64
+ attr_reader :arguments
65
+ end
66
+ class Block < Node
67
+ def initialize(nodes)
68
+ @nodes = nodes
69
+ end
70
+ attr_reader :nodes
71
+ end
72
+ class Compose < Node
73
+ def initialize(left, right)
74
+ @left = left
75
+ @right = right
76
+ end
77
+ attr_reader :left
78
+ attr_reader :right
79
+ end
80
+ class Constant < Node
81
+ def initialize(text)
82
+ @text = text
83
+ end
84
+ attr_reader :text
85
+ end
86
+ class Infix < Node
87
+ def initialize(left, right, operator)
88
+ @left = left
89
+ @right = right
90
+ @operator = operator
91
+ end
92
+ attr_reader :left
93
+ attr_reader :right
94
+ attr_reader :operator
95
+ end
96
+ class List < Node
97
+ def initialize(nodes)
98
+ @nodes = nodes
99
+ end
100
+ attr_reader :nodes
101
+ end
102
+ class Literal < Node
103
+ def initialize(value)
104
+ @value = value
105
+ end
106
+ attr_reader :value
107
+ end
108
+ class Number < Node
109
+ def initialize(value)
110
+ @value = value
111
+ end
112
+ attr_reader :value
113
+ end
114
+ class Postfix < Node
115
+ def initialize(node, operator)
116
+ @node = node
117
+ @operator = operator
118
+ end
119
+ attr_reader :node
120
+ attr_reader :operator
121
+ end
122
+ class Prefix < Node
123
+ def initialize(node, operator)
124
+ @node = node
125
+ @operator = operator
126
+ end
127
+ attr_reader :node
128
+ attr_reader :operator
129
+ end
130
+ class QuasiQuote < Node
131
+ def initialize(node)
132
+ @node = node
133
+ end
134
+ attr_reader :node
135
+ end
136
+ class Quote < Node
137
+ def initialize(node)
138
+ @node = node
139
+ end
140
+ attr_reader :node
141
+ end
142
+ class Sequence < Node
143
+ def initialize(nodes)
144
+ @nodes = nodes
145
+ end
146
+ attr_reader :nodes
147
+ end
148
+ class StringLiteral < Node
149
+ def initialize(value)
150
+ @value = value
151
+ end
152
+ attr_reader :value
153
+ end
154
+ class Unquote < Node
155
+ def initialize(node)
156
+ @node = node
157
+ end
158
+ attr_reader :node
159
+ end
160
+ class Word < Node
161
+ def initialize(text)
162
+ @text = text
163
+ end
164
+ attr_reader :text
165
+ end
166
+ end
167
+ module ASTConstruction
168
+ def application(node, arguments)
169
+ AST::Apply.new(node, arguments)
170
+ end
171
+ def block(nodes)
172
+ AST::Block.new(nodes)
173
+ end
174
+ def compose(left, right)
175
+ AST::Compose.new(left, right)
176
+ end
177
+ def constant(text)
178
+ AST::Constant.new(text)
179
+ end
180
+ def infix(left, right, operator)
181
+ AST::Infix.new(left, right, operator)
182
+ end
183
+ def list(nodes)
184
+ AST::List.new(nodes)
185
+ end
186
+ def literal(value)
187
+ AST::Literal.new(value)
188
+ end
189
+ def number(value)
190
+ AST::Number.new(value)
191
+ end
192
+ def postfix(node, operator)
193
+ AST::Postfix.new(node, operator)
194
+ end
195
+ def prefix(node, operator)
196
+ AST::Prefix.new(node, operator)
197
+ end
198
+ def quasiquote(node)
199
+ AST::QuasiQuote.new(node)
200
+ end
201
+ def quote(node)
202
+ AST::Quote.new(node)
203
+ end
204
+ def sequence(nodes)
205
+ AST::Sequence.new(nodes)
206
+ end
207
+ def strliteral(value)
208
+ AST::StringLiteral.new(value)
209
+ end
210
+ def unquote(node)
211
+ AST::Unquote.new(node)
212
+ end
213
+ def word(text)
214
+ AST::Word.new(text)
215
+ end
216
+ end
217
+ include ASTConstruction
218
+
219
+ # root = shebang? wsp expressions?:es wsp !. { sequence(Array(es)) }
220
+ def _root
221
+
222
+ _save = self.pos
223
+ while true # sequence
224
+ _save1 = self.pos
225
+ _tmp = apply(:_shebang)
226
+ unless _tmp
227
+ _tmp = true
228
+ self.pos = _save1
229
+ end
230
+ unless _tmp
231
+ self.pos = _save
232
+ break
233
+ end
234
+ _tmp = apply(:_wsp)
235
+ unless _tmp
236
+ self.pos = _save
237
+ break
238
+ end
239
+ _save2 = self.pos
240
+ _tmp = apply(:_expressions)
241
+ @result = nil unless _tmp
242
+ unless _tmp
243
+ _tmp = true
244
+ self.pos = _save2
245
+ end
246
+ es = @result
247
+ unless _tmp
248
+ self.pos = _save
249
+ break
250
+ end
251
+ _tmp = apply(:_wsp)
252
+ unless _tmp
253
+ self.pos = _save
254
+ break
255
+ end
256
+ _save3 = self.pos
257
+ _tmp = get_byte
258
+ _tmp = _tmp ? nil : true
259
+ self.pos = _save3
260
+ unless _tmp
261
+ self.pos = _save
262
+ break
263
+ end
264
+ @result = begin; sequence(Array(es)) ; end
265
+ _tmp = true
266
+ unless _tmp
267
+ self.pos = _save
268
+ end
269
+ break
270
+ end # end sequence
271
+
272
+ set_failed_rule :_root unless _tmp
273
+ return _tmp
274
+ end
275
+
276
+ # shebang = "#!" /.*?$/
277
+ def _shebang
278
+
279
+ _save = self.pos
280
+ while true # sequence
281
+ _tmp = match_string("#!")
282
+ unless _tmp
283
+ self.pos = _save
284
+ break
285
+ end
286
+ _tmp = scan(/\A(?-mix:.*?$)/)
287
+ unless _tmp
288
+ self.pos = _save
289
+ end
290
+ break
291
+ end # end sequence
292
+
293
+ set_failed_rule :_shebang unless _tmp
294
+ return _tmp
295
+ end
296
+
297
+ # expressions = {current_column}:c expression:x (delim(c) expression)*:xs { [x] + Array(xs) }
298
+ def _expressions
299
+
300
+ _save = self.pos
301
+ while true # sequence
302
+ @result = begin; current_column; end
303
+ _tmp = true
304
+ c = @result
305
+ unless _tmp
306
+ self.pos = _save
307
+ break
308
+ end
309
+ _tmp = apply(:_expression)
310
+ x = @result
311
+ unless _tmp
312
+ self.pos = _save
313
+ break
314
+ end
315
+ _ary = []
316
+ while true
317
+
318
+ _save2 = self.pos
319
+ while true # sequence
320
+ _tmp = apply_with_args(:_delim, c)
321
+ unless _tmp
322
+ self.pos = _save2
323
+ break
324
+ end
325
+ _tmp = apply(:_expression)
326
+ unless _tmp
327
+ self.pos = _save2
328
+ end
329
+ break
330
+ end # end sequence
331
+
332
+ _ary << @result if _tmp
333
+ break unless _tmp
334
+ end
335
+ _tmp = true
336
+ @result = _ary
337
+ xs = @result
338
+ unless _tmp
339
+ self.pos = _save
340
+ break
341
+ end
342
+ @result = begin;
343
+ [x] + Array(xs)
344
+ ; end
345
+ _tmp = true
346
+ unless _tmp
347
+ self.pos = _save
348
+ end
349
+ break
350
+ end # end sequence
351
+
352
+ set_failed_rule :_expressions unless _tmp
353
+ return _tmp
354
+ end
355
+
356
+ # delim = (wsp "," wsp | (sp "\n" sp)+ &{ current_column >= c })
357
+ def _delim(c)
358
+
359
+ _save = self.pos
360
+ while true # choice
361
+
362
+ _save1 = self.pos
363
+ while true # sequence
364
+ _tmp = apply(:_wsp)
365
+ unless _tmp
366
+ self.pos = _save1
367
+ break
368
+ end
369
+ _tmp = match_string(",")
370
+ unless _tmp
371
+ self.pos = _save1
372
+ break
373
+ end
374
+ _tmp = apply(:_wsp)
375
+ unless _tmp
376
+ self.pos = _save1
377
+ end
378
+ break
379
+ end # end sequence
380
+
381
+ break if _tmp
382
+ self.pos = _save
383
+
384
+ _save2 = self.pos
385
+ while true # sequence
386
+ _save3 = self.pos
387
+
388
+ _save4 = self.pos
389
+ while true # sequence
390
+ _tmp = apply(:_sp)
391
+ unless _tmp
392
+ self.pos = _save4
393
+ break
394
+ end
395
+ _tmp = match_string("\n")
396
+ unless _tmp
397
+ self.pos = _save4
398
+ break
399
+ end
400
+ _tmp = apply(:_sp)
401
+ unless _tmp
402
+ self.pos = _save4
403
+ end
404
+ break
405
+ end # end sequence
406
+
407
+ if _tmp
408
+ while true
409
+
410
+ _save5 = self.pos
411
+ while true # sequence
412
+ _tmp = apply(:_sp)
413
+ unless _tmp
414
+ self.pos = _save5
415
+ break
416
+ end
417
+ _tmp = match_string("\n")
418
+ unless _tmp
419
+ self.pos = _save5
420
+ break
421
+ end
422
+ _tmp = apply(:_sp)
423
+ unless _tmp
424
+ self.pos = _save5
425
+ end
426
+ break
427
+ end # end sequence
428
+
429
+ break unless _tmp
430
+ end
431
+ _tmp = true
432
+ else
433
+ self.pos = _save3
434
+ end
435
+ unless _tmp
436
+ self.pos = _save2
437
+ break
438
+ end
439
+ _save6 = self.pos
440
+ _tmp = begin; current_column >= c ; end
441
+ self.pos = _save6
442
+ unless _tmp
443
+ self.pos = _save2
444
+ end
445
+ break
446
+ end # end sequence
447
+
448
+ break if _tmp
449
+ self.pos = _save
450
+ break
451
+ end # end choice
452
+
453
+ set_failed_rule :_delim unless _tmp
454
+ return _tmp
455
+ end
456
+
457
+ # expression = level4
458
+ def _expression
459
+ _tmp = apply(:_level4)
460
+ set_failed_rule :_expression unless _tmp
461
+ return _tmp
462
+ end
463
+
464
+ # one_expression = wsp expression:e wsp !. { e }
465
+ def _one_expression
466
+
467
+ _save = self.pos
468
+ while true # sequence
469
+ _tmp = apply(:_wsp)
470
+ unless _tmp
471
+ self.pos = _save
472
+ break
473
+ end
474
+ _tmp = apply(:_expression)
475
+ e = @result
476
+ unless _tmp
477
+ self.pos = _save
478
+ break
479
+ end
480
+ _tmp = apply(:_wsp)
481
+ unless _tmp
482
+ self.pos = _save
483
+ break
484
+ end
485
+ _save1 = self.pos
486
+ _tmp = get_byte
487
+ _tmp = _tmp ? nil : true
488
+ self.pos = _save1
489
+ unless _tmp
490
+ self.pos = _save
491
+ break
492
+ end
493
+ @result = begin; e ; end
494
+ _tmp = true
495
+ unless _tmp
496
+ self.pos = _save
497
+ end
498
+ break
499
+ end # end sequence
500
+
501
+ set_failed_rule :_one_expression unless _tmp
502
+ return _tmp
503
+ end
504
+
505
+ # line = {current_line}
506
+ def _line
507
+ @result = begin; current_line; end
508
+ _tmp = true
509
+ set_failed_rule :_line unless _tmp
510
+ return _tmp
511
+ end
512
+
513
+ # cont = (scont(p) | !"(")
514
+ def _cont(p)
515
+
516
+ _save = self.pos
517
+ while true # choice
518
+ _tmp = apply_with_args(:_scont, p)
519
+ break if _tmp
520
+ self.pos = _save
521
+ _save1 = self.pos
522
+ _tmp = match_string("(")
523
+ _tmp = _tmp ? nil : true
524
+ self.pos = _save1
525
+ break if _tmp
526
+ self.pos = _save
527
+ break
528
+ end # end choice
529
+
530
+ set_failed_rule :_cont unless _tmp
531
+ return _tmp
532
+ end
533
+
534
+ # scont = (("\n" sp)+ &{ continue?(p) } | sig_sp cont(p)?)
535
+ def _scont(p)
536
+
537
+ _save = self.pos
538
+ while true # choice
539
+
540
+ _save1 = self.pos
541
+ while true # sequence
542
+ _save2 = self.pos
543
+
544
+ _save3 = self.pos
545
+ while true # sequence
546
+ _tmp = match_string("\n")
547
+ unless _tmp
548
+ self.pos = _save3
549
+ break
550
+ end
551
+ _tmp = apply(:_sp)
552
+ unless _tmp
553
+ self.pos = _save3
554
+ end
555
+ break
556
+ end # end sequence
557
+
558
+ if _tmp
559
+ while true
560
+
561
+ _save4 = self.pos
562
+ while true # sequence
563
+ _tmp = match_string("\n")
564
+ unless _tmp
565
+ self.pos = _save4
566
+ break
567
+ end
568
+ _tmp = apply(:_sp)
569
+ unless _tmp
570
+ self.pos = _save4
571
+ end
572
+ break
573
+ end # end sequence
574
+
575
+ break unless _tmp
576
+ end
577
+ _tmp = true
578
+ else
579
+ self.pos = _save2
580
+ end
581
+ unless _tmp
582
+ self.pos = _save1
583
+ break
584
+ end
585
+ _save5 = self.pos
586
+ _tmp = begin; continue?(p) ; end
587
+ self.pos = _save5
588
+ unless _tmp
589
+ self.pos = _save1
590
+ end
591
+ break
592
+ end # end sequence
593
+
594
+ break if _tmp
595
+ self.pos = _save
596
+
597
+ _save6 = self.pos
598
+ while true # sequence
599
+ _tmp = apply(:_sig_sp)
600
+ unless _tmp
601
+ self.pos = _save6
602
+ break
603
+ end
604
+ _save7 = self.pos
605
+ _tmp = apply_with_args(:_cont, p)
606
+ unless _tmp
607
+ _tmp = true
608
+ self.pos = _save7
609
+ end
610
+ unless _tmp
611
+ self.pos = _save6
612
+ end
613
+ break
614
+ end # end sequence
615
+
616
+ break if _tmp
617
+ self.pos = _save
618
+ break
619
+ end # end choice
620
+
621
+ set_failed_rule :_scont unless _tmp
622
+ return _tmp
623
+ end
624
+
625
+ # sp = (" " | "\t" | comment)*
626
+ def _sp
627
+ while true
628
+
629
+ _save1 = self.pos
630
+ while true # choice
631
+ _tmp = match_string(" ")
632
+ break if _tmp
633
+ self.pos = _save1
634
+ _tmp = match_string("\t")
635
+ break if _tmp
636
+ self.pos = _save1
637
+ _tmp = apply(:_comment)
638
+ break if _tmp
639
+ self.pos = _save1
640
+ break
641
+ end # end choice
642
+
643
+ break unless _tmp
644
+ end
645
+ _tmp = true
646
+ set_failed_rule :_sp unless _tmp
647
+ return _tmp
648
+ end
649
+
650
+ # wsp = (" " | "\t" | "\n" | comment)*
651
+ def _wsp
652
+ while true
653
+
654
+ _save1 = self.pos
655
+ while true # choice
656
+ _tmp = match_string(" ")
657
+ break if _tmp
658
+ self.pos = _save1
659
+ _tmp = match_string("\t")
660
+ break if _tmp
661
+ self.pos = _save1
662
+ _tmp = match_string("\n")
663
+ break if _tmp
664
+ self.pos = _save1
665
+ _tmp = apply(:_comment)
666
+ break if _tmp
667
+ self.pos = _save1
668
+ break
669
+ end # end choice
670
+
671
+ break unless _tmp
672
+ end
673
+ _tmp = true
674
+ set_failed_rule :_wsp unless _tmp
675
+ return _tmp
676
+ end
677
+
678
+ # sig_sp = (" " | "\t" | comment)+
679
+ def _sig_sp
680
+ _save = self.pos
681
+
682
+ _save1 = self.pos
683
+ while true # choice
684
+ _tmp = match_string(" ")
685
+ break if _tmp
686
+ self.pos = _save1
687
+ _tmp = match_string("\t")
688
+ break if _tmp
689
+ self.pos = _save1
690
+ _tmp = apply(:_comment)
691
+ break if _tmp
692
+ self.pos = _save1
693
+ break
694
+ end # end choice
695
+
696
+ if _tmp
697
+ while true
698
+
699
+ _save2 = self.pos
700
+ while true # choice
701
+ _tmp = match_string(" ")
702
+ break if _tmp
703
+ self.pos = _save2
704
+ _tmp = match_string("\t")
705
+ break if _tmp
706
+ self.pos = _save2
707
+ _tmp = apply(:_comment)
708
+ break if _tmp
709
+ self.pos = _save2
710
+ break
711
+ end # end choice
712
+
713
+ break unless _tmp
714
+ end
715
+ _tmp = true
716
+ else
717
+ self.pos = _save
718
+ end
719
+ set_failed_rule :_sig_sp unless _tmp
720
+ return _tmp
721
+ end
722
+
723
+ # sig_wsp = (" " | "\t" | "\n" | comment)+
724
+ def _sig_wsp
725
+ _save = self.pos
726
+
727
+ _save1 = self.pos
728
+ while true # choice
729
+ _tmp = match_string(" ")
730
+ break if _tmp
731
+ self.pos = _save1
732
+ _tmp = match_string("\t")
733
+ break if _tmp
734
+ self.pos = _save1
735
+ _tmp = match_string("\n")
736
+ break if _tmp
737
+ self.pos = _save1
738
+ _tmp = apply(:_comment)
739
+ break if _tmp
740
+ self.pos = _save1
741
+ break
742
+ end # end choice
743
+
744
+ if _tmp
745
+ while true
746
+
747
+ _save2 = self.pos
748
+ while true # choice
749
+ _tmp = match_string(" ")
750
+ break if _tmp
751
+ self.pos = _save2
752
+ _tmp = match_string("\t")
753
+ break if _tmp
754
+ self.pos = _save2
755
+ _tmp = match_string("\n")
756
+ break if _tmp
757
+ self.pos = _save2
758
+ _tmp = apply(:_comment)
759
+ break if _tmp
760
+ self.pos = _save2
761
+ break
762
+ end # end choice
763
+
764
+ break unless _tmp
765
+ end
766
+ _tmp = true
767
+ else
768
+ self.pos = _save
769
+ end
770
+ set_failed_rule :_sig_wsp unless _tmp
771
+ return _tmp
772
+ end
773
+
774
+ # comment = (/--.*?$/ | multi_comment)
775
+ def _comment
776
+
777
+ _save = self.pos
778
+ while true # choice
779
+ _tmp = scan(/\A(?-mix:--.*?$)/)
780
+ break if _tmp
781
+ self.pos = _save
782
+ _tmp = apply(:_multi_comment)
783
+ break if _tmp
784
+ self.pos = _save
785
+ break
786
+ end # end choice
787
+
788
+ set_failed_rule :_comment unless _tmp
789
+ return _tmp
790
+ end
791
+
792
+ # multi_comment = "{-" in_multi
793
+ def _multi_comment
794
+
795
+ _save = self.pos
796
+ while true # sequence
797
+ _tmp = match_string("{-")
798
+ unless _tmp
799
+ self.pos = _save
800
+ break
801
+ end
802
+ _tmp = apply(:_in_multi)
803
+ unless _tmp
804
+ self.pos = _save
805
+ end
806
+ break
807
+ end # end sequence
808
+
809
+ set_failed_rule :_multi_comment unless _tmp
810
+ return _tmp
811
+ end
812
+
813
+ # in_multi = (/[^\-\{\}]*/ "-}" | /[^\-\{\}]*/ "{-" in_multi /[^\-\{\}]*/ "-}" | /[^\-\{\}]*/ /[-{}]/ in_multi)
814
+ def _in_multi
815
+
816
+ _save = self.pos
817
+ while true # choice
818
+
819
+ _save1 = self.pos
820
+ while true # sequence
821
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
822
+ unless _tmp
823
+ self.pos = _save1
824
+ break
825
+ end
826
+ _tmp = match_string("-}")
827
+ unless _tmp
828
+ self.pos = _save1
829
+ end
830
+ break
831
+ end # end sequence
832
+
833
+ break if _tmp
834
+ self.pos = _save
835
+
836
+ _save2 = self.pos
837
+ while true # sequence
838
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
839
+ unless _tmp
840
+ self.pos = _save2
841
+ break
842
+ end
843
+ _tmp = match_string("{-")
844
+ unless _tmp
845
+ self.pos = _save2
846
+ break
847
+ end
848
+ _tmp = apply(:_in_multi)
849
+ unless _tmp
850
+ self.pos = _save2
851
+ break
852
+ end
853
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
854
+ unless _tmp
855
+ self.pos = _save2
856
+ break
857
+ end
858
+ _tmp = match_string("-}")
859
+ unless _tmp
860
+ self.pos = _save2
861
+ end
862
+ break
863
+ end # end sequence
864
+
865
+ break if _tmp
866
+ self.pos = _save
867
+
868
+ _save3 = self.pos
869
+ while true # sequence
870
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
871
+ unless _tmp
872
+ self.pos = _save3
873
+ break
874
+ end
875
+ _tmp = scan(/\A(?-mix:[-{}])/)
876
+ unless _tmp
877
+ self.pos = _save3
878
+ break
879
+ end
880
+ _tmp = apply(:_in_multi)
881
+ unless _tmp
882
+ self.pos = _save3
883
+ end
884
+ break
885
+ end # end sequence
886
+
887
+ break if _tmp
888
+ self.pos = _save
889
+ break
890
+ end # end choice
891
+
892
+ set_failed_rule :_in_multi unless _tmp
893
+ return _tmp
894
+ end
895
+
896
+ # op_letter = < /[$+<=>^|~!@#%&*\-\\.\/\?]/ > { text.to_sym }
897
+ def _op_letter
898
+
899
+ _save = self.pos
900
+ while true # sequence
901
+ _text_start = self.pos
902
+ _tmp = scan(/\A(?-mix:[$+<=>^|~!@#%&*\-\\.\/\?])/)
903
+ if _tmp
904
+ text = get_text(_text_start)
905
+ end
906
+ unless _tmp
907
+ self.pos = _save
908
+ break
909
+ end
910
+ @result = begin; text.to_sym ; end
911
+ _tmp = true
912
+ unless _tmp
913
+ self.pos = _save
914
+ end
915
+ break
916
+ end # end sequence
917
+
918
+ set_failed_rule :_op_letter unless _tmp
919
+ return _tmp
920
+ end
921
+
922
+ # operator = < op_letter+ > { text.to_sym }
923
+ def _operator
924
+
925
+ _save = self.pos
926
+ while true # sequence
927
+ _text_start = self.pos
928
+ _save1 = self.pos
929
+ _tmp = apply(:_op_letter)
930
+ if _tmp
931
+ while true
932
+ _tmp = apply(:_op_letter)
933
+ break unless _tmp
934
+ end
935
+ _tmp = true
936
+ else
937
+ self.pos = _save1
938
+ end
939
+ if _tmp
940
+ text = get_text(_text_start)
941
+ end
942
+ unless _tmp
943
+ self.pos = _save
944
+ break
945
+ end
946
+ @result = begin; text.to_sym ; end
947
+ _tmp = true
948
+ unless _tmp
949
+ self.pos = _save
950
+ end
951
+ break
952
+ end # end sequence
953
+
954
+ set_failed_rule :_operator unless _tmp
955
+ return _tmp
956
+ end
957
+
958
+ # identifier = < /[a-z_][a-zA-Z\d\-_]*/ > { text.tr("-", "_").to_sym }
959
+ def _identifier
960
+
961
+ _save = self.pos
962
+ while true # sequence
963
+ _text_start = self.pos
964
+ _tmp = scan(/\A(?-mix:[a-z_][a-zA-Z\d\-_]*)/)
965
+ if _tmp
966
+ text = get_text(_text_start)
967
+ end
968
+ unless _tmp
969
+ self.pos = _save
970
+ break
971
+ end
972
+ @result = begin; text.tr("-", "_").to_sym ; end
973
+ _tmp = true
974
+ unless _tmp
975
+ self.pos = _save
976
+ end
977
+ break
978
+ end # end sequence
979
+
980
+ set_failed_rule :_identifier unless _tmp
981
+ return _tmp
982
+ end
983
+
984
+ # language = "#language" wsp identifier:n {set_lang(n)} %lang.root
985
+ def _language
986
+
987
+ _save = self.pos
988
+ while true # sequence
989
+ _tmp = match_string("#language")
990
+ unless _tmp
991
+ self.pos = _save
992
+ break
993
+ end
994
+ _tmp = apply(:_wsp)
995
+ unless _tmp
996
+ self.pos = _save
997
+ break
998
+ end
999
+ _tmp = apply(:_identifier)
1000
+ n = @result
1001
+ unless _tmp
1002
+ self.pos = _save
1003
+ break
1004
+ end
1005
+ @result = begin; set_lang(n); end
1006
+ _tmp = true
1007
+ unless _tmp
1008
+ self.pos = _save
1009
+ break
1010
+ end
1011
+ _tmp = @_grammar_lang.external_invoke(self, :_root)
1012
+ unless _tmp
1013
+ self.pos = _save
1014
+ end
1015
+ break
1016
+ end # end sequence
1017
+
1018
+ set_failed_rule :_language unless _tmp
1019
+ return _tmp
1020
+ end
1021
+
1022
+ # level0 = (number | quote | quasi_quote | unquote | string | constant | word | block | list | prefix)
1023
+ def _level0
1024
+
1025
+ _save = self.pos
1026
+ while true # choice
1027
+ _tmp = apply(:_number)
1028
+ break if _tmp
1029
+ self.pos = _save
1030
+ _tmp = apply(:_quote)
1031
+ break if _tmp
1032
+ self.pos = _save
1033
+ _tmp = apply(:_quasi_quote)
1034
+ break if _tmp
1035
+ self.pos = _save
1036
+ _tmp = apply(:_unquote)
1037
+ break if _tmp
1038
+ self.pos = _save
1039
+ _tmp = apply(:_string)
1040
+ break if _tmp
1041
+ self.pos = _save
1042
+ _tmp = apply(:_constant)
1043
+ break if _tmp
1044
+ self.pos = _save
1045
+ _tmp = apply(:_word)
1046
+ break if _tmp
1047
+ self.pos = _save
1048
+ _tmp = apply(:_block)
1049
+ break if _tmp
1050
+ self.pos = _save
1051
+ _tmp = apply(:_list)
1052
+ break if _tmp
1053
+ self.pos = _save
1054
+ _tmp = apply(:_prefix)
1055
+ break if _tmp
1056
+ self.pos = _save
1057
+ break
1058
+ end # end choice
1059
+
1060
+ set_failed_rule :_level0 unless _tmp
1061
+ return _tmp
1062
+ end
1063
+
1064
+ # level1 = (apply | grouped | level0)
1065
+ def _level1
1066
+
1067
+ _save = self.pos
1068
+ while true # choice
1069
+ _tmp = apply(:_apply)
1070
+ break if _tmp
1071
+ self.pos = _save
1072
+ _tmp = apply(:_grouped)
1073
+ break if _tmp
1074
+ self.pos = _save
1075
+ _tmp = apply(:_level0)
1076
+ break if _tmp
1077
+ self.pos = _save
1078
+ break
1079
+ end # end choice
1080
+
1081
+ set_failed_rule :_level1 unless _tmp
1082
+ return _tmp
1083
+ end
1084
+
1085
+ # level2 = (postfix | level1)
1086
+ def _level2
1087
+
1088
+ _save = self.pos
1089
+ while true # choice
1090
+ _tmp = apply(:_postfix)
1091
+ break if _tmp
1092
+ self.pos = _save
1093
+ _tmp = apply(:_level1)
1094
+ break if _tmp
1095
+ self.pos = _save
1096
+ break
1097
+ end # end choice
1098
+
1099
+ set_failed_rule :_level2 unless _tmp
1100
+ return _tmp
1101
+ end
1102
+
1103
+ # level3 = (compose | level2)
1104
+ def _level3
1105
+
1106
+ _save = self.pos
1107
+ while true # choice
1108
+ _tmp = apply(:_compose)
1109
+ break if _tmp
1110
+ self.pos = _save
1111
+ _tmp = apply(:_level2)
1112
+ break if _tmp
1113
+ self.pos = _save
1114
+ break
1115
+ end # end choice
1116
+
1117
+ set_failed_rule :_level3 unless _tmp
1118
+ return _tmp
1119
+ end
1120
+
1121
+ # level4 = (language | infix | level3)
1122
+ def _level4
1123
+
1124
+ _save = self.pos
1125
+ while true # choice
1126
+ _tmp = apply(:_language)
1127
+ break if _tmp
1128
+ self.pos = _save
1129
+ _tmp = apply(:_infix)
1130
+ break if _tmp
1131
+ self.pos = _save
1132
+ _tmp = apply(:_level3)
1133
+ break if _tmp
1134
+ self.pos = _save
1135
+ break
1136
+ end # end choice
1137
+
1138
+ set_failed_rule :_level4 unless _tmp
1139
+ return _tmp
1140
+ end
1141
+
1142
+ # grouped = "(" wsp expression:x wsp ")" { x }
1143
+ def _grouped
1144
+
1145
+ _save = self.pos
1146
+ while true # sequence
1147
+ _tmp = match_string("(")
1148
+ unless _tmp
1149
+ self.pos = _save
1150
+ break
1151
+ end
1152
+ _tmp = apply(:_wsp)
1153
+ unless _tmp
1154
+ self.pos = _save
1155
+ break
1156
+ end
1157
+ _tmp = apply(:_expression)
1158
+ x = @result
1159
+ unless _tmp
1160
+ self.pos = _save
1161
+ break
1162
+ end
1163
+ _tmp = apply(:_wsp)
1164
+ unless _tmp
1165
+ self.pos = _save
1166
+ break
1167
+ end
1168
+ _tmp = match_string(")")
1169
+ unless _tmp
1170
+ self.pos = _save
1171
+ break
1172
+ end
1173
+ @result = begin; x ; end
1174
+ _tmp = true
1175
+ unless _tmp
1176
+ self.pos = _save
1177
+ end
1178
+ break
1179
+ end # end sequence
1180
+
1181
+ set_failed_rule :_grouped unless _tmp
1182
+ return _tmp
1183
+ end
1184
+
1185
+ # number = (line:l < /[\+\-]?0[oO][0-7]+/ > {make(:number, l, text.to_i(8))} | line:l < /[\+\-]?0[xX][\da-fA-F]+/ > {make(:number, l, text.to_i(16))} | line:l < /[\+\-]?\d+(\.\d+)?[eE][\+\-]?\d+/ > {make(:literal, l, text.to_f)} | line:l < /[\+\-]?\d+\.\d+/ > {make(:literal, l, text.to_f)} | line:l < /[\+\-]?\d+/ > {make(:number, l, text.to_i)})
1186
+ def _number
1187
+
1188
+ _save = self.pos
1189
+ while true # choice
1190
+
1191
+ _save1 = self.pos
1192
+ while true # sequence
1193
+ _tmp = apply(:_line)
1194
+ l = @result
1195
+ unless _tmp
1196
+ self.pos = _save1
1197
+ break
1198
+ end
1199
+ _text_start = self.pos
1200
+ _tmp = scan(/\A(?-mix:[\+\-]?0[oO][0-7]+)/)
1201
+ if _tmp
1202
+ text = get_text(_text_start)
1203
+ end
1204
+ unless _tmp
1205
+ self.pos = _save1
1206
+ break
1207
+ end
1208
+ @result = begin; make(:number, l, text.to_i(8)); end
1209
+ _tmp = true
1210
+ unless _tmp
1211
+ self.pos = _save1
1212
+ end
1213
+ break
1214
+ end # end sequence
1215
+
1216
+ break if _tmp
1217
+ self.pos = _save
1218
+
1219
+ _save2 = self.pos
1220
+ while true # sequence
1221
+ _tmp = apply(:_line)
1222
+ l = @result
1223
+ unless _tmp
1224
+ self.pos = _save2
1225
+ break
1226
+ end
1227
+ _text_start = self.pos
1228
+ _tmp = scan(/\A(?-mix:[\+\-]?0[xX][\da-fA-F]+)/)
1229
+ if _tmp
1230
+ text = get_text(_text_start)
1231
+ end
1232
+ unless _tmp
1233
+ self.pos = _save2
1234
+ break
1235
+ end
1236
+ @result = begin; make(:number, l, text.to_i(16)); end
1237
+ _tmp = true
1238
+ unless _tmp
1239
+ self.pos = _save2
1240
+ end
1241
+ break
1242
+ end # end sequence
1243
+
1244
+ break if _tmp
1245
+ self.pos = _save
1246
+
1247
+ _save3 = self.pos
1248
+ while true # sequence
1249
+ _tmp = apply(:_line)
1250
+ l = @result
1251
+ unless _tmp
1252
+ self.pos = _save3
1253
+ break
1254
+ end
1255
+ _text_start = self.pos
1256
+ _tmp = scan(/\A(?-mix:[\+\-]?\d+(\.\d+)?[eE][\+\-]?\d+)/)
1257
+ if _tmp
1258
+ text = get_text(_text_start)
1259
+ end
1260
+ unless _tmp
1261
+ self.pos = _save3
1262
+ break
1263
+ end
1264
+ @result = begin; make(:literal, l, text.to_f); end
1265
+ _tmp = true
1266
+ unless _tmp
1267
+ self.pos = _save3
1268
+ end
1269
+ break
1270
+ end # end sequence
1271
+
1272
+ break if _tmp
1273
+ self.pos = _save
1274
+
1275
+ _save4 = self.pos
1276
+ while true # sequence
1277
+ _tmp = apply(:_line)
1278
+ l = @result
1279
+ unless _tmp
1280
+ self.pos = _save4
1281
+ break
1282
+ end
1283
+ _text_start = self.pos
1284
+ _tmp = scan(/\A(?-mix:[\+\-]?\d+\.\d+)/)
1285
+ if _tmp
1286
+ text = get_text(_text_start)
1287
+ end
1288
+ unless _tmp
1289
+ self.pos = _save4
1290
+ break
1291
+ end
1292
+ @result = begin; make(:literal, l, text.to_f); end
1293
+ _tmp = true
1294
+ unless _tmp
1295
+ self.pos = _save4
1296
+ end
1297
+ break
1298
+ end # end sequence
1299
+
1300
+ break if _tmp
1301
+ self.pos = _save
1302
+
1303
+ _save5 = self.pos
1304
+ while true # sequence
1305
+ _tmp = apply(:_line)
1306
+ l = @result
1307
+ unless _tmp
1308
+ self.pos = _save5
1309
+ break
1310
+ end
1311
+ _text_start = self.pos
1312
+ _tmp = scan(/\A(?-mix:[\+\-]?\d+)/)
1313
+ if _tmp
1314
+ text = get_text(_text_start)
1315
+ end
1316
+ unless _tmp
1317
+ self.pos = _save5
1318
+ break
1319
+ end
1320
+ @result = begin; make(:number, l, text.to_i); end
1321
+ _tmp = true
1322
+ unless _tmp
1323
+ self.pos = _save5
1324
+ end
1325
+ break
1326
+ end # end sequence
1327
+
1328
+ break if _tmp
1329
+ self.pos = _save
1330
+ break
1331
+ end # end choice
1332
+
1333
+ set_failed_rule :_number unless _tmp
1334
+ return _tmp
1335
+ end
1336
+
1337
+ # string = line:line "\"" < ("\\" . | /[^\\"]/)*:c > "\"" {make(:strliteral, line, text.gsub("\\\"", "\""))}
1338
+ def _string
1339
+
1340
+ _save = self.pos
1341
+ while true # sequence
1342
+ _tmp = apply(:_line)
1343
+ line = @result
1344
+ unless _tmp
1345
+ self.pos = _save
1346
+ break
1347
+ end
1348
+ _tmp = match_string("\"")
1349
+ unless _tmp
1350
+ self.pos = _save
1351
+ break
1352
+ end
1353
+ _text_start = self.pos
1354
+ _ary = []
1355
+ while true
1356
+
1357
+ _save2 = self.pos
1358
+ while true # choice
1359
+
1360
+ _save3 = self.pos
1361
+ while true # sequence
1362
+ _tmp = match_string("\\")
1363
+ unless _tmp
1364
+ self.pos = _save3
1365
+ break
1366
+ end
1367
+ _tmp = get_byte
1368
+ unless _tmp
1369
+ self.pos = _save3
1370
+ end
1371
+ break
1372
+ end # end sequence
1373
+
1374
+ break if _tmp
1375
+ self.pos = _save2
1376
+ _tmp = scan(/\A(?-mix:[^\\"])/)
1377
+ break if _tmp
1378
+ self.pos = _save2
1379
+ break
1380
+ end # end choice
1381
+
1382
+ _ary << @result if _tmp
1383
+ break unless _tmp
1384
+ end
1385
+ _tmp = true
1386
+ @result = _ary
1387
+ c = @result
1388
+ if _tmp
1389
+ text = get_text(_text_start)
1390
+ end
1391
+ unless _tmp
1392
+ self.pos = _save
1393
+ break
1394
+ end
1395
+ _tmp = match_string("\"")
1396
+ unless _tmp
1397
+ self.pos = _save
1398
+ break
1399
+ end
1400
+ @result = begin; make(:strliteral, line, text.gsub("\\\"", "\"")); end
1401
+ _tmp = true
1402
+ unless _tmp
1403
+ self.pos = _save
1404
+ end
1405
+ break
1406
+ end # end sequence
1407
+
1408
+ set_failed_rule :_string unless _tmp
1409
+ return _tmp
1410
+ end
1411
+
1412
+ # constant = line:l < /[A-Z][a-zA-Z0-9_]*/ > {make(:constant, l, text.to_sym)}
1413
+ def _constant
1414
+
1415
+ _save = self.pos
1416
+ while true # sequence
1417
+ _tmp = apply(:_line)
1418
+ l = @result
1419
+ unless _tmp
1420
+ self.pos = _save
1421
+ break
1422
+ end
1423
+ _text_start = self.pos
1424
+ _tmp = scan(/\A(?-mix:[A-Z][a-zA-Z0-9_]*)/)
1425
+ if _tmp
1426
+ text = get_text(_text_start)
1427
+ end
1428
+ unless _tmp
1429
+ self.pos = _save
1430
+ break
1431
+ end
1432
+ @result = begin; make(:constant, l, text.to_sym); end
1433
+ _tmp = true
1434
+ unless _tmp
1435
+ self.pos = _save
1436
+ end
1437
+ break
1438
+ end # end sequence
1439
+
1440
+ set_failed_rule :_constant unless _tmp
1441
+ return _tmp
1442
+ end
1443
+
1444
+ # word = line:l identifier:n {make(:word, l, n)}
1445
+ def _word
1446
+
1447
+ _save = self.pos
1448
+ while true # sequence
1449
+ _tmp = apply(:_line)
1450
+ l = @result
1451
+ unless _tmp
1452
+ self.pos = _save
1453
+ break
1454
+ end
1455
+ _tmp = apply(:_identifier)
1456
+ n = @result
1457
+ unless _tmp
1458
+ self.pos = _save
1459
+ break
1460
+ end
1461
+ @result = begin; make(:word, l, n); end
1462
+ _tmp = true
1463
+ unless _tmp
1464
+ self.pos = _save
1465
+ end
1466
+ break
1467
+ end # end sequence
1468
+
1469
+ set_failed_rule :_word unless _tmp
1470
+ return _tmp
1471
+ end
1472
+
1473
+ # quote = line:l "'" level2:e {make(:make, l, :quote, l, e)}
1474
+ def _quote
1475
+
1476
+ _save = self.pos
1477
+ while true # sequence
1478
+ _tmp = apply(:_line)
1479
+ l = @result
1480
+ unless _tmp
1481
+ self.pos = _save
1482
+ break
1483
+ end
1484
+ _tmp = match_string("'")
1485
+ unless _tmp
1486
+ self.pos = _save
1487
+ break
1488
+ end
1489
+ _tmp = apply(:_level2)
1490
+ e = @result
1491
+ unless _tmp
1492
+ self.pos = _save
1493
+ break
1494
+ end
1495
+ @result = begin; make(:make, l, :quote, l, e); end
1496
+ _tmp = true
1497
+ unless _tmp
1498
+ self.pos = _save
1499
+ end
1500
+ break
1501
+ end # end sequence
1502
+
1503
+ set_failed_rule :_quote unless _tmp
1504
+ return _tmp
1505
+ end
1506
+
1507
+ # quasi_quote = line:l "`" level2:e {make(:quasiquote, l, e)}
1508
+ def _quasi_quote
1509
+
1510
+ _save = self.pos
1511
+ while true # sequence
1512
+ _tmp = apply(:_line)
1513
+ l = @result
1514
+ unless _tmp
1515
+ self.pos = _save
1516
+ break
1517
+ end
1518
+ _tmp = match_string("`")
1519
+ unless _tmp
1520
+ self.pos = _save
1521
+ break
1522
+ end
1523
+ _tmp = apply(:_level2)
1524
+ e = @result
1525
+ unless _tmp
1526
+ self.pos = _save
1527
+ break
1528
+ end
1529
+ @result = begin; make(:quasiquote, l, e); end
1530
+ _tmp = true
1531
+ unless _tmp
1532
+ self.pos = _save
1533
+ end
1534
+ break
1535
+ end # end sequence
1536
+
1537
+ set_failed_rule :_quasi_quote unless _tmp
1538
+ return _tmp
1539
+ end
1540
+
1541
+ # unquote = line:l "~" level2:e {make(:unquote, l, e)}
1542
+ def _unquote
1543
+
1544
+ _save = self.pos
1545
+ while true # sequence
1546
+ _tmp = apply(:_line)
1547
+ l = @result
1548
+ unless _tmp
1549
+ self.pos = _save
1550
+ break
1551
+ end
1552
+ _tmp = match_string("~")
1553
+ unless _tmp
1554
+ self.pos = _save
1555
+ break
1556
+ end
1557
+ _tmp = apply(:_level2)
1558
+ e = @result
1559
+ unless _tmp
1560
+ self.pos = _save
1561
+ break
1562
+ end
1563
+ @result = begin; make(:unquote, l, e); end
1564
+ _tmp = true
1565
+ unless _tmp
1566
+ self.pos = _save
1567
+ end
1568
+ break
1569
+ end # end sequence
1570
+
1571
+ set_failed_rule :_unquote unless _tmp
1572
+ return _tmp
1573
+ end
1574
+
1575
+ # prefix = line:l op_letter:o level2:e {make(:prefix, l, e, o)}
1576
+ def _prefix
1577
+
1578
+ _save = self.pos
1579
+ while true # sequence
1580
+ _tmp = apply(:_line)
1581
+ l = @result
1582
+ unless _tmp
1583
+ self.pos = _save
1584
+ break
1585
+ end
1586
+ _tmp = apply(:_op_letter)
1587
+ o = @result
1588
+ unless _tmp
1589
+ self.pos = _save
1590
+ break
1591
+ end
1592
+ _tmp = apply(:_level2)
1593
+ e = @result
1594
+ unless _tmp
1595
+ self.pos = _save
1596
+ break
1597
+ end
1598
+ @result = begin; make(:prefix, l, e, o); end
1599
+ _tmp = true
1600
+ unless _tmp
1601
+ self.pos = _save
1602
+ end
1603
+ break
1604
+ end # end sequence
1605
+
1606
+ set_failed_rule :_prefix unless _tmp
1607
+ return _tmp
1608
+ end
1609
+
1610
+ # postfix = (line:l postfix:e op_letter:o {make(:postfix, l, e, o)} | line:l level1:e op_letter:o {make(:postfix, l, e, o)})
1611
+ def _postfix
1612
+
1613
+ _save = self.pos
1614
+ while true # choice
1615
+
1616
+ _save1 = self.pos
1617
+ while true # sequence
1618
+ _tmp = apply(:_line)
1619
+ l = @result
1620
+ unless _tmp
1621
+ self.pos = _save1
1622
+ break
1623
+ end
1624
+ _tmp = apply(:_postfix)
1625
+ e = @result
1626
+ unless _tmp
1627
+ self.pos = _save1
1628
+ break
1629
+ end
1630
+ _tmp = apply(:_op_letter)
1631
+ o = @result
1632
+ unless _tmp
1633
+ self.pos = _save1
1634
+ break
1635
+ end
1636
+ @result = begin; make(:postfix, l, e, o); end
1637
+ _tmp = true
1638
+ unless _tmp
1639
+ self.pos = _save1
1640
+ end
1641
+ break
1642
+ end # end sequence
1643
+
1644
+ break if _tmp
1645
+ self.pos = _save
1646
+
1647
+ _save2 = self.pos
1648
+ while true # sequence
1649
+ _tmp = apply(:_line)
1650
+ l = @result
1651
+ unless _tmp
1652
+ self.pos = _save2
1653
+ break
1654
+ end
1655
+ _tmp = apply(:_level1)
1656
+ e = @result
1657
+ unless _tmp
1658
+ self.pos = _save2
1659
+ break
1660
+ end
1661
+ _tmp = apply(:_op_letter)
1662
+ o = @result
1663
+ unless _tmp
1664
+ self.pos = _save2
1665
+ break
1666
+ end
1667
+ @result = begin; make(:postfix, l, e, o); end
1668
+ _tmp = true
1669
+ unless _tmp
1670
+ self.pos = _save2
1671
+ end
1672
+ break
1673
+ end # end sequence
1674
+
1675
+ break if _tmp
1676
+ self.pos = _save
1677
+ break
1678
+ end # end choice
1679
+
1680
+ set_failed_rule :_postfix unless _tmp
1681
+ return _tmp
1682
+ end
1683
+
1684
+ # block = (line:l ":" wsp expressions?:es (wsp ";")? {make(:block, l, Array(es))} | line:l "{" wsp expressions?:es wsp "}" {make(:block, l, Array(es))})
1685
+ def _block
1686
+
1687
+ _save = self.pos
1688
+ while true # choice
1689
+
1690
+ _save1 = self.pos
1691
+ while true # sequence
1692
+ _tmp = apply(:_line)
1693
+ l = @result
1694
+ unless _tmp
1695
+ self.pos = _save1
1696
+ break
1697
+ end
1698
+ _tmp = match_string(":")
1699
+ unless _tmp
1700
+ self.pos = _save1
1701
+ break
1702
+ end
1703
+ _tmp = apply(:_wsp)
1704
+ unless _tmp
1705
+ self.pos = _save1
1706
+ break
1707
+ end
1708
+ _save2 = self.pos
1709
+ _tmp = apply(:_expressions)
1710
+ @result = nil unless _tmp
1711
+ unless _tmp
1712
+ _tmp = true
1713
+ self.pos = _save2
1714
+ end
1715
+ es = @result
1716
+ unless _tmp
1717
+ self.pos = _save1
1718
+ break
1719
+ end
1720
+ _save3 = self.pos
1721
+
1722
+ _save4 = self.pos
1723
+ while true # sequence
1724
+ _tmp = apply(:_wsp)
1725
+ unless _tmp
1726
+ self.pos = _save4
1727
+ break
1728
+ end
1729
+ _tmp = match_string(";")
1730
+ unless _tmp
1731
+ self.pos = _save4
1732
+ end
1733
+ break
1734
+ end # end sequence
1735
+
1736
+ unless _tmp
1737
+ _tmp = true
1738
+ self.pos = _save3
1739
+ end
1740
+ unless _tmp
1741
+ self.pos = _save1
1742
+ break
1743
+ end
1744
+ @result = begin; make(:block, l, Array(es)); end
1745
+ _tmp = true
1746
+ unless _tmp
1747
+ self.pos = _save1
1748
+ end
1749
+ break
1750
+ end # end sequence
1751
+
1752
+ break if _tmp
1753
+ self.pos = _save
1754
+
1755
+ _save5 = self.pos
1756
+ while true # sequence
1757
+ _tmp = apply(:_line)
1758
+ l = @result
1759
+ unless _tmp
1760
+ self.pos = _save5
1761
+ break
1762
+ end
1763
+ _tmp = match_string("{")
1764
+ unless _tmp
1765
+ self.pos = _save5
1766
+ break
1767
+ end
1768
+ _tmp = apply(:_wsp)
1769
+ unless _tmp
1770
+ self.pos = _save5
1771
+ break
1772
+ end
1773
+ _save6 = self.pos
1774
+ _tmp = apply(:_expressions)
1775
+ @result = nil unless _tmp
1776
+ unless _tmp
1777
+ _tmp = true
1778
+ self.pos = _save6
1779
+ end
1780
+ es = @result
1781
+ unless _tmp
1782
+ self.pos = _save5
1783
+ break
1784
+ end
1785
+ _tmp = apply(:_wsp)
1786
+ unless _tmp
1787
+ self.pos = _save5
1788
+ break
1789
+ end
1790
+ _tmp = match_string("}")
1791
+ unless _tmp
1792
+ self.pos = _save5
1793
+ break
1794
+ end
1795
+ @result = begin; make(:block, l, Array(es)); end
1796
+ _tmp = true
1797
+ unless _tmp
1798
+ self.pos = _save5
1799
+ end
1800
+ break
1801
+ end # end sequence
1802
+
1803
+ break if _tmp
1804
+ self.pos = _save
1805
+ break
1806
+ end # end choice
1807
+
1808
+ set_failed_rule :_block unless _tmp
1809
+ return _tmp
1810
+ end
1811
+
1812
+ # list = line:l "[" wsp expressions?:es wsp "]" {make(:list, l, Array(es))}
1813
+ def _list
1814
+
1815
+ _save = self.pos
1816
+ while true # sequence
1817
+ _tmp = apply(:_line)
1818
+ l = @result
1819
+ unless _tmp
1820
+ self.pos = _save
1821
+ break
1822
+ end
1823
+ _tmp = match_string("[")
1824
+ unless _tmp
1825
+ self.pos = _save
1826
+ break
1827
+ end
1828
+ _tmp = apply(:_wsp)
1829
+ unless _tmp
1830
+ self.pos = _save
1831
+ break
1832
+ end
1833
+ _save1 = self.pos
1834
+ _tmp = apply(:_expressions)
1835
+ @result = nil unless _tmp
1836
+ unless _tmp
1837
+ _tmp = true
1838
+ self.pos = _save1
1839
+ end
1840
+ es = @result
1841
+ unless _tmp
1842
+ self.pos = _save
1843
+ break
1844
+ end
1845
+ _tmp = apply(:_wsp)
1846
+ unless _tmp
1847
+ self.pos = _save
1848
+ break
1849
+ end
1850
+ _tmp = match_string("]")
1851
+ unless _tmp
1852
+ self.pos = _save
1853
+ break
1854
+ end
1855
+ @result = begin; make(:list, l, Array(es)); end
1856
+ _tmp = true
1857
+ unless _tmp
1858
+ self.pos = _save
1859
+ end
1860
+ break
1861
+ end # end sequence
1862
+
1863
+ set_failed_rule :_list unless _tmp
1864
+ return _tmp
1865
+ end
1866
+
1867
+ # apply = (line:l apply:a args:as {make(:application, l, a, as)} | line:l name:n args:as {make(:application, l, n, as)})
1868
+ def _apply
1869
+
1870
+ _save = self.pos
1871
+ while true # choice
1872
+
1873
+ _save1 = self.pos
1874
+ while true # sequence
1875
+ _tmp = apply(:_line)
1876
+ l = @result
1877
+ unless _tmp
1878
+ self.pos = _save1
1879
+ break
1880
+ end
1881
+ _tmp = apply(:_apply)
1882
+ a = @result
1883
+ unless _tmp
1884
+ self.pos = _save1
1885
+ break
1886
+ end
1887
+ _tmp = apply(:_args)
1888
+ as = @result
1889
+ unless _tmp
1890
+ self.pos = _save1
1891
+ break
1892
+ end
1893
+ @result = begin; make(:application, l, a, as); end
1894
+ _tmp = true
1895
+ unless _tmp
1896
+ self.pos = _save1
1897
+ end
1898
+ break
1899
+ end # end sequence
1900
+
1901
+ break if _tmp
1902
+ self.pos = _save
1903
+
1904
+ _save2 = self.pos
1905
+ while true # sequence
1906
+ _tmp = apply(:_line)
1907
+ l = @result
1908
+ unless _tmp
1909
+ self.pos = _save2
1910
+ break
1911
+ end
1912
+ _tmp = apply(:_name)
1913
+ n = @result
1914
+ unless _tmp
1915
+ self.pos = _save2
1916
+ break
1917
+ end
1918
+ _tmp = apply(:_args)
1919
+ as = @result
1920
+ unless _tmp
1921
+ self.pos = _save2
1922
+ break
1923
+ end
1924
+ @result = begin; make(:application, l, n, as); end
1925
+ _tmp = true
1926
+ unless _tmp
1927
+ self.pos = _save2
1928
+ end
1929
+ break
1930
+ end # end sequence
1931
+
1932
+ break if _tmp
1933
+ self.pos = _save
1934
+ break
1935
+ end # end choice
1936
+
1937
+ set_failed_rule :_apply unless _tmp
1938
+ return _tmp
1939
+ end
1940
+
1941
+ # name = (line:l name:n op_letter:o {make(:postfix, l, n, o)} | grouped | level0)
1942
+ def _name
1943
+
1944
+ _save = self.pos
1945
+ while true # choice
1946
+
1947
+ _save1 = self.pos
1948
+ while true # sequence
1949
+ _tmp = apply(:_line)
1950
+ l = @result
1951
+ unless _tmp
1952
+ self.pos = _save1
1953
+ break
1954
+ end
1955
+ _tmp = apply(:_name)
1956
+ n = @result
1957
+ unless _tmp
1958
+ self.pos = _save1
1959
+ break
1960
+ end
1961
+ _tmp = apply(:_op_letter)
1962
+ o = @result
1963
+ unless _tmp
1964
+ self.pos = _save1
1965
+ break
1966
+ end
1967
+ @result = begin; make(:postfix, l, n, o); end
1968
+ _tmp = true
1969
+ unless _tmp
1970
+ self.pos = _save1
1971
+ end
1972
+ break
1973
+ end # end sequence
1974
+
1975
+ break if _tmp
1976
+ self.pos = _save
1977
+ _tmp = apply(:_grouped)
1978
+ break if _tmp
1979
+ self.pos = _save
1980
+ _tmp = apply(:_level0)
1981
+ break if _tmp
1982
+ self.pos = _save
1983
+ break
1984
+ end # end choice
1985
+
1986
+ set_failed_rule :_name unless _tmp
1987
+ return _tmp
1988
+ end
1989
+
1990
+ # args = "(" wsp expressions?:as wsp ")" { Array(as) }
1991
+ def _args
1992
+
1993
+ _save = self.pos
1994
+ while true # sequence
1995
+ _tmp = match_string("(")
1996
+ unless _tmp
1997
+ self.pos = _save
1998
+ break
1999
+ end
2000
+ _tmp = apply(:_wsp)
2001
+ unless _tmp
2002
+ self.pos = _save
2003
+ break
2004
+ end
2005
+ _save1 = self.pos
2006
+ _tmp = apply(:_expressions)
2007
+ @result = nil unless _tmp
2008
+ unless _tmp
2009
+ _tmp = true
2010
+ self.pos = _save1
2011
+ end
2012
+ as = @result
2013
+ unless _tmp
2014
+ self.pos = _save
2015
+ break
2016
+ end
2017
+ _tmp = apply(:_wsp)
2018
+ unless _tmp
2019
+ self.pos = _save
2020
+ break
2021
+ end
2022
+ _tmp = match_string(")")
2023
+ unless _tmp
2024
+ self.pos = _save
2025
+ break
2026
+ end
2027
+ @result = begin; Array(as) ; end
2028
+ _tmp = true
2029
+ unless _tmp
2030
+ self.pos = _save
2031
+ end
2032
+ break
2033
+ end # end sequence
2034
+
2035
+ set_failed_rule :_args unless _tmp
2036
+ return _tmp
2037
+ end
2038
+
2039
+ # compose = @composes(current_position)
2040
+ def _compose
2041
+ _tmp = _composes(current_position)
2042
+ set_failed_rule :_compose unless _tmp
2043
+ return _tmp
2044
+ end
2045
+
2046
+ # composes = (line:line compose:l cont(p) level2:r {make(:compose, line, l, r)} | line:line level2:l cont(p) level2:r {make(:compose, line, l, r)})
2047
+ def _composes(p)
2048
+
2049
+ _save = self.pos
2050
+ while true # choice
2051
+
2052
+ _save1 = self.pos
2053
+ while true # sequence
2054
+ _tmp = apply(:_line)
2055
+ line = @result
2056
+ unless _tmp
2057
+ self.pos = _save1
2058
+ break
2059
+ end
2060
+ _tmp = apply(:_compose)
2061
+ l = @result
2062
+ unless _tmp
2063
+ self.pos = _save1
2064
+ break
2065
+ end
2066
+ _tmp = apply_with_args(:_cont, p)
2067
+ unless _tmp
2068
+ self.pos = _save1
2069
+ break
2070
+ end
2071
+ _tmp = apply(:_level2)
2072
+ r = @result
2073
+ unless _tmp
2074
+ self.pos = _save1
2075
+ break
2076
+ end
2077
+ @result = begin; make(:compose, line, l, r); end
2078
+ _tmp = true
2079
+ unless _tmp
2080
+ self.pos = _save1
2081
+ end
2082
+ break
2083
+ end # end sequence
2084
+
2085
+ break if _tmp
2086
+ self.pos = _save
2087
+
2088
+ _save2 = self.pos
2089
+ while true # sequence
2090
+ _tmp = apply(:_line)
2091
+ line = @result
2092
+ unless _tmp
2093
+ self.pos = _save2
2094
+ break
2095
+ end
2096
+ _tmp = apply(:_level2)
2097
+ l = @result
2098
+ unless _tmp
2099
+ self.pos = _save2
2100
+ break
2101
+ end
2102
+ _tmp = apply_with_args(:_cont, p)
2103
+ unless _tmp
2104
+ self.pos = _save2
2105
+ break
2106
+ end
2107
+ _tmp = apply(:_level2)
2108
+ r = @result
2109
+ unless _tmp
2110
+ self.pos = _save2
2111
+ break
2112
+ end
2113
+ @result = begin; make(:compose, line, l, r); end
2114
+ _tmp = true
2115
+ unless _tmp
2116
+ self.pos = _save2
2117
+ end
2118
+ break
2119
+ end # end sequence
2120
+
2121
+ break if _tmp
2122
+ self.pos = _save
2123
+ break
2124
+ end # end choice
2125
+
2126
+ set_failed_rule :_composes unless _tmp
2127
+ return _tmp
2128
+ end
2129
+
2130
+ # infix = @infixes(current_position)
2131
+ def _infix
2132
+ _tmp = _infixes(current_position)
2133
+ set_failed_rule :_infix unless _tmp
2134
+ return _tmp
2135
+ end
2136
+
2137
+ # infixes = (line:line level3:l scont(p) operator:o scont(p) level3:r {make(:infix, line, l, r, o)} | line:line operator:o scont(p) level3:r {make(:infix, line, nil, r, o)})
2138
+ def _infixes(p)
2139
+
2140
+ _save = self.pos
2141
+ while true # choice
2142
+
2143
+ _save1 = self.pos
2144
+ while true # sequence
2145
+ _tmp = apply(:_line)
2146
+ line = @result
2147
+ unless _tmp
2148
+ self.pos = _save1
2149
+ break
2150
+ end
2151
+ _tmp = apply(:_level3)
2152
+ l = @result
2153
+ unless _tmp
2154
+ self.pos = _save1
2155
+ break
2156
+ end
2157
+ _tmp = apply_with_args(:_scont, p)
2158
+ unless _tmp
2159
+ self.pos = _save1
2160
+ break
2161
+ end
2162
+ _tmp = apply(:_operator)
2163
+ o = @result
2164
+ unless _tmp
2165
+ self.pos = _save1
2166
+ break
2167
+ end
2168
+ _tmp = apply_with_args(:_scont, p)
2169
+ unless _tmp
2170
+ self.pos = _save1
2171
+ break
2172
+ end
2173
+ _tmp = apply(:_level3)
2174
+ r = @result
2175
+ unless _tmp
2176
+ self.pos = _save1
2177
+ break
2178
+ end
2179
+ @result = begin; make(:infix, line, l, r, o); end
2180
+ _tmp = true
2181
+ unless _tmp
2182
+ self.pos = _save1
2183
+ end
2184
+ break
2185
+ end # end sequence
2186
+
2187
+ break if _tmp
2188
+ self.pos = _save
2189
+
2190
+ _save2 = self.pos
2191
+ while true # sequence
2192
+ _tmp = apply(:_line)
2193
+ line = @result
2194
+ unless _tmp
2195
+ self.pos = _save2
2196
+ break
2197
+ end
2198
+ _tmp = apply(:_operator)
2199
+ o = @result
2200
+ unless _tmp
2201
+ self.pos = _save2
2202
+ break
2203
+ end
2204
+ _tmp = apply_with_args(:_scont, p)
2205
+ unless _tmp
2206
+ self.pos = _save2
2207
+ break
2208
+ end
2209
+ _tmp = apply(:_level3)
2210
+ r = @result
2211
+ unless _tmp
2212
+ self.pos = _save2
2213
+ break
2214
+ end
2215
+ @result = begin; make(:infix, line, nil, r, o); end
2216
+ _tmp = true
2217
+ unless _tmp
2218
+ self.pos = _save2
2219
+ end
2220
+ break
2221
+ end # end sequence
2222
+
2223
+ break if _tmp
2224
+ self.pos = _save
2225
+ break
2226
+ end # end choice
2227
+
2228
+ set_failed_rule :_infixes unless _tmp
2229
+ return _tmp
2230
+ end
2231
+
2232
+ Rules = {}
2233
+ Rules[:_root] = rule_info("root", "shebang? wsp expressions?:es wsp !. { sequence(Array(es)) }")
2234
+ Rules[:_shebang] = rule_info("shebang", "\"\#!\" /.*?$/")
2235
+ Rules[:_expressions] = rule_info("expressions", "{current_column}:c expression:x (delim(c) expression)*:xs { [x] + Array(xs) }")
2236
+ Rules[:_delim] = rule_info("delim", "(wsp \",\" wsp | (sp \"\\n\" sp)+ &{ current_column >= c })")
2237
+ Rules[:_expression] = rule_info("expression", "level4")
2238
+ Rules[:_one_expression] = rule_info("one_expression", "wsp expression:e wsp !. { e }")
2239
+ Rules[:_line] = rule_info("line", "{current_line}")
2240
+ Rules[:_cont] = rule_info("cont", "(scont(p) | !\"(\")")
2241
+ Rules[:_scont] = rule_info("scont", "((\"\\n\" sp)+ &{ continue?(p) } | sig_sp cont(p)?)")
2242
+ Rules[:_sp] = rule_info("sp", "(\" \" | \"\\t\" | comment)*")
2243
+ Rules[:_wsp] = rule_info("wsp", "(\" \" | \"\\t\" | \"\\n\" | comment)*")
2244
+ Rules[:_sig_sp] = rule_info("sig_sp", "(\" \" | \"\\t\" | comment)+")
2245
+ Rules[:_sig_wsp] = rule_info("sig_wsp", "(\" \" | \"\\t\" | \"\\n\" | comment)+")
2246
+ Rules[:_comment] = rule_info("comment", "(/--.*?$/ | multi_comment)")
2247
+ Rules[:_multi_comment] = rule_info("multi_comment", "\"{-\" in_multi")
2248
+ Rules[:_in_multi] = rule_info("in_multi", "(/[^\\-\\{\\}]*/ \"-}\" | /[^\\-\\{\\}]*/ \"{-\" in_multi /[^\\-\\{\\}]*/ \"-}\" | /[^\\-\\{\\}]*/ /[-{}]/ in_multi)")
2249
+ Rules[:_op_letter] = rule_info("op_letter", "< /[$+<=>^|~!@\#%&*\\-\\\\.\\/\\?]/ > { text.to_sym }")
2250
+ Rules[:_operator] = rule_info("operator", "< op_letter+ > { text.to_sym }")
2251
+ Rules[:_identifier] = rule_info("identifier", "< /[a-z_][a-zA-Z\\d\\-_]*/ > { text.tr(\"-\", \"_\").to_sym }")
2252
+ Rules[:_language] = rule_info("language", "\"\#language\" wsp identifier:n {set_lang(n)} %lang.root")
2253
+ Rules[:_level0] = rule_info("level0", "(number | quote | quasi_quote | unquote | string | constant | word | block | list | prefix)")
2254
+ Rules[:_level1] = rule_info("level1", "(apply | grouped | level0)")
2255
+ Rules[:_level2] = rule_info("level2", "(postfix | level1)")
2256
+ Rules[:_level3] = rule_info("level3", "(compose | level2)")
2257
+ Rules[:_level4] = rule_info("level4", "(language | infix | level3)")
2258
+ Rules[:_grouped] = rule_info("grouped", "\"(\" wsp expression:x wsp \")\" { x }")
2259
+ Rules[:_number] = rule_info("number", "(line:l < /[\\+\\-]?0[oO][0-7]+/ > {make(:number, l, text.to_i(8))} | line:l < /[\\+\\-]?0[xX][\\da-fA-F]+/ > {make(:number, l, text.to_i(16))} | line:l < /[\\+\\-]?\\d+(\\.\\d+)?[eE][\\+\\-]?\\d+/ > {make(:literal, l, text.to_f)} | line:l < /[\\+\\-]?\\d+\\.\\d+/ > {make(:literal, l, text.to_f)} | line:l < /[\\+\\-]?\\d+/ > {make(:number, l, text.to_i)})")
2260
+ Rules[:_string] = rule_info("string", "line:line \"\\\"\" < (\"\\\\\" . | /[^\\\\\"]/)*:c > \"\\\"\" {make(:strliteral, line, text.gsub(\"\\\\\\\"\", \"\\\"\"))}")
2261
+ Rules[:_constant] = rule_info("constant", "line:l < /[A-Z][a-zA-Z0-9_]*/ > {make(:constant, l, text.to_sym)}")
2262
+ Rules[:_word] = rule_info("word", "line:l identifier:n {make(:word, l, n)}")
2263
+ Rules[:_quote] = rule_info("quote", "line:l \"'\" level2:e {make(:make, l, :quote, l, e)}")
2264
+ Rules[:_quasi_quote] = rule_info("quasi_quote", "line:l \"`\" level2:e {make(:quasiquote, l, e)}")
2265
+ Rules[:_unquote] = rule_info("unquote", "line:l \"~\" level2:e {make(:unquote, l, e)}")
2266
+ Rules[:_prefix] = rule_info("prefix", "line:l op_letter:o level2:e {make(:prefix, l, e, o)}")
2267
+ Rules[:_postfix] = rule_info("postfix", "(line:l postfix:e op_letter:o {make(:postfix, l, e, o)} | line:l level1:e op_letter:o {make(:postfix, l, e, o)})")
2268
+ Rules[:_block] = rule_info("block", "(line:l \":\" wsp expressions?:es (wsp \";\")? {make(:block, l, Array(es))} | line:l \"{\" wsp expressions?:es wsp \"}\" {make(:block, l, Array(es))})")
2269
+ Rules[:_list] = rule_info("list", "line:l \"[\" wsp expressions?:es wsp \"]\" {make(:list, l, Array(es))}")
2270
+ Rules[:_apply] = rule_info("apply", "(line:l apply:a args:as {make(:application, l, a, as)} | line:l name:n args:as {make(:application, l, n, as)})")
2271
+ Rules[:_name] = rule_info("name", "(line:l name:n op_letter:o {make(:postfix, l, n, o)} | grouped | level0)")
2272
+ Rules[:_args] = rule_info("args", "\"(\" wsp expressions?:as wsp \")\" { Array(as) }")
2273
+ Rules[:_compose] = rule_info("compose", "@composes(current_position)")
2274
+ Rules[:_composes] = rule_info("composes", "(line:line compose:l cont(p) level2:r {make(:compose, line, l, r)} | line:line level2:l cont(p) level2:r {make(:compose, line, l, r)})")
2275
+ Rules[:_infix] = rule_info("infix", "@infixes(current_position)")
2276
+ Rules[:_infixes] = rule_info("infixes", "(line:line level3:l scont(p) operator:o scont(p) level3:r {make(:infix, line, l, r, o)} | line:line operator:o scont(p) level3:r {make(:infix, line, nil, r, o)})")
2277
+ # :startdoc:
2278
+ end