atomy 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/COPYING +30 -0
  2. data/README.md +1 -0
  3. data/bin/atomy +134 -0
  4. data/kernel/block.ay +30 -0
  5. data/kernel/boot.ay +10 -0
  6. data/kernel/comparison.ay +61 -0
  7. data/kernel/concurrency.ay +84 -0
  8. data/kernel/condition.ay +277 -0
  9. data/kernel/control-flow.ay +222 -0
  10. data/kernel/cosmetics.ay +3 -0
  11. data/kernel/data-delta.ay +105 -0
  12. data/kernel/data.ay +56 -0
  13. data/kernel/define.ay +93 -0
  14. data/kernel/doc.ay +453 -0
  15. data/kernel/documentation.ay +135 -0
  16. data/kernel/dynamic.ay +42 -0
  17. data/kernel/errors.ay +6 -0
  18. data/kernel/format.ay +13 -0
  19. data/kernel/format/data.ay +89 -0
  20. data/kernel/format/formatter.ay +345 -0
  21. data/kernel/format/parser.ay +13 -0
  22. data/kernel/hashes.ay +39 -0
  23. data/kernel/io.ay +244 -0
  24. data/kernel/namespaces.ay +63 -0
  25. data/kernel/node.ay +48 -0
  26. data/kernel/operators.ay +28 -0
  27. data/kernel/particles.ay +53 -0
  28. data/kernel/patterns.ay +256 -0
  29. data/kernel/precision.ay +148 -0
  30. data/kernel/pretty.ay +283 -0
  31. data/kernel/repl.ay +140 -0
  32. data/kernel/therie.ay +204 -0
  33. data/lib/ast/binary_send.rb +44 -0
  34. data/lib/ast/block.rb +268 -0
  35. data/lib/ast/constant.rb +88 -0
  36. data/lib/ast/internal/assign.rb +19 -0
  37. data/lib/ast/internal/block_pass.rb +21 -0
  38. data/lib/ast/internal/catch.rb +247 -0
  39. data/lib/ast/internal/class.rb +30 -0
  40. data/lib/ast/internal/class_variable.rb +23 -0
  41. data/lib/ast/internal/define.rb +174 -0
  42. data/lib/ast/internal/ensure.rb +135 -0
  43. data/lib/ast/internal/file.rb +14 -0
  44. data/lib/ast/internal/global_variable.rb +20 -0
  45. data/lib/ast/internal/if_then_else.rb +24 -0
  46. data/lib/ast/internal/instance_variable.rb +17 -0
  47. data/lib/ast/internal/let_macro.rb +35 -0
  48. data/lib/ast/internal/macro_quote.rb +23 -0
  49. data/lib/ast/internal/match.rb +53 -0
  50. data/lib/ast/internal/module.rb +30 -0
  51. data/lib/ast/internal/pattern.rb +17 -0
  52. data/lib/ast/internal/return.rb +29 -0
  53. data/lib/ast/internal/set.rb +19 -0
  54. data/lib/ast/internal/singleton_class.rb +18 -0
  55. data/lib/ast/internal/splat.rb +14 -0
  56. data/lib/ast/internal/when.rb +24 -0
  57. data/lib/ast/list.rb +25 -0
  58. data/lib/ast/macro.rb +37 -0
  59. data/lib/ast/node.rb +599 -0
  60. data/lib/ast/operator.rb +21 -0
  61. data/lib/ast/particle.rb +13 -0
  62. data/lib/ast/primitive.rb +20 -0
  63. data/lib/ast/quasi_quote.rb +20 -0
  64. data/lib/ast/quote.rb +13 -0
  65. data/lib/ast/send.rb +104 -0
  66. data/lib/ast/splice.rb +32 -0
  67. data/lib/ast/string.rb +23 -0
  68. data/lib/ast/unary.rb +44 -0
  69. data/lib/ast/unquote.rb +45 -0
  70. data/lib/ast/variable.rb +64 -0
  71. data/lib/atomy.kpeg.rb +3995 -0
  72. data/lib/code_loader.rb +137 -0
  73. data/lib/compiler/compiler.rb +155 -0
  74. data/lib/compiler/stages.rb +81 -0
  75. data/lib/formatter.kpeg.rb +1394 -0
  76. data/lib/macros.rb +317 -0
  77. data/lib/method.rb +261 -0
  78. data/lib/namespace.rb +236 -0
  79. data/lib/parser.rb +28 -0
  80. data/lib/patterns.rb +276 -0
  81. data/lib/patterns/any.rb +21 -0
  82. data/lib/patterns/attribute.rb +59 -0
  83. data/lib/patterns/block_pass.rb +54 -0
  84. data/lib/patterns/constant.rb +33 -0
  85. data/lib/patterns/default.rb +44 -0
  86. data/lib/patterns/head_tail.rb +63 -0
  87. data/lib/patterns/list.rb +77 -0
  88. data/lib/patterns/match.rb +45 -0
  89. data/lib/patterns/named.rb +55 -0
  90. data/lib/patterns/named_class.rb +46 -0
  91. data/lib/patterns/named_global.rb +46 -0
  92. data/lib/patterns/named_instance.rb +46 -0
  93. data/lib/patterns/particle.rb +29 -0
  94. data/lib/patterns/quasi_quote.rb +184 -0
  95. data/lib/patterns/quote.rb +33 -0
  96. data/lib/patterns/singleton_class.rb +31 -0
  97. data/lib/patterns/splat.rb +57 -0
  98. data/lib/util.rb +37 -0
  99. metadata +164 -0
@@ -0,0 +1,21 @@
1
+ module Atomy
2
+ module AST
3
+ class Operator < Node
4
+ attributes [:operators], :associativity, :precedence
5
+ generate
6
+
7
+ def bytecode(g)
8
+ pos(g)
9
+ g.push_const :Atomy
10
+ g.find_const :Macro
11
+ @operators.each do |o|
12
+ g.push_literal o
13
+ end
14
+ g.make_array @operators.size
15
+ g.push_literal @associativity
16
+ g.push_int @precedence
17
+ g.send :set_op_info, 3
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ module Atomy
2
+ module AST
3
+ class Particle < Node
4
+ attributes :name
5
+ generate
6
+
7
+ def bytecode(g)
8
+ pos(g)
9
+ g.push_literal @name.to_sym
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ module Atomy
2
+ module AST
3
+ class Primitive < Node
4
+ attributes :value
5
+ generate
6
+
7
+ def bytecode(g)
8
+ pos(g)
9
+
10
+ # TODO: `(~#true) will break here
11
+ case @value
12
+ when :true, :false, :self, :nil, Integer
13
+ g.push @value
14
+ else
15
+ g.push_literal @value
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Atomy
2
+ module AST
3
+ class QuasiQuote < Node
4
+ children :expression
5
+ generate
6
+
7
+ def construct(g, d = nil)
8
+ get(g)
9
+ g.push_int @line
10
+ @expression.construct(g, quote(d))
11
+ g.send :new, 2
12
+ end
13
+
14
+ def bytecode(g)
15
+ pos(g)
16
+ @expression.recursively(&:resolve).construct(g, 1)
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/ast/quote.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Atomy
2
+ module AST
3
+ class Quote < Node
4
+ children :expression
5
+ generate
6
+
7
+ def bytecode(g)
8
+ pos(g)
9
+ @expression.recursively(&:resolve).construct(g)
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/ast/send.rb ADDED
@@ -0,0 +1,104 @@
1
+ module Atomy
2
+ module AST
3
+ class Send < Node
4
+ children :receiver, [:arguments], :message?, :block?
5
+ attributes :method_name?
6
+ slots [:private, "false"], :namespace?
7
+ generate
8
+
9
+ def self.new(*args)
10
+ super.resolve_message
11
+ end
12
+
13
+ def resolve_message
14
+ res = self
15
+
16
+ if res.message
17
+ res = res.message.as_message(self)
18
+ res.message = nil if res.method_name
19
+ end
20
+
21
+ res
22
+ end
23
+
24
+ def register_macro(body, let = false)
25
+ Atomy::Macro.register(
26
+ @method_name,
27
+ ([@receiver] + @arguments).collect do |n|
28
+ Atomy::Macro.macro_pattern n
29
+ end,
30
+ body,
31
+ let
32
+ )
33
+ end
34
+
35
+ def message_name
36
+ Atomy.namespaced(@namespace, @method_name)
37
+ end
38
+
39
+ def to_send
40
+ self
41
+ end
42
+
43
+ def prepare
44
+ resolve.expand
45
+ end
46
+
47
+ def bytecode(g)
48
+ pos(g)
49
+
50
+ @receiver.compile(g)
51
+
52
+ block = @block
53
+ splat = nil
54
+
55
+ unless @namespace == "_"
56
+ g.push_literal message_name.to_sym
57
+ end
58
+
59
+ args = 0
60
+ @arguments.each do |a|
61
+ e = a.prepare
62
+ if e.kind_of?(BlockPass)
63
+ block = e
64
+ break
65
+ elsif e.kind_of?(Splat)
66
+ splat = e
67
+ break
68
+ end
69
+
70
+ e.bytecode(g)
71
+ args += 1
72
+ end
73
+
74
+ if splat
75
+ splat.compile(g)
76
+ if block
77
+ block.compile(g)
78
+ else
79
+ g.push_nil
80
+ end
81
+ if @namespace == "_"
82
+ g.send_with_splat @method_name.to_sym, args, @private
83
+ else
84
+ g.send_with_splat :atomy_send, args + 1
85
+ #g.call_custom_with_splat message_name.to_sym, args
86
+ end
87
+ elsif block
88
+ block.compile(g)
89
+ if @namespace == "_"
90
+ g.send_with_block @method_name.to_sym, args, @private
91
+ else
92
+ g.send_with_block :atomy_send, args + 1
93
+ #g.call_custom_with_block message_name.to_sym, args
94
+ end
95
+ elsif @namespace == "_"
96
+ g.send @method_name.to_sym, args, @private
97
+ else
98
+ g.send :atomy_send, args + 1
99
+ #g.call_custom message_name.to_sym, args
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
data/lib/ast/splice.rb ADDED
@@ -0,0 +1,32 @@
1
+ module Atomy
2
+ module AST
3
+ class Splice < Node
4
+ children :expression
5
+ generate
6
+
7
+ def construct(g, d = nil)
8
+ pos(g)
9
+ # TODO: fail if depth == 0
10
+ if d == 1
11
+ @expression.compile(g)
12
+ else
13
+ get(g)
14
+ g.push_int @line
15
+ @expression.construct(g, unquote(d))
16
+ g.send :new, 2
17
+ end
18
+ end
19
+
20
+ def bytecode(g)
21
+ pos(g)
22
+ # TODO: this should raise an exception since
23
+ # it'll only happen outside of a quasiquote.
24
+ g.push_literal @expression
25
+ end
26
+
27
+ def unquote?
28
+ true
29
+ end
30
+ end
31
+ end
32
+ end
data/lib/ast/string.rb ADDED
@@ -0,0 +1,23 @@
1
+ module Atomy
2
+ module AST
3
+ class String < Node
4
+ attributes :value, :raw?
5
+ generate
6
+
7
+ def bytecode(g)
8
+ pos(g)
9
+ g.push_literal @value
10
+ g.string_dup
11
+ end
12
+
13
+ def as_message(send)
14
+ MacroQuote.new(
15
+ @line,
16
+ send.receiver.name,
17
+ @raw || @value,
18
+ send.arguments.collect(&:name)
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/ast/unary.rb ADDED
@@ -0,0 +1,44 @@
1
+ # TODO: ensure binary sends do not end with @
2
+ module Atomy
3
+ module AST
4
+ class Unary < Node
5
+ children :receiver
6
+ attributes :operator
7
+ slots :namespace?
8
+ generate
9
+
10
+ def register_macro(body, let = false)
11
+ Atomy::Macro.register(
12
+ @operator + "@",
13
+ [Atomy::Macro.macro_pattern(@receiver)],
14
+ body,
15
+ let
16
+ )
17
+ end
18
+
19
+ def message_name
20
+ Atomy.namespaced(@namespace, @operator)
21
+ end
22
+
23
+ def prepare
24
+ resolve.expand
25
+ end
26
+
27
+ def bytecode(g)
28
+ pos(g)
29
+ @receiver.compile(g)
30
+ if @namespace == "_"
31
+ g.send @operator.to_sym, 0
32
+ else
33
+ g.push_literal message_name.to_sym
34
+ g.send :atomy_send, 1
35
+ #g.call_custom method_name.to_sym, 0
36
+ end
37
+ end
38
+
39
+ def method_name
40
+ @operator + "@"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,45 @@
1
+ module Atomy
2
+ module AST
3
+ class Unquote < Node
4
+ children :expression
5
+ generate
6
+
7
+ def construct(g, d = nil)
8
+ pos(g)
9
+ # TODO: fail if depth == 0
10
+ if d == 1
11
+ @expression.compile(g)
12
+ g.send :to_node, 0
13
+ elsif @expression.kind_of?(Splice) && d == 2
14
+ @expression.get(g)
15
+ g.push_int @line
16
+ g.push_cpath_top
17
+ g.find_const :Atomy
18
+ @expression.expression.compile(g)
19
+ g.send :unquote_splice, 1
20
+ g.send :new, 2
21
+ else
22
+ get(g)
23
+ g.push_int @line
24
+ @expression.construct(g, unquote(d))
25
+ g.send :new, 2
26
+ end
27
+ end
28
+
29
+ def bytecode(g)
30
+ pos(g)
31
+ # TODO: this should raise an exception since
32
+ # it'll only happen outside of a quasiquote.
33
+ g.push_literal @expression
34
+ end
35
+
36
+ def unquote?
37
+ true
38
+ end
39
+
40
+ def as_message(send)
41
+ send
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,64 @@
1
+ module Atomy
2
+ module AST
3
+ class Variable < Node
4
+ attributes :name
5
+ slots :namespace?
6
+ generate
7
+
8
+ def self.new(*as)
9
+ x = super
10
+ unless x.namespace
11
+ x.namespace, x.name = Atomy.from_namespaced(x.name)
12
+ end
13
+ x
14
+ end
15
+
16
+ def register_macro(body, let = false)
17
+ Atomy::Macro.register(
18
+ method_name,
19
+ [],
20
+ body,
21
+ let
22
+ )
23
+ end
24
+
25
+ def prepare
26
+ resolve.expand
27
+ end
28
+
29
+ def message_name
30
+ Atomy.namespaced(@namespace, @name)
31
+ end
32
+
33
+ def bytecode(g)
34
+ pos(g)
35
+
36
+ var = g.state.scope.search_local(@name)
37
+ if var
38
+ var.get_bytecode(g)
39
+ else
40
+ g.push_self
41
+ g.push_literal message_name.to_sym
42
+ g.send :atomy_send, 1
43
+ #g.call_custom message_name.to_sym, 0
44
+ end
45
+ end
46
+
47
+ # used in macroexpansion
48
+ def method_name
49
+ name + ":@"
50
+ end
51
+
52
+ def namespace_symbol
53
+ name.to_sym
54
+ end
55
+
56
+ def as_message(send)
57
+ send.dup.tap do |s|
58
+ s.method_name = @name
59
+ s.namespace = @namespace
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
data/lib/atomy.kpeg.rb ADDED
@@ -0,0 +1,3995 @@
1
+ class Atomy::Parser
2
+ # STANDALONE START
3
+ def setup_parser(str, debug=false)
4
+ @string = str
5
+ @pos = 0
6
+ @memoizations = Hash.new { |h,k| h[k] = {} }
7
+ @result = nil
8
+ @failed_rule = nil
9
+ @failing_rule_offset = -1
10
+
11
+ setup_foreign_grammar
12
+ end
13
+
14
+ # This is distinct from setup_parser so that a standalone parser
15
+ # can redefine #initialize and still have access to the proper
16
+ # parser setup code.
17
+ #
18
+ def initialize(str, debug=false)
19
+ setup_parser(str, debug)
20
+ end
21
+
22
+ attr_reader :string
23
+ attr_reader :failing_rule_offset
24
+ attr_accessor :result, :pos
25
+
26
+ # STANDALONE START
27
+ def current_column(target=pos)
28
+ if c = string.rindex("\n", target-1)
29
+ return target - c - 1
30
+ end
31
+
32
+ target + 1
33
+ end
34
+
35
+ def current_line(target=pos)
36
+ cur_offset = 0
37
+ cur_line = 0
38
+
39
+ string.each_line do |line|
40
+ cur_line += 1
41
+ cur_offset += line.size
42
+ return cur_line if cur_offset >= target
43
+ end
44
+
45
+ -1
46
+ end
47
+
48
+ def lines
49
+ lines = []
50
+ string.each_line { |l| lines << l }
51
+ lines
52
+ end
53
+
54
+ #
55
+
56
+ def get_text(start)
57
+ @string[start..@pos-1]
58
+ end
59
+
60
+ def show_pos
61
+ width = 10
62
+ if @pos < width
63
+ "#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
64
+ else
65
+ "#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
66
+ end
67
+ end
68
+
69
+ def failure_info
70
+ l = current_line @failing_rule_offset
71
+ c = current_column @failing_rule_offset
72
+
73
+ if @failed_rule.kind_of? Symbol
74
+ info = self.class::Rules[@failed_rule]
75
+ "line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
76
+ else
77
+ "line #{l}, column #{c}: failed rule '#{@failed_rule}'"
78
+ end
79
+ end
80
+
81
+ def failure_caret
82
+ l = current_line @failing_rule_offset
83
+ c = current_column @failing_rule_offset
84
+
85
+ line = lines[l-1]
86
+ "#{line}\n#{' ' * (c - 1)}^"
87
+ end
88
+
89
+ def failure_character
90
+ l = current_line @failing_rule_offset
91
+ c = current_column @failing_rule_offset
92
+ lines[l-1][c-1, 1]
93
+ end
94
+
95
+ def failure_oneline
96
+ l = current_line @failing_rule_offset
97
+ c = current_column @failing_rule_offset
98
+
99
+ char = lines[l-1][c-1, 1]
100
+
101
+ if @failed_rule.kind_of? Symbol
102
+ info = self.class::Rules[@failed_rule]
103
+ "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
104
+ else
105
+ "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
106
+ end
107
+ end
108
+
109
+ class ParseError < RuntimeError
110
+ end
111
+
112
+ def raise_error
113
+ raise ParseError, failure_oneline
114
+ end
115
+
116
+ def show_error(io=STDOUT)
117
+ error_pos = @failing_rule_offset
118
+ line_no = current_line(error_pos)
119
+ col_no = current_column(error_pos)
120
+
121
+ io.puts "On line #{line_no}, column #{col_no}:"
122
+
123
+ if @failed_rule.kind_of? Symbol
124
+ info = self.class::Rules[@failed_rule]
125
+ io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
126
+ else
127
+ io.puts "Failed to match rule '#{@failed_rule}'"
128
+ end
129
+
130
+ io.puts "Got: #{string[error_pos,1].inspect}"
131
+ line = lines[line_no-1]
132
+ io.puts "=> #{line}"
133
+ io.print(" " * (col_no + 3))
134
+ io.puts "^"
135
+ end
136
+
137
+ def set_failed_rule(name)
138
+ if @pos > @failing_rule_offset
139
+ @failed_rule = name
140
+ @failing_rule_offset = @pos
141
+ end
142
+ end
143
+
144
+ attr_reader :failed_rule
145
+
146
+ def match_string(str)
147
+ len = str.size
148
+ if @string[pos,len] == str
149
+ @pos += len
150
+ return str
151
+ end
152
+
153
+ return nil
154
+ end
155
+
156
+ def scan(reg)
157
+ if m = reg.match(@string[@pos..-1])
158
+ width = m.end(0)
159
+ @pos += width
160
+ return true
161
+ end
162
+
163
+ return nil
164
+ end
165
+
166
+ if "".respond_to? :getbyte
167
+ def get_byte
168
+ if @pos >= @string.size
169
+ return nil
170
+ end
171
+
172
+ s = @string.getbyte @pos
173
+ @pos += 1
174
+ s
175
+ end
176
+ else
177
+ def get_byte
178
+ if @pos >= @string.size
179
+ return nil
180
+ end
181
+
182
+ s = @string[@pos]
183
+ @pos += 1
184
+ s
185
+ end
186
+ end
187
+
188
+ def parse(rule=nil)
189
+ if !rule
190
+ _root ? true : false
191
+ else
192
+ # This is not shared with code_generator.rb so this can be standalone
193
+ method = rule.gsub("-","_hyphen_")
194
+ __send__("_#{method}") ? true : false
195
+ end
196
+ end
197
+
198
+ class LeftRecursive
199
+ def initialize(detected=false)
200
+ @detected = detected
201
+ end
202
+
203
+ attr_accessor :detected
204
+ end
205
+
206
+ class MemoEntry
207
+ def initialize(ans, pos)
208
+ @ans = ans
209
+ @pos = pos
210
+ @uses = 1
211
+ @result = nil
212
+ end
213
+
214
+ attr_reader :ans, :pos, :uses, :result
215
+
216
+ def inc!
217
+ @uses += 1
218
+ end
219
+
220
+ def move!(ans, pos, result)
221
+ @ans = ans
222
+ @pos = pos
223
+ @result = result
224
+ end
225
+ end
226
+
227
+ def external_invoke(other, rule, *args)
228
+ old_pos = @pos
229
+ old_string = @string
230
+
231
+ @pos = other.pos
232
+ @string = other.string
233
+
234
+ begin
235
+ if val = __send__(rule, *args)
236
+ other.pos = @pos
237
+ other.result = @result
238
+ else
239
+ other.set_failed_rule "#{self.class}##{rule}"
240
+ end
241
+ val
242
+ ensure
243
+ @pos = old_pos
244
+ @string = old_string
245
+ end
246
+ end
247
+
248
+ def apply(rule)
249
+ if m = @memoizations[rule][@pos]
250
+ m.inc!
251
+
252
+ prev = @pos
253
+ @pos = m.pos
254
+ if m.ans.kind_of? LeftRecursive
255
+ m.ans.detected = true
256
+ return nil
257
+ end
258
+
259
+ @result = m.result
260
+
261
+ return m.ans
262
+ else
263
+ lr = LeftRecursive.new(false)
264
+ m = MemoEntry.new(lr, @pos)
265
+ @memoizations[rule][@pos] = m
266
+ start_pos = @pos
267
+
268
+ ans = __send__ rule
269
+
270
+ m.move! ans, @pos, @result
271
+
272
+ # Don't bother trying to grow the left recursion
273
+ # if it's failing straight away (thus there is no seed)
274
+ if ans and lr.detected
275
+ return grow_lr(rule, start_pos, m)
276
+ else
277
+ return ans
278
+ end
279
+
280
+ return ans
281
+ end
282
+ end
283
+
284
+ def grow_lr(rule, start_pos, m)
285
+ while true
286
+ @pos = start_pos
287
+ @result = m.result
288
+
289
+ ans = __send__ rule
290
+ return nil unless ans
291
+
292
+ break if @pos <= m.pos
293
+
294
+ m.move! ans, @pos, @result
295
+ end
296
+
297
+ @result = m.result
298
+ @pos = m.pos
299
+ return m.ans
300
+ end
301
+
302
+ class RuleInfo
303
+ def initialize(name, rendered)
304
+ @name = name
305
+ @rendered = rendered
306
+ end
307
+
308
+ attr_reader :name, :rendered
309
+ end
310
+
311
+ def self.rule_info(name, rendered)
312
+ RuleInfo.new(name, rendered)
313
+ end
314
+
315
+ #
316
+
317
+
318
+ def current_position(target=pos)
319
+ cur_offset = 0
320
+ cur_line = 0
321
+
322
+ line_lengths.each do |len|
323
+ cur_line += 1
324
+ return [cur_line, target - cur_offset] if cur_offset + len > target
325
+ cur_offset += len
326
+ end
327
+
328
+ [cur_line, cur_offset]
329
+ end
330
+
331
+ def line_lengths
332
+ @line_lengths ||= lines.collect { |l| l.size }
333
+ end
334
+
335
+ def continue?(x)
336
+ y = current_position
337
+ y[0] >= x[0] && y[1] > x[1]
338
+ end
339
+
340
+ def op_info(op)
341
+ Atomy::OPERATORS[op] || {}
342
+ end
343
+
344
+ def prec(o)
345
+ op_info(o)[:prec] || 5
346
+ end
347
+
348
+ def assoc(o)
349
+ op_info(o)[:assoc] || :left
350
+ end
351
+
352
+ def binary(o, l, r)
353
+ Atomy::AST::BinarySend.new(l.line, l, r, o)
354
+ end
355
+
356
+ def resolve(a, e, chain)
357
+ return [e, []] if chain.empty?
358
+
359
+ b, *rest = chain
360
+
361
+ if a && (prec(a) > prec(b) || (prec(a) == prec(b) && assoc(a) == :left))
362
+ [e, chain]
363
+ else
364
+ e2, *rest2 = rest
365
+ r, rest3 = resolve(b, e2, rest2)
366
+ resolve(a, binary(b, e, r), rest3)
367
+ end
368
+ end
369
+
370
+ def const_chain(l, ns, top = false)
371
+ p = nil
372
+ ns.each do |n|
373
+ if p
374
+ p = Atomy::AST::ScopedConstant.new(l, p, n)
375
+ elsif top
376
+ p = Atomy::AST::ToplevelConstant.new(l, n)
377
+ else
378
+ p = Atomy::AST::Constant.new(l, n)
379
+ end
380
+ end
381
+ p
382
+ end
383
+
384
+
385
+ def setup_foreign_grammar; end
386
+
387
+ # sp = (" " | "\t" | comment)*
388
+ def _sp
389
+ while true
390
+
391
+ _save1 = self.pos
392
+ while true # choice
393
+ _tmp = match_string(" ")
394
+ break if _tmp
395
+ self.pos = _save1
396
+ _tmp = match_string("\t")
397
+ break if _tmp
398
+ self.pos = _save1
399
+ _tmp = apply(:_comment)
400
+ break if _tmp
401
+ self.pos = _save1
402
+ break
403
+ end # end choice
404
+
405
+ break unless _tmp
406
+ end
407
+ _tmp = true
408
+ set_failed_rule :_sp unless _tmp
409
+ return _tmp
410
+ end
411
+
412
+ # wsp = (" " | "\t" | "\n" | comment)*
413
+ def _wsp
414
+ while true
415
+
416
+ _save1 = self.pos
417
+ while true # choice
418
+ _tmp = match_string(" ")
419
+ break if _tmp
420
+ self.pos = _save1
421
+ _tmp = match_string("\t")
422
+ break if _tmp
423
+ self.pos = _save1
424
+ _tmp = match_string("\n")
425
+ break if _tmp
426
+ self.pos = _save1
427
+ _tmp = apply(:_comment)
428
+ break if _tmp
429
+ self.pos = _save1
430
+ break
431
+ end # end choice
432
+
433
+ break unless _tmp
434
+ end
435
+ _tmp = true
436
+ set_failed_rule :_wsp unless _tmp
437
+ return _tmp
438
+ end
439
+
440
+ # sig_sp = (" " | "\t" | comment)+
441
+ def _sig_sp
442
+ _save = self.pos
443
+
444
+ _save1 = self.pos
445
+ while true # choice
446
+ _tmp = match_string(" ")
447
+ break if _tmp
448
+ self.pos = _save1
449
+ _tmp = match_string("\t")
450
+ break if _tmp
451
+ self.pos = _save1
452
+ _tmp = apply(:_comment)
453
+ break if _tmp
454
+ self.pos = _save1
455
+ break
456
+ end # end choice
457
+
458
+ if _tmp
459
+ while true
460
+
461
+ _save2 = self.pos
462
+ while true # choice
463
+ _tmp = match_string(" ")
464
+ break if _tmp
465
+ self.pos = _save2
466
+ _tmp = match_string("\t")
467
+ break if _tmp
468
+ self.pos = _save2
469
+ _tmp = apply(:_comment)
470
+ break if _tmp
471
+ self.pos = _save2
472
+ break
473
+ end # end choice
474
+
475
+ break unless _tmp
476
+ end
477
+ _tmp = true
478
+ else
479
+ self.pos = _save
480
+ end
481
+ set_failed_rule :_sig_sp unless _tmp
482
+ return _tmp
483
+ end
484
+
485
+ # sig_wsp = (" " | "\t" | "\n" | comment)+
486
+ def _sig_wsp
487
+ _save = self.pos
488
+
489
+ _save1 = self.pos
490
+ while true # choice
491
+ _tmp = match_string(" ")
492
+ break if _tmp
493
+ self.pos = _save1
494
+ _tmp = match_string("\t")
495
+ break if _tmp
496
+ self.pos = _save1
497
+ _tmp = match_string("\n")
498
+ break if _tmp
499
+ self.pos = _save1
500
+ _tmp = apply(:_comment)
501
+ break if _tmp
502
+ self.pos = _save1
503
+ break
504
+ end # end choice
505
+
506
+ if _tmp
507
+ while true
508
+
509
+ _save2 = self.pos
510
+ while true # choice
511
+ _tmp = match_string(" ")
512
+ break if _tmp
513
+ self.pos = _save2
514
+ _tmp = match_string("\t")
515
+ break if _tmp
516
+ self.pos = _save2
517
+ _tmp = match_string("\n")
518
+ break if _tmp
519
+ self.pos = _save2
520
+ _tmp = apply(:_comment)
521
+ break if _tmp
522
+ self.pos = _save2
523
+ break
524
+ end # end choice
525
+
526
+ break unless _tmp
527
+ end
528
+ _tmp = true
529
+ else
530
+ self.pos = _save
531
+ end
532
+ set_failed_rule :_sig_wsp unless _tmp
533
+ return _tmp
534
+ end
535
+
536
+ # cont = (("\n" sp)+ &{ continue?(p) } | sig_sp (("\n" sp)+ &{ continue?(p) })? | &.)
537
+ def _cont(p)
538
+
539
+ _save = self.pos
540
+ while true # choice
541
+
542
+ _save1 = self.pos
543
+ while true # sequence
544
+ _save2 = self.pos
545
+
546
+ _save3 = self.pos
547
+ while true # sequence
548
+ _tmp = match_string("\n")
549
+ unless _tmp
550
+ self.pos = _save3
551
+ break
552
+ end
553
+ _tmp = apply(:_sp)
554
+ unless _tmp
555
+ self.pos = _save3
556
+ end
557
+ break
558
+ end # end sequence
559
+
560
+ if _tmp
561
+ while true
562
+
563
+ _save4 = self.pos
564
+ while true # sequence
565
+ _tmp = match_string("\n")
566
+ unless _tmp
567
+ self.pos = _save4
568
+ break
569
+ end
570
+ _tmp = apply(:_sp)
571
+ unless _tmp
572
+ self.pos = _save4
573
+ end
574
+ break
575
+ end # end sequence
576
+
577
+ break unless _tmp
578
+ end
579
+ _tmp = true
580
+ else
581
+ self.pos = _save2
582
+ end
583
+ unless _tmp
584
+ self.pos = _save1
585
+ break
586
+ end
587
+ _save5 = self.pos
588
+ _tmp = begin; continue?(p) ; end
589
+ self.pos = _save5
590
+ unless _tmp
591
+ self.pos = _save1
592
+ end
593
+ break
594
+ end # end sequence
595
+
596
+ break if _tmp
597
+ self.pos = _save
598
+
599
+ _save6 = self.pos
600
+ while true # sequence
601
+ _tmp = apply(:_sig_sp)
602
+ unless _tmp
603
+ self.pos = _save6
604
+ break
605
+ end
606
+ _save7 = self.pos
607
+
608
+ _save8 = self.pos
609
+ while true # sequence
610
+ _save9 = self.pos
611
+
612
+ _save10 = self.pos
613
+ while true # sequence
614
+ _tmp = match_string("\n")
615
+ unless _tmp
616
+ self.pos = _save10
617
+ break
618
+ end
619
+ _tmp = apply(:_sp)
620
+ unless _tmp
621
+ self.pos = _save10
622
+ end
623
+ break
624
+ end # end sequence
625
+
626
+ if _tmp
627
+ while true
628
+
629
+ _save11 = self.pos
630
+ while true # sequence
631
+ _tmp = match_string("\n")
632
+ unless _tmp
633
+ self.pos = _save11
634
+ break
635
+ end
636
+ _tmp = apply(:_sp)
637
+ unless _tmp
638
+ self.pos = _save11
639
+ end
640
+ break
641
+ end # end sequence
642
+
643
+ break unless _tmp
644
+ end
645
+ _tmp = true
646
+ else
647
+ self.pos = _save9
648
+ end
649
+ unless _tmp
650
+ self.pos = _save8
651
+ break
652
+ end
653
+ _save12 = self.pos
654
+ _tmp = begin; continue?(p) ; end
655
+ self.pos = _save12
656
+ unless _tmp
657
+ self.pos = _save8
658
+ end
659
+ break
660
+ end # end sequence
661
+
662
+ unless _tmp
663
+ _tmp = true
664
+ self.pos = _save7
665
+ end
666
+ unless _tmp
667
+ self.pos = _save6
668
+ end
669
+ break
670
+ end # end sequence
671
+
672
+ break if _tmp
673
+ self.pos = _save
674
+ _save13 = self.pos
675
+ _tmp = get_byte
676
+ self.pos = _save13
677
+ break if _tmp
678
+ self.pos = _save
679
+ break
680
+ end # end choice
681
+
682
+ set_failed_rule :_cont unless _tmp
683
+ return _tmp
684
+ end
685
+
686
+ # line = { current_line }
687
+ def _line
688
+ @result = begin; current_line ; end
689
+ _tmp = true
690
+ set_failed_rule :_line unless _tmp
691
+ return _tmp
692
+ end
693
+
694
+ # ident_start = < /[\p{Ll}_]/u > { text }
695
+ def _ident_start
696
+
697
+ _save = self.pos
698
+ while true # sequence
699
+ _text_start = self.pos
700
+ _tmp = scan(/\A(?-mix:[\p{Ll}_])/u)
701
+ if _tmp
702
+ text = get_text(_text_start)
703
+ end
704
+ unless _tmp
705
+ self.pos = _save
706
+ break
707
+ end
708
+ @result = begin; text ; end
709
+ _tmp = true
710
+ unless _tmp
711
+ self.pos = _save
712
+ end
713
+ break
714
+ end # end sequence
715
+
716
+ set_failed_rule :_ident_start unless _tmp
717
+ return _tmp
718
+ end
719
+
720
+ # ident_letter = < (/[\p{L}\d]/u | !":" op_letter) > { text }
721
+ def _ident_letter
722
+
723
+ _save = self.pos
724
+ while true # sequence
725
+ _text_start = self.pos
726
+
727
+ _save1 = self.pos
728
+ while true # choice
729
+ _tmp = scan(/\A(?-mix:[\p{L}\d])/u)
730
+ break if _tmp
731
+ self.pos = _save1
732
+
733
+ _save2 = self.pos
734
+ while true # sequence
735
+ _save3 = self.pos
736
+ _tmp = match_string(":")
737
+ _tmp = _tmp ? nil : true
738
+ self.pos = _save3
739
+ unless _tmp
740
+ self.pos = _save2
741
+ break
742
+ end
743
+ _tmp = apply(:_op_letter)
744
+ unless _tmp
745
+ self.pos = _save2
746
+ end
747
+ break
748
+ end # end sequence
749
+
750
+ break if _tmp
751
+ self.pos = _save1
752
+ break
753
+ end # end choice
754
+
755
+ if _tmp
756
+ text = get_text(_text_start)
757
+ end
758
+ unless _tmp
759
+ self.pos = _save
760
+ break
761
+ end
762
+ @result = begin; text ; end
763
+ _tmp = true
764
+ unless _tmp
765
+ self.pos = _save
766
+ end
767
+ break
768
+ end # end sequence
769
+
770
+ set_failed_rule :_ident_letter unless _tmp
771
+ return _tmp
772
+ end
773
+
774
+ # op_letter = < /[\p{S}!@#%&*\-\\:.\/\?]/u > { text }
775
+ def _op_letter
776
+
777
+ _save = self.pos
778
+ while true # sequence
779
+ _text_start = self.pos
780
+ _tmp = scan(/\A(?-mix:[\p{S}!@#%&*\-\\:.\/\?])/u)
781
+ if _tmp
782
+ text = get_text(_text_start)
783
+ end
784
+ unless _tmp
785
+ self.pos = _save
786
+ break
787
+ end
788
+ @result = begin; text ; end
789
+ _tmp = true
790
+ unless _tmp
791
+ self.pos = _save
792
+ end
793
+ break
794
+ end # end sequence
795
+
796
+ set_failed_rule :_op_letter unless _tmp
797
+ return _tmp
798
+ end
799
+
800
+ # operator = < op_letter+ > &{ text != ":" } { text }
801
+ def _operator
802
+
803
+ _save = self.pos
804
+ while true # sequence
805
+ _text_start = self.pos
806
+ _save1 = self.pos
807
+ _tmp = apply(:_op_letter)
808
+ if _tmp
809
+ while true
810
+ _tmp = apply(:_op_letter)
811
+ break unless _tmp
812
+ end
813
+ _tmp = true
814
+ else
815
+ self.pos = _save1
816
+ end
817
+ if _tmp
818
+ text = get_text(_text_start)
819
+ end
820
+ unless _tmp
821
+ self.pos = _save
822
+ break
823
+ end
824
+ _save2 = self.pos
825
+ _tmp = begin; text != ":" ; end
826
+ self.pos = _save2
827
+ unless _tmp
828
+ self.pos = _save
829
+ break
830
+ end
831
+ @result = begin; text ; end
832
+ _tmp = true
833
+ unless _tmp
834
+ self.pos = _save
835
+ end
836
+ break
837
+ end # end sequence
838
+
839
+ set_failed_rule :_operator unless _tmp
840
+ return _tmp
841
+ end
842
+
843
+ # identifier = < ident_start ident_letter* > { text.tr("-", "_") }
844
+ def _identifier
845
+
846
+ _save = self.pos
847
+ while true # sequence
848
+ _text_start = self.pos
849
+
850
+ _save1 = self.pos
851
+ while true # sequence
852
+ _tmp = apply(:_ident_start)
853
+ unless _tmp
854
+ self.pos = _save1
855
+ break
856
+ end
857
+ while true
858
+ _tmp = apply(:_ident_letter)
859
+ break unless _tmp
860
+ end
861
+ _tmp = true
862
+ unless _tmp
863
+ self.pos = _save1
864
+ end
865
+ break
866
+ end # end sequence
867
+
868
+ if _tmp
869
+ text = get_text(_text_start)
870
+ end
871
+ unless _tmp
872
+ self.pos = _save
873
+ break
874
+ end
875
+ @result = begin; text.tr("-", "_") ; end
876
+ _tmp = true
877
+ unless _tmp
878
+ self.pos = _save
879
+ end
880
+ break
881
+ end # end sequence
882
+
883
+ set_failed_rule :_identifier unless _tmp
884
+ return _tmp
885
+ end
886
+
887
+ # grouped = "(" wsp expression:x wsp ")" { x }
888
+ def _grouped
889
+
890
+ _save = self.pos
891
+ while true # sequence
892
+ _tmp = match_string("(")
893
+ unless _tmp
894
+ self.pos = _save
895
+ break
896
+ end
897
+ _tmp = apply(:_wsp)
898
+ unless _tmp
899
+ self.pos = _save
900
+ break
901
+ end
902
+ _tmp = apply(:_expression)
903
+ x = @result
904
+ unless _tmp
905
+ self.pos = _save
906
+ break
907
+ end
908
+ _tmp = apply(:_wsp)
909
+ unless _tmp
910
+ self.pos = _save
911
+ break
912
+ end
913
+ _tmp = match_string(")")
914
+ unless _tmp
915
+ self.pos = _save
916
+ break
917
+ end
918
+ @result = begin; x ; end
919
+ _tmp = true
920
+ unless _tmp
921
+ self.pos = _save
922
+ end
923
+ break
924
+ end # end sequence
925
+
926
+ set_failed_rule :_grouped unless _tmp
927
+ return _tmp
928
+ end
929
+
930
+ # comment = (/--.*?$/ | multi_comment)
931
+ def _comment
932
+
933
+ _save = self.pos
934
+ while true # choice
935
+ _tmp = scan(/\A(?-mix:--.*?$)/)
936
+ break if _tmp
937
+ self.pos = _save
938
+ _tmp = apply(:_multi_comment)
939
+ break if _tmp
940
+ self.pos = _save
941
+ break
942
+ end # end choice
943
+
944
+ set_failed_rule :_comment unless _tmp
945
+ return _tmp
946
+ end
947
+
948
+ # multi_comment = "{-" in_multi
949
+ def _multi_comment
950
+
951
+ _save = self.pos
952
+ while true # sequence
953
+ _tmp = match_string("{-")
954
+ unless _tmp
955
+ self.pos = _save
956
+ break
957
+ end
958
+ _tmp = apply(:_in_multi)
959
+ unless _tmp
960
+ self.pos = _save
961
+ end
962
+ break
963
+ end # end sequence
964
+
965
+ set_failed_rule :_multi_comment unless _tmp
966
+ return _tmp
967
+ end
968
+
969
+ # in_multi = (/[^\-\{\}]*/ "-}" | /[^\-\{\}]*/ "{-" in_multi /[^\-\{\}]*/ "-}" | /[^\-\{\}]*/ /[-{}]/ in_multi)
970
+ def _in_multi
971
+
972
+ _save = self.pos
973
+ while true # choice
974
+
975
+ _save1 = self.pos
976
+ while true # sequence
977
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
978
+ unless _tmp
979
+ self.pos = _save1
980
+ break
981
+ end
982
+ _tmp = match_string("-}")
983
+ unless _tmp
984
+ self.pos = _save1
985
+ end
986
+ break
987
+ end # end sequence
988
+
989
+ break if _tmp
990
+ self.pos = _save
991
+
992
+ _save2 = self.pos
993
+ while true # sequence
994
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
995
+ unless _tmp
996
+ self.pos = _save2
997
+ break
998
+ end
999
+ _tmp = match_string("{-")
1000
+ unless _tmp
1001
+ self.pos = _save2
1002
+ break
1003
+ end
1004
+ _tmp = apply(:_in_multi)
1005
+ unless _tmp
1006
+ self.pos = _save2
1007
+ break
1008
+ end
1009
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
1010
+ unless _tmp
1011
+ self.pos = _save2
1012
+ break
1013
+ end
1014
+ _tmp = match_string("-}")
1015
+ unless _tmp
1016
+ self.pos = _save2
1017
+ end
1018
+ break
1019
+ end # end sequence
1020
+
1021
+ break if _tmp
1022
+ self.pos = _save
1023
+
1024
+ _save3 = self.pos
1025
+ while true # sequence
1026
+ _tmp = scan(/\A(?-mix:[^\-\{\}]*)/)
1027
+ unless _tmp
1028
+ self.pos = _save3
1029
+ break
1030
+ end
1031
+ _tmp = scan(/\A(?-mix:[-{}])/)
1032
+ unless _tmp
1033
+ self.pos = _save3
1034
+ break
1035
+ end
1036
+ _tmp = apply(:_in_multi)
1037
+ unless _tmp
1038
+ self.pos = _save3
1039
+ end
1040
+ break
1041
+ end # end sequence
1042
+
1043
+ break if _tmp
1044
+ self.pos = _save
1045
+ break
1046
+ end # end choice
1047
+
1048
+ set_failed_rule :_in_multi unless _tmp
1049
+ return _tmp
1050
+ end
1051
+
1052
+ # delim = (wsp "," wsp | (sp "\n" sp)+ &{ current_column >= c })
1053
+ def _delim(c)
1054
+
1055
+ _save = self.pos
1056
+ while true # choice
1057
+
1058
+ _save1 = self.pos
1059
+ while true # sequence
1060
+ _tmp = apply(:_wsp)
1061
+ unless _tmp
1062
+ self.pos = _save1
1063
+ break
1064
+ end
1065
+ _tmp = match_string(",")
1066
+ unless _tmp
1067
+ self.pos = _save1
1068
+ break
1069
+ end
1070
+ _tmp = apply(:_wsp)
1071
+ unless _tmp
1072
+ self.pos = _save1
1073
+ end
1074
+ break
1075
+ end # end sequence
1076
+
1077
+ break if _tmp
1078
+ self.pos = _save
1079
+
1080
+ _save2 = self.pos
1081
+ while true # sequence
1082
+ _save3 = self.pos
1083
+
1084
+ _save4 = self.pos
1085
+ while true # sequence
1086
+ _tmp = apply(:_sp)
1087
+ unless _tmp
1088
+ self.pos = _save4
1089
+ break
1090
+ end
1091
+ _tmp = match_string("\n")
1092
+ unless _tmp
1093
+ self.pos = _save4
1094
+ break
1095
+ end
1096
+ _tmp = apply(:_sp)
1097
+ unless _tmp
1098
+ self.pos = _save4
1099
+ end
1100
+ break
1101
+ end # end sequence
1102
+
1103
+ if _tmp
1104
+ while true
1105
+
1106
+ _save5 = self.pos
1107
+ while true # sequence
1108
+ _tmp = apply(:_sp)
1109
+ unless _tmp
1110
+ self.pos = _save5
1111
+ break
1112
+ end
1113
+ _tmp = match_string("\n")
1114
+ unless _tmp
1115
+ self.pos = _save5
1116
+ break
1117
+ end
1118
+ _tmp = apply(:_sp)
1119
+ unless _tmp
1120
+ self.pos = _save5
1121
+ end
1122
+ break
1123
+ end # end sequence
1124
+
1125
+ break unless _tmp
1126
+ end
1127
+ _tmp = true
1128
+ else
1129
+ self.pos = _save3
1130
+ end
1131
+ unless _tmp
1132
+ self.pos = _save2
1133
+ break
1134
+ end
1135
+ _save6 = self.pos
1136
+ _tmp = begin; current_column >= c ; end
1137
+ self.pos = _save6
1138
+ unless _tmp
1139
+ self.pos = _save2
1140
+ end
1141
+ break
1142
+ end # end sequence
1143
+
1144
+ break if _tmp
1145
+ self.pos = _save
1146
+ break
1147
+ end # end choice
1148
+
1149
+ set_failed_rule :_delim unless _tmp
1150
+ return _tmp
1151
+ end
1152
+
1153
+ # expression = level3
1154
+ def _expression
1155
+ _tmp = apply(:_level3)
1156
+ set_failed_rule :_expression unless _tmp
1157
+ return _tmp
1158
+ end
1159
+
1160
+ # expressions = { current_column }:c expression:x (delim(c) expression)*:xs delim(c)? { [x] + Array(xs) }
1161
+ def _expressions
1162
+
1163
+ _save = self.pos
1164
+ while true # sequence
1165
+ @result = begin; current_column ; end
1166
+ _tmp = true
1167
+ c = @result
1168
+ unless _tmp
1169
+ self.pos = _save
1170
+ break
1171
+ end
1172
+ _tmp = apply(:_expression)
1173
+ x = @result
1174
+ unless _tmp
1175
+ self.pos = _save
1176
+ break
1177
+ end
1178
+ _ary = []
1179
+ while true
1180
+
1181
+ _save2 = self.pos
1182
+ while true # sequence
1183
+ _tmp = _delim(c)
1184
+ unless _tmp
1185
+ self.pos = _save2
1186
+ break
1187
+ end
1188
+ _tmp = apply(:_expression)
1189
+ unless _tmp
1190
+ self.pos = _save2
1191
+ end
1192
+ break
1193
+ end # end sequence
1194
+
1195
+ _ary << @result if _tmp
1196
+ break unless _tmp
1197
+ end
1198
+ _tmp = true
1199
+ @result = _ary
1200
+ xs = @result
1201
+ unless _tmp
1202
+ self.pos = _save
1203
+ break
1204
+ end
1205
+ _save3 = self.pos
1206
+ _tmp = _delim(c)
1207
+ unless _tmp
1208
+ _tmp = true
1209
+ self.pos = _save3
1210
+ end
1211
+ unless _tmp
1212
+ self.pos = _save
1213
+ break
1214
+ end
1215
+ @result = begin; [x] + Array(xs) ; end
1216
+ _tmp = true
1217
+ unless _tmp
1218
+ self.pos = _save
1219
+ end
1220
+ break
1221
+ end # end sequence
1222
+
1223
+ set_failed_rule :_expressions unless _tmp
1224
+ return _tmp
1225
+ end
1226
+
1227
+ # level0 = (true | false | self | nil | number | quote | quasi_quote | splice | unquote | string | constant | variable | block | list | unary)
1228
+ def _level0
1229
+
1230
+ _save = self.pos
1231
+ while true # choice
1232
+ _tmp = apply(:_true)
1233
+ break if _tmp
1234
+ self.pos = _save
1235
+ _tmp = apply(:_false)
1236
+ break if _tmp
1237
+ self.pos = _save
1238
+ _tmp = apply(:_self)
1239
+ break if _tmp
1240
+ self.pos = _save
1241
+ _tmp = apply(:_nil)
1242
+ break if _tmp
1243
+ self.pos = _save
1244
+ _tmp = apply(:_number)
1245
+ break if _tmp
1246
+ self.pos = _save
1247
+ _tmp = apply(:_quote)
1248
+ break if _tmp
1249
+ self.pos = _save
1250
+ _tmp = apply(:_quasi_quote)
1251
+ break if _tmp
1252
+ self.pos = _save
1253
+ _tmp = apply(:_splice)
1254
+ break if _tmp
1255
+ self.pos = _save
1256
+ _tmp = apply(:_unquote)
1257
+ break if _tmp
1258
+ self.pos = _save
1259
+ _tmp = apply(:_string)
1260
+ break if _tmp
1261
+ self.pos = _save
1262
+ _tmp = apply(:_constant)
1263
+ break if _tmp
1264
+ self.pos = _save
1265
+ _tmp = apply(:_variable)
1266
+ break if _tmp
1267
+ self.pos = _save
1268
+ _tmp = apply(:_block)
1269
+ break if _tmp
1270
+ self.pos = _save
1271
+ _tmp = apply(:_list)
1272
+ break if _tmp
1273
+ self.pos = _save
1274
+ _tmp = apply(:_unary)
1275
+ break if _tmp
1276
+ self.pos = _save
1277
+ break
1278
+ end # end choice
1279
+
1280
+ set_failed_rule :_level0 unless _tmp
1281
+ return _tmp
1282
+ end
1283
+
1284
+ # level1 = (headless | grouped | level0)
1285
+ def _level1
1286
+
1287
+ _save = self.pos
1288
+ while true # choice
1289
+ _tmp = apply(:_headless)
1290
+ break if _tmp
1291
+ self.pos = _save
1292
+ _tmp = apply(:_grouped)
1293
+ break if _tmp
1294
+ self.pos = _save
1295
+ _tmp = apply(:_level0)
1296
+ break if _tmp
1297
+ self.pos = _save
1298
+ break
1299
+ end # end choice
1300
+
1301
+ set_failed_rule :_level1 unless _tmp
1302
+ return _tmp
1303
+ end
1304
+
1305
+ # level2 = (send | level1)
1306
+ def _level2
1307
+
1308
+ _save = self.pos
1309
+ while true # choice
1310
+ _tmp = apply(:_send)
1311
+ break if _tmp
1312
+ self.pos = _save
1313
+ _tmp = apply(:_level1)
1314
+ break if _tmp
1315
+ self.pos = _save
1316
+ break
1317
+ end # end choice
1318
+
1319
+ set_failed_rule :_level2 unless _tmp
1320
+ return _tmp
1321
+ end
1322
+
1323
+ # level3 = (macro | op_assoc_prec | binary_send | level2)
1324
+ def _level3
1325
+
1326
+ _save = self.pos
1327
+ while true # choice
1328
+ _tmp = apply(:_macro)
1329
+ break if _tmp
1330
+ self.pos = _save
1331
+ _tmp = apply(:_op_assoc_prec)
1332
+ break if _tmp
1333
+ self.pos = _save
1334
+ _tmp = apply(:_binary_send)
1335
+ break if _tmp
1336
+ self.pos = _save
1337
+ _tmp = apply(:_level2)
1338
+ break if _tmp
1339
+ self.pos = _save
1340
+ break
1341
+ end # end choice
1342
+
1343
+ set_failed_rule :_level3 unless _tmp
1344
+ return _tmp
1345
+ end
1346
+
1347
+ # true = line:line "true" !ident_letter { Atomy::AST::Primitive.new(line, :true) }
1348
+ def _true
1349
+
1350
+ _save = self.pos
1351
+ while true # sequence
1352
+ _tmp = apply(:_line)
1353
+ line = @result
1354
+ unless _tmp
1355
+ self.pos = _save
1356
+ break
1357
+ end
1358
+ _tmp = match_string("true")
1359
+ unless _tmp
1360
+ self.pos = _save
1361
+ break
1362
+ end
1363
+ _save1 = self.pos
1364
+ _tmp = apply(:_ident_letter)
1365
+ _tmp = _tmp ? nil : true
1366
+ self.pos = _save1
1367
+ unless _tmp
1368
+ self.pos = _save
1369
+ break
1370
+ end
1371
+ @result = begin; Atomy::AST::Primitive.new(line, :true) ; end
1372
+ _tmp = true
1373
+ unless _tmp
1374
+ self.pos = _save
1375
+ end
1376
+ break
1377
+ end # end sequence
1378
+
1379
+ set_failed_rule :_true unless _tmp
1380
+ return _tmp
1381
+ end
1382
+
1383
+ # false = line:line "false" !ident_letter { Atomy::AST::Primitive.new(line, :false) }
1384
+ def _false
1385
+
1386
+ _save = self.pos
1387
+ while true # sequence
1388
+ _tmp = apply(:_line)
1389
+ line = @result
1390
+ unless _tmp
1391
+ self.pos = _save
1392
+ break
1393
+ end
1394
+ _tmp = match_string("false")
1395
+ unless _tmp
1396
+ self.pos = _save
1397
+ break
1398
+ end
1399
+ _save1 = self.pos
1400
+ _tmp = apply(:_ident_letter)
1401
+ _tmp = _tmp ? nil : true
1402
+ self.pos = _save1
1403
+ unless _tmp
1404
+ self.pos = _save
1405
+ break
1406
+ end
1407
+ @result = begin; Atomy::AST::Primitive.new(line, :false) ; end
1408
+ _tmp = true
1409
+ unless _tmp
1410
+ self.pos = _save
1411
+ end
1412
+ break
1413
+ end # end sequence
1414
+
1415
+ set_failed_rule :_false unless _tmp
1416
+ return _tmp
1417
+ end
1418
+
1419
+ # self = line:line "self" !ident_letter { Atomy::AST::Primitive.new(line, :self) }
1420
+ def _self
1421
+
1422
+ _save = self.pos
1423
+ while true # sequence
1424
+ _tmp = apply(:_line)
1425
+ line = @result
1426
+ unless _tmp
1427
+ self.pos = _save
1428
+ break
1429
+ end
1430
+ _tmp = match_string("self")
1431
+ unless _tmp
1432
+ self.pos = _save
1433
+ break
1434
+ end
1435
+ _save1 = self.pos
1436
+ _tmp = apply(:_ident_letter)
1437
+ _tmp = _tmp ? nil : true
1438
+ self.pos = _save1
1439
+ unless _tmp
1440
+ self.pos = _save
1441
+ break
1442
+ end
1443
+ @result = begin; Atomy::AST::Primitive.new(line, :self) ; end
1444
+ _tmp = true
1445
+ unless _tmp
1446
+ self.pos = _save
1447
+ end
1448
+ break
1449
+ end # end sequence
1450
+
1451
+ set_failed_rule :_self unless _tmp
1452
+ return _tmp
1453
+ end
1454
+
1455
+ # nil = line:line "nil" !ident_letter { Atomy::AST::Primitive.new(line, :nil) }
1456
+ def _nil
1457
+
1458
+ _save = self.pos
1459
+ while true # sequence
1460
+ _tmp = apply(:_line)
1461
+ line = @result
1462
+ unless _tmp
1463
+ self.pos = _save
1464
+ break
1465
+ end
1466
+ _tmp = match_string("nil")
1467
+ unless _tmp
1468
+ self.pos = _save
1469
+ break
1470
+ end
1471
+ _save1 = self.pos
1472
+ _tmp = apply(:_ident_letter)
1473
+ _tmp = _tmp ? nil : true
1474
+ self.pos = _save1
1475
+ unless _tmp
1476
+ self.pos = _save
1477
+ break
1478
+ end
1479
+ @result = begin; Atomy::AST::Primitive.new(line, :nil) ; end
1480
+ _tmp = true
1481
+ unless _tmp
1482
+ self.pos = _save
1483
+ end
1484
+ break
1485
+ end # end sequence
1486
+
1487
+ set_failed_rule :_nil unless _tmp
1488
+ return _tmp
1489
+ end
1490
+
1491
+ # number = (line:line < /[\+\-]?0[oO][\da-fA-F]+/ > { Atomy::AST::Primitive.new(line, text.to_i(8)) } | line:line < /[\+\-]?0[xX][0-7]+/ > { Atomy::AST::Primitive.new(line, text.to_i(16)) } | line:line < /[\+\-]?\d+(\.\d+)?[eE][\+\-]?\d+/ > { Atomy::AST::Primitive.new(line, text.to_f) } | line:line < /[\+\-]?\d+\.\d+/ > { Atomy::AST::Primitive.new(line, text.to_f) } | line:line < /[\+\-]?\d+/ > { Atomy::AST::Primitive.new(line, text.to_i) })
1492
+ def _number
1493
+
1494
+ _save = self.pos
1495
+ while true # choice
1496
+
1497
+ _save1 = self.pos
1498
+ while true # sequence
1499
+ _tmp = apply(:_line)
1500
+ line = @result
1501
+ unless _tmp
1502
+ self.pos = _save1
1503
+ break
1504
+ end
1505
+ _text_start = self.pos
1506
+ _tmp = scan(/\A(?-mix:[\+\-]?0[oO][\da-fA-F]+)/)
1507
+ if _tmp
1508
+ text = get_text(_text_start)
1509
+ end
1510
+ unless _tmp
1511
+ self.pos = _save1
1512
+ break
1513
+ end
1514
+ @result = begin; Atomy::AST::Primitive.new(line, text.to_i(8)) ; end
1515
+ _tmp = true
1516
+ unless _tmp
1517
+ self.pos = _save1
1518
+ end
1519
+ break
1520
+ end # end sequence
1521
+
1522
+ break if _tmp
1523
+ self.pos = _save
1524
+
1525
+ _save2 = self.pos
1526
+ while true # sequence
1527
+ _tmp = apply(:_line)
1528
+ line = @result
1529
+ unless _tmp
1530
+ self.pos = _save2
1531
+ break
1532
+ end
1533
+ _text_start = self.pos
1534
+ _tmp = scan(/\A(?-mix:[\+\-]?0[xX][0-7]+)/)
1535
+ if _tmp
1536
+ text = get_text(_text_start)
1537
+ end
1538
+ unless _tmp
1539
+ self.pos = _save2
1540
+ break
1541
+ end
1542
+ @result = begin; Atomy::AST::Primitive.new(line, text.to_i(16)) ; end
1543
+ _tmp = true
1544
+ unless _tmp
1545
+ self.pos = _save2
1546
+ end
1547
+ break
1548
+ end # end sequence
1549
+
1550
+ break if _tmp
1551
+ self.pos = _save
1552
+
1553
+ _save3 = self.pos
1554
+ while true # sequence
1555
+ _tmp = apply(:_line)
1556
+ line = @result
1557
+ unless _tmp
1558
+ self.pos = _save3
1559
+ break
1560
+ end
1561
+ _text_start = self.pos
1562
+ _tmp = scan(/\A(?-mix:[\+\-]?\d+(\.\d+)?[eE][\+\-]?\d+)/)
1563
+ if _tmp
1564
+ text = get_text(_text_start)
1565
+ end
1566
+ unless _tmp
1567
+ self.pos = _save3
1568
+ break
1569
+ end
1570
+ @result = begin; Atomy::AST::Primitive.new(line, text.to_f) ; end
1571
+ _tmp = true
1572
+ unless _tmp
1573
+ self.pos = _save3
1574
+ end
1575
+ break
1576
+ end # end sequence
1577
+
1578
+ break if _tmp
1579
+ self.pos = _save
1580
+
1581
+ _save4 = self.pos
1582
+ while true # sequence
1583
+ _tmp = apply(:_line)
1584
+ line = @result
1585
+ unless _tmp
1586
+ self.pos = _save4
1587
+ break
1588
+ end
1589
+ _text_start = self.pos
1590
+ _tmp = scan(/\A(?-mix:[\+\-]?\d+\.\d+)/)
1591
+ if _tmp
1592
+ text = get_text(_text_start)
1593
+ end
1594
+ unless _tmp
1595
+ self.pos = _save4
1596
+ break
1597
+ end
1598
+ @result = begin; Atomy::AST::Primitive.new(line, text.to_f) ; end
1599
+ _tmp = true
1600
+ unless _tmp
1601
+ self.pos = _save4
1602
+ end
1603
+ break
1604
+ end # end sequence
1605
+
1606
+ break if _tmp
1607
+ self.pos = _save
1608
+
1609
+ _save5 = self.pos
1610
+ while true # sequence
1611
+ _tmp = apply(:_line)
1612
+ line = @result
1613
+ unless _tmp
1614
+ self.pos = _save5
1615
+ break
1616
+ end
1617
+ _text_start = self.pos
1618
+ _tmp = scan(/\A(?-mix:[\+\-]?\d+)/)
1619
+ if _tmp
1620
+ text = get_text(_text_start)
1621
+ end
1622
+ unless _tmp
1623
+ self.pos = _save5
1624
+ break
1625
+ end
1626
+ @result = begin; Atomy::AST::Primitive.new(line, text.to_i) ; end
1627
+ _tmp = true
1628
+ unless _tmp
1629
+ self.pos = _save5
1630
+ end
1631
+ break
1632
+ end # end sequence
1633
+
1634
+ break if _tmp
1635
+ self.pos = _save
1636
+ break
1637
+ end # end choice
1638
+
1639
+ set_failed_rule :_number unless _tmp
1640
+ return _tmp
1641
+ end
1642
+
1643
+ # macro = line:line "macro" "(" wsp expression:p wsp ")" wsp block:b { Atomy::AST::Macro.new(line, p, b.block_body) }
1644
+ def _macro
1645
+
1646
+ _save = self.pos
1647
+ while true # sequence
1648
+ _tmp = apply(:_line)
1649
+ line = @result
1650
+ unless _tmp
1651
+ self.pos = _save
1652
+ break
1653
+ end
1654
+ _tmp = match_string("macro")
1655
+ unless _tmp
1656
+ self.pos = _save
1657
+ break
1658
+ end
1659
+ _tmp = match_string("(")
1660
+ unless _tmp
1661
+ self.pos = _save
1662
+ break
1663
+ end
1664
+ _tmp = apply(:_wsp)
1665
+ unless _tmp
1666
+ self.pos = _save
1667
+ break
1668
+ end
1669
+ _tmp = apply(:_expression)
1670
+ p = @result
1671
+ unless _tmp
1672
+ self.pos = _save
1673
+ break
1674
+ end
1675
+ _tmp = apply(:_wsp)
1676
+ unless _tmp
1677
+ self.pos = _save
1678
+ break
1679
+ end
1680
+ _tmp = match_string(")")
1681
+ unless _tmp
1682
+ self.pos = _save
1683
+ break
1684
+ end
1685
+ _tmp = apply(:_wsp)
1686
+ unless _tmp
1687
+ self.pos = _save
1688
+ break
1689
+ end
1690
+ _tmp = apply(:_block)
1691
+ b = @result
1692
+ unless _tmp
1693
+ self.pos = _save
1694
+ break
1695
+ end
1696
+ @result = begin; Atomy::AST::Macro.new(line, p, b.block_body) ; end
1697
+ _tmp = true
1698
+ unless _tmp
1699
+ self.pos = _save
1700
+ end
1701
+ break
1702
+ end # end sequence
1703
+
1704
+ set_failed_rule :_macro unless _tmp
1705
+ return _tmp
1706
+ end
1707
+
1708
+ # op_assoc = sig_wsp < /left|right/ > { text.to_sym }
1709
+ def _op_assoc
1710
+
1711
+ _save = self.pos
1712
+ while true # sequence
1713
+ _tmp = apply(:_sig_wsp)
1714
+ unless _tmp
1715
+ self.pos = _save
1716
+ break
1717
+ end
1718
+ _text_start = self.pos
1719
+ _tmp = scan(/\A(?-mix:left|right)/)
1720
+ if _tmp
1721
+ text = get_text(_text_start)
1722
+ end
1723
+ unless _tmp
1724
+ self.pos = _save
1725
+ break
1726
+ end
1727
+ @result = begin; text.to_sym ; end
1728
+ _tmp = true
1729
+ unless _tmp
1730
+ self.pos = _save
1731
+ end
1732
+ break
1733
+ end # end sequence
1734
+
1735
+ set_failed_rule :_op_assoc unless _tmp
1736
+ return _tmp
1737
+ end
1738
+
1739
+ # op_prec = sig_wsp < /[0-9]+/ > { text.to_i }
1740
+ def _op_prec
1741
+
1742
+ _save = self.pos
1743
+ while true # sequence
1744
+ _tmp = apply(:_sig_wsp)
1745
+ unless _tmp
1746
+ self.pos = _save
1747
+ break
1748
+ end
1749
+ _text_start = self.pos
1750
+ _tmp = scan(/\A(?-mix:[0-9]+)/)
1751
+ if _tmp
1752
+ text = get_text(_text_start)
1753
+ end
1754
+ unless _tmp
1755
+ self.pos = _save
1756
+ break
1757
+ end
1758
+ @result = begin; text.to_i ; end
1759
+ _tmp = true
1760
+ unless _tmp
1761
+ self.pos = _save
1762
+ end
1763
+ break
1764
+ end # end sequence
1765
+
1766
+ set_failed_rule :_op_prec unless _tmp
1767
+ return _tmp
1768
+ end
1769
+
1770
+ # op_assoc_prec = line:line "operator" op_assoc?:assoc op_prec:prec (sig_wsp operator)+:os { Atomy::Macro.set_op_info(os, assoc, prec) Atomy::AST::Operator.new(line, assoc, prec, os) }
1771
+ def _op_assoc_prec
1772
+
1773
+ _save = self.pos
1774
+ while true # sequence
1775
+ _tmp = apply(:_line)
1776
+ line = @result
1777
+ unless _tmp
1778
+ self.pos = _save
1779
+ break
1780
+ end
1781
+ _tmp = match_string("operator")
1782
+ unless _tmp
1783
+ self.pos = _save
1784
+ break
1785
+ end
1786
+ _save1 = self.pos
1787
+ _tmp = apply(:_op_assoc)
1788
+ @result = nil unless _tmp
1789
+ unless _tmp
1790
+ _tmp = true
1791
+ self.pos = _save1
1792
+ end
1793
+ assoc = @result
1794
+ unless _tmp
1795
+ self.pos = _save
1796
+ break
1797
+ end
1798
+ _tmp = apply(:_op_prec)
1799
+ prec = @result
1800
+ unless _tmp
1801
+ self.pos = _save
1802
+ break
1803
+ end
1804
+ _save2 = self.pos
1805
+ _ary = []
1806
+
1807
+ _save3 = self.pos
1808
+ while true # sequence
1809
+ _tmp = apply(:_sig_wsp)
1810
+ unless _tmp
1811
+ self.pos = _save3
1812
+ break
1813
+ end
1814
+ _tmp = apply(:_operator)
1815
+ unless _tmp
1816
+ self.pos = _save3
1817
+ end
1818
+ break
1819
+ end # end sequence
1820
+
1821
+ if _tmp
1822
+ _ary << @result
1823
+ while true
1824
+
1825
+ _save4 = self.pos
1826
+ while true # sequence
1827
+ _tmp = apply(:_sig_wsp)
1828
+ unless _tmp
1829
+ self.pos = _save4
1830
+ break
1831
+ end
1832
+ _tmp = apply(:_operator)
1833
+ unless _tmp
1834
+ self.pos = _save4
1835
+ end
1836
+ break
1837
+ end # end sequence
1838
+
1839
+ _ary << @result if _tmp
1840
+ break unless _tmp
1841
+ end
1842
+ _tmp = true
1843
+ @result = _ary
1844
+ else
1845
+ self.pos = _save2
1846
+ end
1847
+ os = @result
1848
+ unless _tmp
1849
+ self.pos = _save
1850
+ break
1851
+ end
1852
+ @result = begin; Atomy::Macro.set_op_info(os, assoc, prec)
1853
+ Atomy::AST::Operator.new(line, assoc, prec, os)
1854
+ ; end
1855
+ _tmp = true
1856
+ unless _tmp
1857
+ self.pos = _save
1858
+ end
1859
+ break
1860
+ end # end sequence
1861
+
1862
+ set_failed_rule :_op_assoc_prec unless _tmp
1863
+ return _tmp
1864
+ end
1865
+
1866
+ # quote = line:line "'" level1:e { Atomy::AST::Quote.new(line, e) }
1867
+ def _quote
1868
+
1869
+ _save = self.pos
1870
+ while true # sequence
1871
+ _tmp = apply(:_line)
1872
+ line = @result
1873
+ unless _tmp
1874
+ self.pos = _save
1875
+ break
1876
+ end
1877
+ _tmp = match_string("'")
1878
+ unless _tmp
1879
+ self.pos = _save
1880
+ break
1881
+ end
1882
+ _tmp = apply(:_level1)
1883
+ e = @result
1884
+ unless _tmp
1885
+ self.pos = _save
1886
+ break
1887
+ end
1888
+ @result = begin; Atomy::AST::Quote.new(line, e) ; end
1889
+ _tmp = true
1890
+ unless _tmp
1891
+ self.pos = _save
1892
+ end
1893
+ break
1894
+ end # end sequence
1895
+
1896
+ set_failed_rule :_quote unless _tmp
1897
+ return _tmp
1898
+ end
1899
+
1900
+ # quasi_quote = line:line "`" level1:e { Atomy::AST::QuasiQuote.new(line, e) }
1901
+ def _quasi_quote
1902
+
1903
+ _save = self.pos
1904
+ while true # sequence
1905
+ _tmp = apply(:_line)
1906
+ line = @result
1907
+ unless _tmp
1908
+ self.pos = _save
1909
+ break
1910
+ end
1911
+ _tmp = match_string("`")
1912
+ unless _tmp
1913
+ self.pos = _save
1914
+ break
1915
+ end
1916
+ _tmp = apply(:_level1)
1917
+ e = @result
1918
+ unless _tmp
1919
+ self.pos = _save
1920
+ break
1921
+ end
1922
+ @result = begin; Atomy::AST::QuasiQuote.new(line, e) ; end
1923
+ _tmp = true
1924
+ unless _tmp
1925
+ self.pos = _save
1926
+ end
1927
+ break
1928
+ end # end sequence
1929
+
1930
+ set_failed_rule :_quasi_quote unless _tmp
1931
+ return _tmp
1932
+ end
1933
+
1934
+ # splice = line:line "~*" level1:e { Atomy::AST::Splice.new(line, e) }
1935
+ def _splice
1936
+
1937
+ _save = self.pos
1938
+ while true # sequence
1939
+ _tmp = apply(:_line)
1940
+ line = @result
1941
+ unless _tmp
1942
+ self.pos = _save
1943
+ break
1944
+ end
1945
+ _tmp = match_string("~*")
1946
+ unless _tmp
1947
+ self.pos = _save
1948
+ break
1949
+ end
1950
+ _tmp = apply(:_level1)
1951
+ e = @result
1952
+ unless _tmp
1953
+ self.pos = _save
1954
+ break
1955
+ end
1956
+ @result = begin; Atomy::AST::Splice.new(line, e) ; end
1957
+ _tmp = true
1958
+ unless _tmp
1959
+ self.pos = _save
1960
+ end
1961
+ break
1962
+ end # end sequence
1963
+
1964
+ set_failed_rule :_splice unless _tmp
1965
+ return _tmp
1966
+ end
1967
+
1968
+ # unquote = line:line "~" level1:e { Atomy::AST::Unquote.new(line, e) }
1969
+ def _unquote
1970
+
1971
+ _save = self.pos
1972
+ while true # sequence
1973
+ _tmp = apply(:_line)
1974
+ line = @result
1975
+ unless _tmp
1976
+ self.pos = _save
1977
+ break
1978
+ end
1979
+ _tmp = match_string("~")
1980
+ unless _tmp
1981
+ self.pos = _save
1982
+ break
1983
+ end
1984
+ _tmp = apply(:_level1)
1985
+ e = @result
1986
+ unless _tmp
1987
+ self.pos = _save
1988
+ break
1989
+ end
1990
+ @result = begin; Atomy::AST::Unquote.new(line, e) ; end
1991
+ _tmp = true
1992
+ unless _tmp
1993
+ self.pos = _save
1994
+ end
1995
+ break
1996
+ end # end sequence
1997
+
1998
+ set_failed_rule :_unquote unless _tmp
1999
+ return _tmp
2000
+ end
2001
+
2002
+ # escape = (number_escapes | escapes)
2003
+ def _escape
2004
+
2005
+ _save = self.pos
2006
+ while true # choice
2007
+ _tmp = apply(:_number_escapes)
2008
+ break if _tmp
2009
+ self.pos = _save
2010
+ _tmp = apply(:_escapes)
2011
+ break if _tmp
2012
+ self.pos = _save
2013
+ break
2014
+ end # end choice
2015
+
2016
+ set_failed_rule :_escape unless _tmp
2017
+ return _tmp
2018
+ end
2019
+
2020
+ # str_seq = < /[^\\"]+/ > { text }
2021
+ def _str_seq
2022
+
2023
+ _save = self.pos
2024
+ while true # sequence
2025
+ _text_start = self.pos
2026
+ _tmp = scan(/\A(?-mix:[^\\"]+)/)
2027
+ if _tmp
2028
+ text = get_text(_text_start)
2029
+ end
2030
+ unless _tmp
2031
+ self.pos = _save
2032
+ break
2033
+ end
2034
+ @result = begin; text ; end
2035
+ _tmp = true
2036
+ unless _tmp
2037
+ self.pos = _save
2038
+ end
2039
+ break
2040
+ end # end sequence
2041
+
2042
+ set_failed_rule :_str_seq unless _tmp
2043
+ return _tmp
2044
+ end
2045
+
2046
+ # string = line:line "\"" < ("\\" escape | str_seq)*:c > "\"" { Atomy::AST::String.new( line, c.join, text.gsub("\\\"", "\"") ) }
2047
+ def _string
2048
+
2049
+ _save = self.pos
2050
+ while true # sequence
2051
+ _tmp = apply(:_line)
2052
+ line = @result
2053
+ unless _tmp
2054
+ self.pos = _save
2055
+ break
2056
+ end
2057
+ _tmp = match_string("\"")
2058
+ unless _tmp
2059
+ self.pos = _save
2060
+ break
2061
+ end
2062
+ _text_start = self.pos
2063
+ _ary = []
2064
+ while true
2065
+
2066
+ _save2 = self.pos
2067
+ while true # choice
2068
+
2069
+ _save3 = self.pos
2070
+ while true # sequence
2071
+ _tmp = match_string("\\")
2072
+ unless _tmp
2073
+ self.pos = _save3
2074
+ break
2075
+ end
2076
+ _tmp = apply(:_escape)
2077
+ unless _tmp
2078
+ self.pos = _save3
2079
+ end
2080
+ break
2081
+ end # end sequence
2082
+
2083
+ break if _tmp
2084
+ self.pos = _save2
2085
+ _tmp = apply(:_str_seq)
2086
+ break if _tmp
2087
+ self.pos = _save2
2088
+ break
2089
+ end # end choice
2090
+
2091
+ _ary << @result if _tmp
2092
+ break unless _tmp
2093
+ end
2094
+ _tmp = true
2095
+ @result = _ary
2096
+ c = @result
2097
+ if _tmp
2098
+ text = get_text(_text_start)
2099
+ end
2100
+ unless _tmp
2101
+ self.pos = _save
2102
+ break
2103
+ end
2104
+ _tmp = match_string("\"")
2105
+ unless _tmp
2106
+ self.pos = _save
2107
+ break
2108
+ end
2109
+ @result = begin; Atomy::AST::String.new(
2110
+ line,
2111
+ c.join,
2112
+ text.gsub("\\\"", "\"")
2113
+ )
2114
+ ; end
2115
+ _tmp = true
2116
+ unless _tmp
2117
+ self.pos = _save
2118
+ end
2119
+ break
2120
+ end # end sequence
2121
+
2122
+ set_failed_rule :_string unless _tmp
2123
+ return _tmp
2124
+ end
2125
+
2126
+ # constant_name = < /[A-Z][a-zA-Z0-9_]*/ > { text }
2127
+ def _constant_name
2128
+
2129
+ _save = self.pos
2130
+ while true # sequence
2131
+ _text_start = self.pos
2132
+ _tmp = scan(/\A(?-mix:[A-Z][a-zA-Z0-9_]*)/)
2133
+ if _tmp
2134
+ text = get_text(_text_start)
2135
+ end
2136
+ unless _tmp
2137
+ self.pos = _save
2138
+ break
2139
+ end
2140
+ @result = begin; text ; end
2141
+ _tmp = true
2142
+ unless _tmp
2143
+ self.pos = _save
2144
+ end
2145
+ break
2146
+ end # end sequence
2147
+
2148
+ set_failed_rule :_constant_name unless _tmp
2149
+ return _tmp
2150
+ end
2151
+
2152
+ # constant = (line:line constant_name:m ("::" constant_name)*:s { names = [m] + Array(s) const_chain(line, names) } | line:line ("::" constant_name)+:s { names = Array(s) const_chain(line, names, true) })
2153
+ def _constant
2154
+
2155
+ _save = self.pos
2156
+ while true # choice
2157
+
2158
+ _save1 = self.pos
2159
+ while true # sequence
2160
+ _tmp = apply(:_line)
2161
+ line = @result
2162
+ unless _tmp
2163
+ self.pos = _save1
2164
+ break
2165
+ end
2166
+ _tmp = apply(:_constant_name)
2167
+ m = @result
2168
+ unless _tmp
2169
+ self.pos = _save1
2170
+ break
2171
+ end
2172
+ _ary = []
2173
+ while true
2174
+
2175
+ _save3 = self.pos
2176
+ while true # sequence
2177
+ _tmp = match_string("::")
2178
+ unless _tmp
2179
+ self.pos = _save3
2180
+ break
2181
+ end
2182
+ _tmp = apply(:_constant_name)
2183
+ unless _tmp
2184
+ self.pos = _save3
2185
+ end
2186
+ break
2187
+ end # end sequence
2188
+
2189
+ _ary << @result if _tmp
2190
+ break unless _tmp
2191
+ end
2192
+ _tmp = true
2193
+ @result = _ary
2194
+ s = @result
2195
+ unless _tmp
2196
+ self.pos = _save1
2197
+ break
2198
+ end
2199
+ @result = begin;
2200
+ names = [m] + Array(s)
2201
+ const_chain(line, names)
2202
+ ; end
2203
+ _tmp = true
2204
+ unless _tmp
2205
+ self.pos = _save1
2206
+ end
2207
+ break
2208
+ end # end sequence
2209
+
2210
+ break if _tmp
2211
+ self.pos = _save
2212
+
2213
+ _save4 = self.pos
2214
+ while true # sequence
2215
+ _tmp = apply(:_line)
2216
+ line = @result
2217
+ unless _tmp
2218
+ self.pos = _save4
2219
+ break
2220
+ end
2221
+ _save5 = self.pos
2222
+ _ary = []
2223
+
2224
+ _save6 = self.pos
2225
+ while true # sequence
2226
+ _tmp = match_string("::")
2227
+ unless _tmp
2228
+ self.pos = _save6
2229
+ break
2230
+ end
2231
+ _tmp = apply(:_constant_name)
2232
+ unless _tmp
2233
+ self.pos = _save6
2234
+ end
2235
+ break
2236
+ end # end sequence
2237
+
2238
+ if _tmp
2239
+ _ary << @result
2240
+ while true
2241
+
2242
+ _save7 = self.pos
2243
+ while true # sequence
2244
+ _tmp = match_string("::")
2245
+ unless _tmp
2246
+ self.pos = _save7
2247
+ break
2248
+ end
2249
+ _tmp = apply(:_constant_name)
2250
+ unless _tmp
2251
+ self.pos = _save7
2252
+ end
2253
+ break
2254
+ end # end sequence
2255
+
2256
+ _ary << @result if _tmp
2257
+ break unless _tmp
2258
+ end
2259
+ _tmp = true
2260
+ @result = _ary
2261
+ else
2262
+ self.pos = _save5
2263
+ end
2264
+ s = @result
2265
+ unless _tmp
2266
+ self.pos = _save4
2267
+ break
2268
+ end
2269
+ @result = begin;
2270
+ names = Array(s)
2271
+ const_chain(line, names, true)
2272
+ ; end
2273
+ _tmp = true
2274
+ unless _tmp
2275
+ self.pos = _save4
2276
+ end
2277
+ break
2278
+ end # end sequence
2279
+
2280
+ break if _tmp
2281
+ self.pos = _save
2282
+ break
2283
+ end # end choice
2284
+
2285
+ set_failed_rule :_constant unless _tmp
2286
+ return _tmp
2287
+ end
2288
+
2289
+ # variable = line:line identifier:n { Atomy::AST::Variable.new(line, n.gsub("/", Atomy::NAMESPACE_DELIM)) }
2290
+ def _variable
2291
+
2292
+ _save = self.pos
2293
+ while true # sequence
2294
+ _tmp = apply(:_line)
2295
+ line = @result
2296
+ unless _tmp
2297
+ self.pos = _save
2298
+ break
2299
+ end
2300
+ _tmp = apply(:_identifier)
2301
+ n = @result
2302
+ unless _tmp
2303
+ self.pos = _save
2304
+ break
2305
+ end
2306
+ @result = begin; Atomy::AST::Variable.new(line, n.gsub("/", Atomy::NAMESPACE_DELIM)) ; end
2307
+ _tmp = true
2308
+ unless _tmp
2309
+ self.pos = _save
2310
+ end
2311
+ break
2312
+ end # end sequence
2313
+
2314
+ set_failed_rule :_variable unless _tmp
2315
+ return _tmp
2316
+ end
2317
+
2318
+ # unary = line:line !":" op_letter:o level1:e { Atomy::AST::Unary.new(line, e, o) }
2319
+ def _unary
2320
+
2321
+ _save = self.pos
2322
+ while true # sequence
2323
+ _tmp = apply(:_line)
2324
+ line = @result
2325
+ unless _tmp
2326
+ self.pos = _save
2327
+ break
2328
+ end
2329
+ _save1 = self.pos
2330
+ _tmp = match_string(":")
2331
+ _tmp = _tmp ? nil : true
2332
+ self.pos = _save1
2333
+ unless _tmp
2334
+ self.pos = _save
2335
+ break
2336
+ end
2337
+ _tmp = apply(:_op_letter)
2338
+ o = @result
2339
+ unless _tmp
2340
+ self.pos = _save
2341
+ break
2342
+ end
2343
+ _tmp = apply(:_level1)
2344
+ e = @result
2345
+ unless _tmp
2346
+ self.pos = _save
2347
+ break
2348
+ end
2349
+ @result = begin; Atomy::AST::Unary.new(line, e, o) ; end
2350
+ _tmp = true
2351
+ unless _tmp
2352
+ self.pos = _save
2353
+ end
2354
+ break
2355
+ end # end sequence
2356
+
2357
+ set_failed_rule :_unary unless _tmp
2358
+ return _tmp
2359
+ end
2360
+
2361
+ # args = "(" wsp expressions?:as wsp ")" { Array(as) }
2362
+ def _args
2363
+
2364
+ _save = self.pos
2365
+ while true # sequence
2366
+ _tmp = match_string("(")
2367
+ unless _tmp
2368
+ self.pos = _save
2369
+ break
2370
+ end
2371
+ _tmp = apply(:_wsp)
2372
+ unless _tmp
2373
+ self.pos = _save
2374
+ break
2375
+ end
2376
+ _save1 = self.pos
2377
+ _tmp = apply(:_expressions)
2378
+ @result = nil unless _tmp
2379
+ unless _tmp
2380
+ _tmp = true
2381
+ self.pos = _save1
2382
+ end
2383
+ as = @result
2384
+ unless _tmp
2385
+ self.pos = _save
2386
+ break
2387
+ end
2388
+ _tmp = apply(:_wsp)
2389
+ unless _tmp
2390
+ self.pos = _save
2391
+ break
2392
+ end
2393
+ _tmp = match_string(")")
2394
+ unless _tmp
2395
+ self.pos = _save
2396
+ break
2397
+ end
2398
+ @result = begin; Array(as) ; end
2399
+ _tmp = true
2400
+ unless _tmp
2401
+ self.pos = _save
2402
+ end
2403
+ break
2404
+ end # end sequence
2405
+
2406
+ set_failed_rule :_args unless _tmp
2407
+ return _tmp
2408
+ end
2409
+
2410
+ # block = (line:line ":" !operator wsp expressions?:es (wsp ";")? { Atomy::AST::Block.new(line, Array(es), []) } | line:line "{" wsp expressions?:es wsp "}" { Atomy::AST::Block.new(line, Array(es), []) })
2411
+ def _block
2412
+
2413
+ _save = self.pos
2414
+ while true # choice
2415
+
2416
+ _save1 = self.pos
2417
+ while true # sequence
2418
+ _tmp = apply(:_line)
2419
+ line = @result
2420
+ unless _tmp
2421
+ self.pos = _save1
2422
+ break
2423
+ end
2424
+ _tmp = match_string(":")
2425
+ unless _tmp
2426
+ self.pos = _save1
2427
+ break
2428
+ end
2429
+ _save2 = self.pos
2430
+ _tmp = apply(:_operator)
2431
+ _tmp = _tmp ? nil : true
2432
+ self.pos = _save2
2433
+ unless _tmp
2434
+ self.pos = _save1
2435
+ break
2436
+ end
2437
+ _tmp = apply(:_wsp)
2438
+ unless _tmp
2439
+ self.pos = _save1
2440
+ break
2441
+ end
2442
+ _save3 = self.pos
2443
+ _tmp = apply(:_expressions)
2444
+ @result = nil unless _tmp
2445
+ unless _tmp
2446
+ _tmp = true
2447
+ self.pos = _save3
2448
+ end
2449
+ es = @result
2450
+ unless _tmp
2451
+ self.pos = _save1
2452
+ break
2453
+ end
2454
+ _save4 = self.pos
2455
+
2456
+ _save5 = self.pos
2457
+ while true # sequence
2458
+ _tmp = apply(:_wsp)
2459
+ unless _tmp
2460
+ self.pos = _save5
2461
+ break
2462
+ end
2463
+ _tmp = match_string(";")
2464
+ unless _tmp
2465
+ self.pos = _save5
2466
+ end
2467
+ break
2468
+ end # end sequence
2469
+
2470
+ unless _tmp
2471
+ _tmp = true
2472
+ self.pos = _save4
2473
+ end
2474
+ unless _tmp
2475
+ self.pos = _save1
2476
+ break
2477
+ end
2478
+ @result = begin; Atomy::AST::Block.new(line, Array(es), []) ; end
2479
+ _tmp = true
2480
+ unless _tmp
2481
+ self.pos = _save1
2482
+ end
2483
+ break
2484
+ end # end sequence
2485
+
2486
+ break if _tmp
2487
+ self.pos = _save
2488
+
2489
+ _save6 = self.pos
2490
+ while true # sequence
2491
+ _tmp = apply(:_line)
2492
+ line = @result
2493
+ unless _tmp
2494
+ self.pos = _save6
2495
+ break
2496
+ end
2497
+ _tmp = match_string("{")
2498
+ unless _tmp
2499
+ self.pos = _save6
2500
+ break
2501
+ end
2502
+ _tmp = apply(:_wsp)
2503
+ unless _tmp
2504
+ self.pos = _save6
2505
+ break
2506
+ end
2507
+ _save7 = self.pos
2508
+ _tmp = apply(:_expressions)
2509
+ @result = nil unless _tmp
2510
+ unless _tmp
2511
+ _tmp = true
2512
+ self.pos = _save7
2513
+ end
2514
+ es = @result
2515
+ unless _tmp
2516
+ self.pos = _save6
2517
+ break
2518
+ end
2519
+ _tmp = apply(:_wsp)
2520
+ unless _tmp
2521
+ self.pos = _save6
2522
+ break
2523
+ end
2524
+ _tmp = match_string("}")
2525
+ unless _tmp
2526
+ self.pos = _save6
2527
+ break
2528
+ end
2529
+ @result = begin; Atomy::AST::Block.new(line, Array(es), []) ; end
2530
+ _tmp = true
2531
+ unless _tmp
2532
+ self.pos = _save6
2533
+ end
2534
+ break
2535
+ end # end sequence
2536
+
2537
+ break if _tmp
2538
+ self.pos = _save
2539
+ break
2540
+ end # end choice
2541
+
2542
+ set_failed_rule :_block unless _tmp
2543
+ return _tmp
2544
+ end
2545
+
2546
+ # list = line:line "[" wsp expressions?:es wsp "]" { Atomy::AST::List.new(line, Array(es)) }
2547
+ def _list
2548
+
2549
+ _save = self.pos
2550
+ while true # sequence
2551
+ _tmp = apply(:_line)
2552
+ line = @result
2553
+ unless _tmp
2554
+ self.pos = _save
2555
+ break
2556
+ end
2557
+ _tmp = match_string("[")
2558
+ unless _tmp
2559
+ self.pos = _save
2560
+ break
2561
+ end
2562
+ _tmp = apply(:_wsp)
2563
+ unless _tmp
2564
+ self.pos = _save
2565
+ break
2566
+ end
2567
+ _save1 = self.pos
2568
+ _tmp = apply(:_expressions)
2569
+ @result = nil unless _tmp
2570
+ unless _tmp
2571
+ _tmp = true
2572
+ self.pos = _save1
2573
+ end
2574
+ es = @result
2575
+ unless _tmp
2576
+ self.pos = _save
2577
+ break
2578
+ end
2579
+ _tmp = apply(:_wsp)
2580
+ unless _tmp
2581
+ self.pos = _save
2582
+ break
2583
+ end
2584
+ _tmp = match_string("]")
2585
+ unless _tmp
2586
+ self.pos = _save
2587
+ break
2588
+ end
2589
+ @result = begin; Atomy::AST::List.new(line, Array(es)) ; end
2590
+ _tmp = true
2591
+ unless _tmp
2592
+ self.pos = _save
2593
+ end
2594
+ break
2595
+ end # end sequence
2596
+
2597
+ set_failed_rule :_list unless _tmp
2598
+ return _tmp
2599
+ end
2600
+
2601
+ # sends = (line:line send:r cont(pos) level0:n args?:as { Atomy::AST::Send.new(line, r, Array(as), n) } | line:line level1:r cont(pos) level0:n args?:as { Atomy::AST::Send.new(line, r, Array(as), n) })
2602
+ def _sends(pos)
2603
+
2604
+ _save = self.pos
2605
+ while true # choice
2606
+
2607
+ _save1 = self.pos
2608
+ while true # sequence
2609
+ _tmp = apply(:_line)
2610
+ line = @result
2611
+ unless _tmp
2612
+ self.pos = _save1
2613
+ break
2614
+ end
2615
+ _tmp = apply(:_send)
2616
+ r = @result
2617
+ unless _tmp
2618
+ self.pos = _save1
2619
+ break
2620
+ end
2621
+ _tmp = _cont(pos)
2622
+ unless _tmp
2623
+ self.pos = _save1
2624
+ break
2625
+ end
2626
+ _tmp = apply(:_level0)
2627
+ n = @result
2628
+ unless _tmp
2629
+ self.pos = _save1
2630
+ break
2631
+ end
2632
+ _save2 = self.pos
2633
+ _tmp = apply(:_args)
2634
+ @result = nil unless _tmp
2635
+ unless _tmp
2636
+ _tmp = true
2637
+ self.pos = _save2
2638
+ end
2639
+ as = @result
2640
+ unless _tmp
2641
+ self.pos = _save1
2642
+ break
2643
+ end
2644
+ @result = begin; Atomy::AST::Send.new(line, r, Array(as), n) ; end
2645
+ _tmp = true
2646
+ unless _tmp
2647
+ self.pos = _save1
2648
+ end
2649
+ break
2650
+ end # end sequence
2651
+
2652
+ break if _tmp
2653
+ self.pos = _save
2654
+
2655
+ _save3 = self.pos
2656
+ while true # sequence
2657
+ _tmp = apply(:_line)
2658
+ line = @result
2659
+ unless _tmp
2660
+ self.pos = _save3
2661
+ break
2662
+ end
2663
+ _tmp = apply(:_level1)
2664
+ r = @result
2665
+ unless _tmp
2666
+ self.pos = _save3
2667
+ break
2668
+ end
2669
+ _tmp = _cont(pos)
2670
+ unless _tmp
2671
+ self.pos = _save3
2672
+ break
2673
+ end
2674
+ _tmp = apply(:_level0)
2675
+ n = @result
2676
+ unless _tmp
2677
+ self.pos = _save3
2678
+ break
2679
+ end
2680
+ _save4 = self.pos
2681
+ _tmp = apply(:_args)
2682
+ @result = nil unless _tmp
2683
+ unless _tmp
2684
+ _tmp = true
2685
+ self.pos = _save4
2686
+ end
2687
+ as = @result
2688
+ unless _tmp
2689
+ self.pos = _save3
2690
+ break
2691
+ end
2692
+ @result = begin; Atomy::AST::Send.new(line, r, Array(as), n) ; end
2693
+ _tmp = true
2694
+ unless _tmp
2695
+ self.pos = _save3
2696
+ end
2697
+ break
2698
+ end # end sequence
2699
+
2700
+ break if _tmp
2701
+ self.pos = _save
2702
+ break
2703
+ end # end choice
2704
+
2705
+ set_failed_rule :_sends unless _tmp
2706
+ return _tmp
2707
+ end
2708
+
2709
+ # send = sends(current_position)
2710
+ def _send
2711
+ _tmp = _sends(current_position)
2712
+ set_failed_rule :_send unless _tmp
2713
+ return _tmp
2714
+ end
2715
+
2716
+ # headless = line:line level0:n args:as { Atomy::AST::Send.new( line, Atomy::AST::Primitive.new(line, :self), as, n, nil, nil, true ) }
2717
+ def _headless
2718
+
2719
+ _save = self.pos
2720
+ while true # sequence
2721
+ _tmp = apply(:_line)
2722
+ line = @result
2723
+ unless _tmp
2724
+ self.pos = _save
2725
+ break
2726
+ end
2727
+ _tmp = apply(:_level0)
2728
+ n = @result
2729
+ unless _tmp
2730
+ self.pos = _save
2731
+ break
2732
+ end
2733
+ _tmp = apply(:_args)
2734
+ as = @result
2735
+ unless _tmp
2736
+ self.pos = _save
2737
+ break
2738
+ end
2739
+ @result = begin; Atomy::AST::Send.new(
2740
+ line,
2741
+ Atomy::AST::Primitive.new(line, :self),
2742
+ as,
2743
+ n,
2744
+ nil,
2745
+ nil,
2746
+ true
2747
+ )
2748
+ ; end
2749
+ _tmp = true
2750
+ unless _tmp
2751
+ self.pos = _save
2752
+ end
2753
+ break
2754
+ end # end sequence
2755
+
2756
+ set_failed_rule :_headless unless _tmp
2757
+ return _tmp
2758
+ end
2759
+
2760
+ # binary_c = (cont(pos) operator:o sig_wsp level2:e { [o, e] })+:bs { bs.flatten }
2761
+ def _binary_c(pos)
2762
+
2763
+ _save = self.pos
2764
+ while true # sequence
2765
+ _save1 = self.pos
2766
+ _ary = []
2767
+
2768
+ _save2 = self.pos
2769
+ while true # sequence
2770
+ _tmp = _cont(pos)
2771
+ unless _tmp
2772
+ self.pos = _save2
2773
+ break
2774
+ end
2775
+ _tmp = apply(:_operator)
2776
+ o = @result
2777
+ unless _tmp
2778
+ self.pos = _save2
2779
+ break
2780
+ end
2781
+ _tmp = apply(:_sig_wsp)
2782
+ unless _tmp
2783
+ self.pos = _save2
2784
+ break
2785
+ end
2786
+ _tmp = apply(:_level2)
2787
+ e = @result
2788
+ unless _tmp
2789
+ self.pos = _save2
2790
+ break
2791
+ end
2792
+ @result = begin; [o, e] ; end
2793
+ _tmp = true
2794
+ unless _tmp
2795
+ self.pos = _save2
2796
+ end
2797
+ break
2798
+ end # end sequence
2799
+
2800
+ if _tmp
2801
+ _ary << @result
2802
+ while true
2803
+
2804
+ _save3 = self.pos
2805
+ while true # sequence
2806
+ _tmp = _cont(pos)
2807
+ unless _tmp
2808
+ self.pos = _save3
2809
+ break
2810
+ end
2811
+ _tmp = apply(:_operator)
2812
+ o = @result
2813
+ unless _tmp
2814
+ self.pos = _save3
2815
+ break
2816
+ end
2817
+ _tmp = apply(:_sig_wsp)
2818
+ unless _tmp
2819
+ self.pos = _save3
2820
+ break
2821
+ end
2822
+ _tmp = apply(:_level2)
2823
+ e = @result
2824
+ unless _tmp
2825
+ self.pos = _save3
2826
+ break
2827
+ end
2828
+ @result = begin; [o, e] ; end
2829
+ _tmp = true
2830
+ unless _tmp
2831
+ self.pos = _save3
2832
+ end
2833
+ break
2834
+ end # end sequence
2835
+
2836
+ _ary << @result if _tmp
2837
+ break unless _tmp
2838
+ end
2839
+ _tmp = true
2840
+ @result = _ary
2841
+ else
2842
+ self.pos = _save1
2843
+ end
2844
+ bs = @result
2845
+ unless _tmp
2846
+ self.pos = _save
2847
+ break
2848
+ end
2849
+ @result = begin; bs.flatten ; end
2850
+ _tmp = true
2851
+ unless _tmp
2852
+ self.pos = _save
2853
+ end
2854
+ break
2855
+ end # end sequence
2856
+
2857
+ set_failed_rule :_binary_c unless _tmp
2858
+ return _tmp
2859
+ end
2860
+
2861
+ # binary_send = (level2:l binary_c(current_position):c { resolve(nil, l, c).first } | line:line operator:o sig_wsp expression:r { Atomy::AST::BinarySend.new( line, Atomy::AST::Primitive.new(line, :self), r, o, true ) })
2862
+ def _binary_send
2863
+
2864
+ _save = self.pos
2865
+ while true # choice
2866
+
2867
+ _save1 = self.pos
2868
+ while true # sequence
2869
+ _tmp = apply(:_level2)
2870
+ l = @result
2871
+ unless _tmp
2872
+ self.pos = _save1
2873
+ break
2874
+ end
2875
+ _tmp = _binary_c(current_position)
2876
+ c = @result
2877
+ unless _tmp
2878
+ self.pos = _save1
2879
+ break
2880
+ end
2881
+ @result = begin; resolve(nil, l, c).first ; end
2882
+ _tmp = true
2883
+ unless _tmp
2884
+ self.pos = _save1
2885
+ end
2886
+ break
2887
+ end # end sequence
2888
+
2889
+ break if _tmp
2890
+ self.pos = _save
2891
+
2892
+ _save2 = self.pos
2893
+ while true # sequence
2894
+ _tmp = apply(:_line)
2895
+ line = @result
2896
+ unless _tmp
2897
+ self.pos = _save2
2898
+ break
2899
+ end
2900
+ _tmp = apply(:_operator)
2901
+ o = @result
2902
+ unless _tmp
2903
+ self.pos = _save2
2904
+ break
2905
+ end
2906
+ _tmp = apply(:_sig_wsp)
2907
+ unless _tmp
2908
+ self.pos = _save2
2909
+ break
2910
+ end
2911
+ _tmp = apply(:_expression)
2912
+ r = @result
2913
+ unless _tmp
2914
+ self.pos = _save2
2915
+ break
2916
+ end
2917
+ @result = begin; Atomy::AST::BinarySend.new(
2918
+ line,
2919
+ Atomy::AST::Primitive.new(line, :self),
2920
+ r,
2921
+ o,
2922
+ true
2923
+ )
2924
+ ; end
2925
+ _tmp = true
2926
+ unless _tmp
2927
+ self.pos = _save2
2928
+ end
2929
+ break
2930
+ end # end sequence
2931
+
2932
+ break if _tmp
2933
+ self.pos = _save
2934
+ break
2935
+ end # end choice
2936
+
2937
+ set_failed_rule :_binary_send unless _tmp
2938
+ return _tmp
2939
+ end
2940
+
2941
+ # escapes = ("n" { "\n" } | "s" { " " } | "r" { "\r" } | "t" { "\t" } | "v" { "\v" } | "f" { "\f" } | "b" { "\b" } | "a" { "\a" } | "e" { "\e" } | "\\" { "\\" } | "\"" { "\"" } | "BS" { "\b" } | "HT" { "\t" } | "LF" { "\n" } | "VT" { "\v" } | "FF" { "\f" } | "CR" { "\r" } | "SO" { "\016" } | "SI" { "\017" } | "EM" { "\031" } | "FS" { "\034" } | "GS" { "\035" } | "RS" { "\036" } | "US" { "\037" } | "SP" { " " } | "NUL" { "\000" } | "SOH" { "\001" } | "STX" { "\002" } | "ETX" { "\003" } | "EOT" { "\004" } | "ENQ" { "\005" } | "ACK" { "\006" } | "BEL" { "\a" } | "DLE" { "\020" } | "DC1" { "\021" } | "DC2" { "\022" } | "DC3" { "\023" } | "DC4" { "\024" } | "NAK" { "\025" } | "SYN" { "\026" } | "ETB" { "\027" } | "CAN" { "\030" } | "SUB" { "\032" } | "ESC" { "\e" } | "DEL" { "\177" } | < . > { "\\" + text })
2942
+ def _escapes
2943
+
2944
+ _save = self.pos
2945
+ while true # choice
2946
+
2947
+ _save1 = self.pos
2948
+ while true # sequence
2949
+ _tmp = match_string("n")
2950
+ unless _tmp
2951
+ self.pos = _save1
2952
+ break
2953
+ end
2954
+ @result = begin; "\n" ; end
2955
+ _tmp = true
2956
+ unless _tmp
2957
+ self.pos = _save1
2958
+ end
2959
+ break
2960
+ end # end sequence
2961
+
2962
+ break if _tmp
2963
+ self.pos = _save
2964
+
2965
+ _save2 = self.pos
2966
+ while true # sequence
2967
+ _tmp = match_string("s")
2968
+ unless _tmp
2969
+ self.pos = _save2
2970
+ break
2971
+ end
2972
+ @result = begin; " " ; end
2973
+ _tmp = true
2974
+ unless _tmp
2975
+ self.pos = _save2
2976
+ end
2977
+ break
2978
+ end # end sequence
2979
+
2980
+ break if _tmp
2981
+ self.pos = _save
2982
+
2983
+ _save3 = self.pos
2984
+ while true # sequence
2985
+ _tmp = match_string("r")
2986
+ unless _tmp
2987
+ self.pos = _save3
2988
+ break
2989
+ end
2990
+ @result = begin; "\r" ; end
2991
+ _tmp = true
2992
+ unless _tmp
2993
+ self.pos = _save3
2994
+ end
2995
+ break
2996
+ end # end sequence
2997
+
2998
+ break if _tmp
2999
+ self.pos = _save
3000
+
3001
+ _save4 = self.pos
3002
+ while true # sequence
3003
+ _tmp = match_string("t")
3004
+ unless _tmp
3005
+ self.pos = _save4
3006
+ break
3007
+ end
3008
+ @result = begin; "\t" ; end
3009
+ _tmp = true
3010
+ unless _tmp
3011
+ self.pos = _save4
3012
+ end
3013
+ break
3014
+ end # end sequence
3015
+
3016
+ break if _tmp
3017
+ self.pos = _save
3018
+
3019
+ _save5 = self.pos
3020
+ while true # sequence
3021
+ _tmp = match_string("v")
3022
+ unless _tmp
3023
+ self.pos = _save5
3024
+ break
3025
+ end
3026
+ @result = begin; "\v" ; end
3027
+ _tmp = true
3028
+ unless _tmp
3029
+ self.pos = _save5
3030
+ end
3031
+ break
3032
+ end # end sequence
3033
+
3034
+ break if _tmp
3035
+ self.pos = _save
3036
+
3037
+ _save6 = self.pos
3038
+ while true # sequence
3039
+ _tmp = match_string("f")
3040
+ unless _tmp
3041
+ self.pos = _save6
3042
+ break
3043
+ end
3044
+ @result = begin; "\f" ; end
3045
+ _tmp = true
3046
+ unless _tmp
3047
+ self.pos = _save6
3048
+ end
3049
+ break
3050
+ end # end sequence
3051
+
3052
+ break if _tmp
3053
+ self.pos = _save
3054
+
3055
+ _save7 = self.pos
3056
+ while true # sequence
3057
+ _tmp = match_string("b")
3058
+ unless _tmp
3059
+ self.pos = _save7
3060
+ break
3061
+ end
3062
+ @result = begin; "\b" ; end
3063
+ _tmp = true
3064
+ unless _tmp
3065
+ self.pos = _save7
3066
+ end
3067
+ break
3068
+ end # end sequence
3069
+
3070
+ break if _tmp
3071
+ self.pos = _save
3072
+
3073
+ _save8 = self.pos
3074
+ while true # sequence
3075
+ _tmp = match_string("a")
3076
+ unless _tmp
3077
+ self.pos = _save8
3078
+ break
3079
+ end
3080
+ @result = begin; "\a" ; end
3081
+ _tmp = true
3082
+ unless _tmp
3083
+ self.pos = _save8
3084
+ end
3085
+ break
3086
+ end # end sequence
3087
+
3088
+ break if _tmp
3089
+ self.pos = _save
3090
+
3091
+ _save9 = self.pos
3092
+ while true # sequence
3093
+ _tmp = match_string("e")
3094
+ unless _tmp
3095
+ self.pos = _save9
3096
+ break
3097
+ end
3098
+ @result = begin; "\e" ; end
3099
+ _tmp = true
3100
+ unless _tmp
3101
+ self.pos = _save9
3102
+ end
3103
+ break
3104
+ end # end sequence
3105
+
3106
+ break if _tmp
3107
+ self.pos = _save
3108
+
3109
+ _save10 = self.pos
3110
+ while true # sequence
3111
+ _tmp = match_string("\\")
3112
+ unless _tmp
3113
+ self.pos = _save10
3114
+ break
3115
+ end
3116
+ @result = begin; "\\" ; end
3117
+ _tmp = true
3118
+ unless _tmp
3119
+ self.pos = _save10
3120
+ end
3121
+ break
3122
+ end # end sequence
3123
+
3124
+ break if _tmp
3125
+ self.pos = _save
3126
+
3127
+ _save11 = self.pos
3128
+ while true # sequence
3129
+ _tmp = match_string("\"")
3130
+ unless _tmp
3131
+ self.pos = _save11
3132
+ break
3133
+ end
3134
+ @result = begin; "\"" ; end
3135
+ _tmp = true
3136
+ unless _tmp
3137
+ self.pos = _save11
3138
+ end
3139
+ break
3140
+ end # end sequence
3141
+
3142
+ break if _tmp
3143
+ self.pos = _save
3144
+
3145
+ _save12 = self.pos
3146
+ while true # sequence
3147
+ _tmp = match_string("BS")
3148
+ unless _tmp
3149
+ self.pos = _save12
3150
+ break
3151
+ end
3152
+ @result = begin; "\b" ; end
3153
+ _tmp = true
3154
+ unless _tmp
3155
+ self.pos = _save12
3156
+ end
3157
+ break
3158
+ end # end sequence
3159
+
3160
+ break if _tmp
3161
+ self.pos = _save
3162
+
3163
+ _save13 = self.pos
3164
+ while true # sequence
3165
+ _tmp = match_string("HT")
3166
+ unless _tmp
3167
+ self.pos = _save13
3168
+ break
3169
+ end
3170
+ @result = begin; "\t" ; end
3171
+ _tmp = true
3172
+ unless _tmp
3173
+ self.pos = _save13
3174
+ end
3175
+ break
3176
+ end # end sequence
3177
+
3178
+ break if _tmp
3179
+ self.pos = _save
3180
+
3181
+ _save14 = self.pos
3182
+ while true # sequence
3183
+ _tmp = match_string("LF")
3184
+ unless _tmp
3185
+ self.pos = _save14
3186
+ break
3187
+ end
3188
+ @result = begin; "\n" ; end
3189
+ _tmp = true
3190
+ unless _tmp
3191
+ self.pos = _save14
3192
+ end
3193
+ break
3194
+ end # end sequence
3195
+
3196
+ break if _tmp
3197
+ self.pos = _save
3198
+
3199
+ _save15 = self.pos
3200
+ while true # sequence
3201
+ _tmp = match_string("VT")
3202
+ unless _tmp
3203
+ self.pos = _save15
3204
+ break
3205
+ end
3206
+ @result = begin; "\v" ; end
3207
+ _tmp = true
3208
+ unless _tmp
3209
+ self.pos = _save15
3210
+ end
3211
+ break
3212
+ end # end sequence
3213
+
3214
+ break if _tmp
3215
+ self.pos = _save
3216
+
3217
+ _save16 = self.pos
3218
+ while true # sequence
3219
+ _tmp = match_string("FF")
3220
+ unless _tmp
3221
+ self.pos = _save16
3222
+ break
3223
+ end
3224
+ @result = begin; "\f" ; end
3225
+ _tmp = true
3226
+ unless _tmp
3227
+ self.pos = _save16
3228
+ end
3229
+ break
3230
+ end # end sequence
3231
+
3232
+ break if _tmp
3233
+ self.pos = _save
3234
+
3235
+ _save17 = self.pos
3236
+ while true # sequence
3237
+ _tmp = match_string("CR")
3238
+ unless _tmp
3239
+ self.pos = _save17
3240
+ break
3241
+ end
3242
+ @result = begin; "\r" ; end
3243
+ _tmp = true
3244
+ unless _tmp
3245
+ self.pos = _save17
3246
+ end
3247
+ break
3248
+ end # end sequence
3249
+
3250
+ break if _tmp
3251
+ self.pos = _save
3252
+
3253
+ _save18 = self.pos
3254
+ while true # sequence
3255
+ _tmp = match_string("SO")
3256
+ unless _tmp
3257
+ self.pos = _save18
3258
+ break
3259
+ end
3260
+ @result = begin; "\016" ; end
3261
+ _tmp = true
3262
+ unless _tmp
3263
+ self.pos = _save18
3264
+ end
3265
+ break
3266
+ end # end sequence
3267
+
3268
+ break if _tmp
3269
+ self.pos = _save
3270
+
3271
+ _save19 = self.pos
3272
+ while true # sequence
3273
+ _tmp = match_string("SI")
3274
+ unless _tmp
3275
+ self.pos = _save19
3276
+ break
3277
+ end
3278
+ @result = begin; "\017" ; end
3279
+ _tmp = true
3280
+ unless _tmp
3281
+ self.pos = _save19
3282
+ end
3283
+ break
3284
+ end # end sequence
3285
+
3286
+ break if _tmp
3287
+ self.pos = _save
3288
+
3289
+ _save20 = self.pos
3290
+ while true # sequence
3291
+ _tmp = match_string("EM")
3292
+ unless _tmp
3293
+ self.pos = _save20
3294
+ break
3295
+ end
3296
+ @result = begin; "\031" ; end
3297
+ _tmp = true
3298
+ unless _tmp
3299
+ self.pos = _save20
3300
+ end
3301
+ break
3302
+ end # end sequence
3303
+
3304
+ break if _tmp
3305
+ self.pos = _save
3306
+
3307
+ _save21 = self.pos
3308
+ while true # sequence
3309
+ _tmp = match_string("FS")
3310
+ unless _tmp
3311
+ self.pos = _save21
3312
+ break
3313
+ end
3314
+ @result = begin; "\034" ; end
3315
+ _tmp = true
3316
+ unless _tmp
3317
+ self.pos = _save21
3318
+ end
3319
+ break
3320
+ end # end sequence
3321
+
3322
+ break if _tmp
3323
+ self.pos = _save
3324
+
3325
+ _save22 = self.pos
3326
+ while true # sequence
3327
+ _tmp = match_string("GS")
3328
+ unless _tmp
3329
+ self.pos = _save22
3330
+ break
3331
+ end
3332
+ @result = begin; "\035" ; end
3333
+ _tmp = true
3334
+ unless _tmp
3335
+ self.pos = _save22
3336
+ end
3337
+ break
3338
+ end # end sequence
3339
+
3340
+ break if _tmp
3341
+ self.pos = _save
3342
+
3343
+ _save23 = self.pos
3344
+ while true # sequence
3345
+ _tmp = match_string("RS")
3346
+ unless _tmp
3347
+ self.pos = _save23
3348
+ break
3349
+ end
3350
+ @result = begin; "\036" ; end
3351
+ _tmp = true
3352
+ unless _tmp
3353
+ self.pos = _save23
3354
+ end
3355
+ break
3356
+ end # end sequence
3357
+
3358
+ break if _tmp
3359
+ self.pos = _save
3360
+
3361
+ _save24 = self.pos
3362
+ while true # sequence
3363
+ _tmp = match_string("US")
3364
+ unless _tmp
3365
+ self.pos = _save24
3366
+ break
3367
+ end
3368
+ @result = begin; "\037" ; end
3369
+ _tmp = true
3370
+ unless _tmp
3371
+ self.pos = _save24
3372
+ end
3373
+ break
3374
+ end # end sequence
3375
+
3376
+ break if _tmp
3377
+ self.pos = _save
3378
+
3379
+ _save25 = self.pos
3380
+ while true # sequence
3381
+ _tmp = match_string("SP")
3382
+ unless _tmp
3383
+ self.pos = _save25
3384
+ break
3385
+ end
3386
+ @result = begin; " " ; end
3387
+ _tmp = true
3388
+ unless _tmp
3389
+ self.pos = _save25
3390
+ end
3391
+ break
3392
+ end # end sequence
3393
+
3394
+ break if _tmp
3395
+ self.pos = _save
3396
+
3397
+ _save26 = self.pos
3398
+ while true # sequence
3399
+ _tmp = match_string("NUL")
3400
+ unless _tmp
3401
+ self.pos = _save26
3402
+ break
3403
+ end
3404
+ @result = begin; "\000" ; end
3405
+ _tmp = true
3406
+ unless _tmp
3407
+ self.pos = _save26
3408
+ end
3409
+ break
3410
+ end # end sequence
3411
+
3412
+ break if _tmp
3413
+ self.pos = _save
3414
+
3415
+ _save27 = self.pos
3416
+ while true # sequence
3417
+ _tmp = match_string("SOH")
3418
+ unless _tmp
3419
+ self.pos = _save27
3420
+ break
3421
+ end
3422
+ @result = begin; "\001" ; end
3423
+ _tmp = true
3424
+ unless _tmp
3425
+ self.pos = _save27
3426
+ end
3427
+ break
3428
+ end # end sequence
3429
+
3430
+ break if _tmp
3431
+ self.pos = _save
3432
+
3433
+ _save28 = self.pos
3434
+ while true # sequence
3435
+ _tmp = match_string("STX")
3436
+ unless _tmp
3437
+ self.pos = _save28
3438
+ break
3439
+ end
3440
+ @result = begin; "\002" ; end
3441
+ _tmp = true
3442
+ unless _tmp
3443
+ self.pos = _save28
3444
+ end
3445
+ break
3446
+ end # end sequence
3447
+
3448
+ break if _tmp
3449
+ self.pos = _save
3450
+
3451
+ _save29 = self.pos
3452
+ while true # sequence
3453
+ _tmp = match_string("ETX")
3454
+ unless _tmp
3455
+ self.pos = _save29
3456
+ break
3457
+ end
3458
+ @result = begin; "\003" ; end
3459
+ _tmp = true
3460
+ unless _tmp
3461
+ self.pos = _save29
3462
+ end
3463
+ break
3464
+ end # end sequence
3465
+
3466
+ break if _tmp
3467
+ self.pos = _save
3468
+
3469
+ _save30 = self.pos
3470
+ while true # sequence
3471
+ _tmp = match_string("EOT")
3472
+ unless _tmp
3473
+ self.pos = _save30
3474
+ break
3475
+ end
3476
+ @result = begin; "\004" ; end
3477
+ _tmp = true
3478
+ unless _tmp
3479
+ self.pos = _save30
3480
+ end
3481
+ break
3482
+ end # end sequence
3483
+
3484
+ break if _tmp
3485
+ self.pos = _save
3486
+
3487
+ _save31 = self.pos
3488
+ while true # sequence
3489
+ _tmp = match_string("ENQ")
3490
+ unless _tmp
3491
+ self.pos = _save31
3492
+ break
3493
+ end
3494
+ @result = begin; "\005" ; end
3495
+ _tmp = true
3496
+ unless _tmp
3497
+ self.pos = _save31
3498
+ end
3499
+ break
3500
+ end # end sequence
3501
+
3502
+ break if _tmp
3503
+ self.pos = _save
3504
+
3505
+ _save32 = self.pos
3506
+ while true # sequence
3507
+ _tmp = match_string("ACK")
3508
+ unless _tmp
3509
+ self.pos = _save32
3510
+ break
3511
+ end
3512
+ @result = begin; "\006" ; end
3513
+ _tmp = true
3514
+ unless _tmp
3515
+ self.pos = _save32
3516
+ end
3517
+ break
3518
+ end # end sequence
3519
+
3520
+ break if _tmp
3521
+ self.pos = _save
3522
+
3523
+ _save33 = self.pos
3524
+ while true # sequence
3525
+ _tmp = match_string("BEL")
3526
+ unless _tmp
3527
+ self.pos = _save33
3528
+ break
3529
+ end
3530
+ @result = begin; "\a" ; end
3531
+ _tmp = true
3532
+ unless _tmp
3533
+ self.pos = _save33
3534
+ end
3535
+ break
3536
+ end # end sequence
3537
+
3538
+ break if _tmp
3539
+ self.pos = _save
3540
+
3541
+ _save34 = self.pos
3542
+ while true # sequence
3543
+ _tmp = match_string("DLE")
3544
+ unless _tmp
3545
+ self.pos = _save34
3546
+ break
3547
+ end
3548
+ @result = begin; "\020" ; end
3549
+ _tmp = true
3550
+ unless _tmp
3551
+ self.pos = _save34
3552
+ end
3553
+ break
3554
+ end # end sequence
3555
+
3556
+ break if _tmp
3557
+ self.pos = _save
3558
+
3559
+ _save35 = self.pos
3560
+ while true # sequence
3561
+ _tmp = match_string("DC1")
3562
+ unless _tmp
3563
+ self.pos = _save35
3564
+ break
3565
+ end
3566
+ @result = begin; "\021" ; end
3567
+ _tmp = true
3568
+ unless _tmp
3569
+ self.pos = _save35
3570
+ end
3571
+ break
3572
+ end # end sequence
3573
+
3574
+ break if _tmp
3575
+ self.pos = _save
3576
+
3577
+ _save36 = self.pos
3578
+ while true # sequence
3579
+ _tmp = match_string("DC2")
3580
+ unless _tmp
3581
+ self.pos = _save36
3582
+ break
3583
+ end
3584
+ @result = begin; "\022" ; end
3585
+ _tmp = true
3586
+ unless _tmp
3587
+ self.pos = _save36
3588
+ end
3589
+ break
3590
+ end # end sequence
3591
+
3592
+ break if _tmp
3593
+ self.pos = _save
3594
+
3595
+ _save37 = self.pos
3596
+ while true # sequence
3597
+ _tmp = match_string("DC3")
3598
+ unless _tmp
3599
+ self.pos = _save37
3600
+ break
3601
+ end
3602
+ @result = begin; "\023" ; end
3603
+ _tmp = true
3604
+ unless _tmp
3605
+ self.pos = _save37
3606
+ end
3607
+ break
3608
+ end # end sequence
3609
+
3610
+ break if _tmp
3611
+ self.pos = _save
3612
+
3613
+ _save38 = self.pos
3614
+ while true # sequence
3615
+ _tmp = match_string("DC4")
3616
+ unless _tmp
3617
+ self.pos = _save38
3618
+ break
3619
+ end
3620
+ @result = begin; "\024" ; end
3621
+ _tmp = true
3622
+ unless _tmp
3623
+ self.pos = _save38
3624
+ end
3625
+ break
3626
+ end # end sequence
3627
+
3628
+ break if _tmp
3629
+ self.pos = _save
3630
+
3631
+ _save39 = self.pos
3632
+ while true # sequence
3633
+ _tmp = match_string("NAK")
3634
+ unless _tmp
3635
+ self.pos = _save39
3636
+ break
3637
+ end
3638
+ @result = begin; "\025" ; end
3639
+ _tmp = true
3640
+ unless _tmp
3641
+ self.pos = _save39
3642
+ end
3643
+ break
3644
+ end # end sequence
3645
+
3646
+ break if _tmp
3647
+ self.pos = _save
3648
+
3649
+ _save40 = self.pos
3650
+ while true # sequence
3651
+ _tmp = match_string("SYN")
3652
+ unless _tmp
3653
+ self.pos = _save40
3654
+ break
3655
+ end
3656
+ @result = begin; "\026" ; end
3657
+ _tmp = true
3658
+ unless _tmp
3659
+ self.pos = _save40
3660
+ end
3661
+ break
3662
+ end # end sequence
3663
+
3664
+ break if _tmp
3665
+ self.pos = _save
3666
+
3667
+ _save41 = self.pos
3668
+ while true # sequence
3669
+ _tmp = match_string("ETB")
3670
+ unless _tmp
3671
+ self.pos = _save41
3672
+ break
3673
+ end
3674
+ @result = begin; "\027" ; end
3675
+ _tmp = true
3676
+ unless _tmp
3677
+ self.pos = _save41
3678
+ end
3679
+ break
3680
+ end # end sequence
3681
+
3682
+ break if _tmp
3683
+ self.pos = _save
3684
+
3685
+ _save42 = self.pos
3686
+ while true # sequence
3687
+ _tmp = match_string("CAN")
3688
+ unless _tmp
3689
+ self.pos = _save42
3690
+ break
3691
+ end
3692
+ @result = begin; "\030" ; end
3693
+ _tmp = true
3694
+ unless _tmp
3695
+ self.pos = _save42
3696
+ end
3697
+ break
3698
+ end # end sequence
3699
+
3700
+ break if _tmp
3701
+ self.pos = _save
3702
+
3703
+ _save43 = self.pos
3704
+ while true # sequence
3705
+ _tmp = match_string("SUB")
3706
+ unless _tmp
3707
+ self.pos = _save43
3708
+ break
3709
+ end
3710
+ @result = begin; "\032" ; end
3711
+ _tmp = true
3712
+ unless _tmp
3713
+ self.pos = _save43
3714
+ end
3715
+ break
3716
+ end # end sequence
3717
+
3718
+ break if _tmp
3719
+ self.pos = _save
3720
+
3721
+ _save44 = self.pos
3722
+ while true # sequence
3723
+ _tmp = match_string("ESC")
3724
+ unless _tmp
3725
+ self.pos = _save44
3726
+ break
3727
+ end
3728
+ @result = begin; "\e" ; end
3729
+ _tmp = true
3730
+ unless _tmp
3731
+ self.pos = _save44
3732
+ end
3733
+ break
3734
+ end # end sequence
3735
+
3736
+ break if _tmp
3737
+ self.pos = _save
3738
+
3739
+ _save45 = self.pos
3740
+ while true # sequence
3741
+ _tmp = match_string("DEL")
3742
+ unless _tmp
3743
+ self.pos = _save45
3744
+ break
3745
+ end
3746
+ @result = begin; "\177" ; end
3747
+ _tmp = true
3748
+ unless _tmp
3749
+ self.pos = _save45
3750
+ end
3751
+ break
3752
+ end # end sequence
3753
+
3754
+ break if _tmp
3755
+ self.pos = _save
3756
+
3757
+ _save46 = self.pos
3758
+ while true # sequence
3759
+ _text_start = self.pos
3760
+ _tmp = get_byte
3761
+ if _tmp
3762
+ text = get_text(_text_start)
3763
+ end
3764
+ unless _tmp
3765
+ self.pos = _save46
3766
+ break
3767
+ end
3768
+ @result = begin; "\\" + text ; end
3769
+ _tmp = true
3770
+ unless _tmp
3771
+ self.pos = _save46
3772
+ end
3773
+ break
3774
+ end # end sequence
3775
+
3776
+ break if _tmp
3777
+ self.pos = _save
3778
+ break
3779
+ end # end choice
3780
+
3781
+ set_failed_rule :_escapes unless _tmp
3782
+ return _tmp
3783
+ end
3784
+
3785
+ # number_escapes = (/[xX]/ < /[0-9a-fA-F]{1,5}/ > { [text.to_i(16)].pack("U") } | < /\d{1,6}/ > { [text.to_i].pack("U") } | /[oO]/ < /[0-7]{1,7}/ > { [text.to_i(16)].pack("U") } | /[uU]/ < /[0-9a-fA-F]{4}/ > { [text.to_i(16)].pack("U") })
3786
+ def _number_escapes
3787
+
3788
+ _save = self.pos
3789
+ while true # choice
3790
+
3791
+ _save1 = self.pos
3792
+ while true # sequence
3793
+ _tmp = scan(/\A(?-mix:[xX])/)
3794
+ unless _tmp
3795
+ self.pos = _save1
3796
+ break
3797
+ end
3798
+ _text_start = self.pos
3799
+ _tmp = scan(/\A(?-mix:[0-9a-fA-F]{1,5})/)
3800
+ if _tmp
3801
+ text = get_text(_text_start)
3802
+ end
3803
+ unless _tmp
3804
+ self.pos = _save1
3805
+ break
3806
+ end
3807
+ @result = begin; [text.to_i(16)].pack("U") ; end
3808
+ _tmp = true
3809
+ unless _tmp
3810
+ self.pos = _save1
3811
+ end
3812
+ break
3813
+ end # end sequence
3814
+
3815
+ break if _tmp
3816
+ self.pos = _save
3817
+
3818
+ _save2 = self.pos
3819
+ while true # sequence
3820
+ _text_start = self.pos
3821
+ _tmp = scan(/\A(?-mix:\d{1,6})/)
3822
+ if _tmp
3823
+ text = get_text(_text_start)
3824
+ end
3825
+ unless _tmp
3826
+ self.pos = _save2
3827
+ break
3828
+ end
3829
+ @result = begin; [text.to_i].pack("U") ; end
3830
+ _tmp = true
3831
+ unless _tmp
3832
+ self.pos = _save2
3833
+ end
3834
+ break
3835
+ end # end sequence
3836
+
3837
+ break if _tmp
3838
+ self.pos = _save
3839
+
3840
+ _save3 = self.pos
3841
+ while true # sequence
3842
+ _tmp = scan(/\A(?-mix:[oO])/)
3843
+ unless _tmp
3844
+ self.pos = _save3
3845
+ break
3846
+ end
3847
+ _text_start = self.pos
3848
+ _tmp = scan(/\A(?-mix:[0-7]{1,7})/)
3849
+ if _tmp
3850
+ text = get_text(_text_start)
3851
+ end
3852
+ unless _tmp
3853
+ self.pos = _save3
3854
+ break
3855
+ end
3856
+ @result = begin; [text.to_i(16)].pack("U") ; end
3857
+ _tmp = true
3858
+ unless _tmp
3859
+ self.pos = _save3
3860
+ end
3861
+ break
3862
+ end # end sequence
3863
+
3864
+ break if _tmp
3865
+ self.pos = _save
3866
+
3867
+ _save4 = self.pos
3868
+ while true # sequence
3869
+ _tmp = scan(/\A(?-mix:[uU])/)
3870
+ unless _tmp
3871
+ self.pos = _save4
3872
+ break
3873
+ end
3874
+ _text_start = self.pos
3875
+ _tmp = scan(/\A(?-mix:[0-9a-fA-F]{4})/)
3876
+ if _tmp
3877
+ text = get_text(_text_start)
3878
+ end
3879
+ unless _tmp
3880
+ self.pos = _save4
3881
+ break
3882
+ end
3883
+ @result = begin; [text.to_i(16)].pack("U") ; end
3884
+ _tmp = true
3885
+ unless _tmp
3886
+ self.pos = _save4
3887
+ end
3888
+ break
3889
+ end # end sequence
3890
+
3891
+ break if _tmp
3892
+ self.pos = _save
3893
+ break
3894
+ end # end choice
3895
+
3896
+ set_failed_rule :_number_escapes unless _tmp
3897
+ return _tmp
3898
+ end
3899
+
3900
+ # root = wsp expressions:es wsp !. { Array(es) }
3901
+ def _root
3902
+
3903
+ _save = self.pos
3904
+ while true # sequence
3905
+ _tmp = apply(:_wsp)
3906
+ unless _tmp
3907
+ self.pos = _save
3908
+ break
3909
+ end
3910
+ _tmp = apply(:_expressions)
3911
+ es = @result
3912
+ unless _tmp
3913
+ self.pos = _save
3914
+ break
3915
+ end
3916
+ _tmp = apply(:_wsp)
3917
+ unless _tmp
3918
+ self.pos = _save
3919
+ break
3920
+ end
3921
+ _save1 = self.pos
3922
+ _tmp = get_byte
3923
+ _tmp = _tmp ? nil : true
3924
+ self.pos = _save1
3925
+ unless _tmp
3926
+ self.pos = _save
3927
+ break
3928
+ end
3929
+ @result = begin; Array(es) ; end
3930
+ _tmp = true
3931
+ unless _tmp
3932
+ self.pos = _save
3933
+ end
3934
+ break
3935
+ end # end sequence
3936
+
3937
+ set_failed_rule :_root unless _tmp
3938
+ return _tmp
3939
+ end
3940
+
3941
+ Rules = {}
3942
+ Rules[:_sp] = rule_info("sp", "(\" \" | \"\\t\" | comment)*")
3943
+ Rules[:_wsp] = rule_info("wsp", "(\" \" | \"\\t\" | \"\\n\" | comment)*")
3944
+ Rules[:_sig_sp] = rule_info("sig_sp", "(\" \" | \"\\t\" | comment)+")
3945
+ Rules[:_sig_wsp] = rule_info("sig_wsp", "(\" \" | \"\\t\" | \"\\n\" | comment)+")
3946
+ Rules[:_cont] = rule_info("cont", "((\"\\n\" sp)+ &{ continue?(p) } | sig_sp ((\"\\n\" sp)+ &{ continue?(p) })? | &.)")
3947
+ Rules[:_line] = rule_info("line", "{ current_line }")
3948
+ Rules[:_ident_start] = rule_info("ident_start", "< /[\\p{Ll}_]/u > { text }")
3949
+ Rules[:_ident_letter] = rule_info("ident_letter", "< (/[\\p{L}\\d]/u | !\":\" op_letter) > { text }")
3950
+ Rules[:_op_letter] = rule_info("op_letter", "< /[\\p{S}!@\#%&*\\-\\\\:.\\/\\?]/u > { text }")
3951
+ Rules[:_operator] = rule_info("operator", "< op_letter+ > &{ text != \":\" } { text }")
3952
+ Rules[:_identifier] = rule_info("identifier", "< ident_start ident_letter* > { text.tr(\"-\", \"_\") }")
3953
+ Rules[:_grouped] = rule_info("grouped", "\"(\" wsp expression:x wsp \")\" { x }")
3954
+ Rules[:_comment] = rule_info("comment", "(/--.*?$/ | multi_comment)")
3955
+ Rules[:_multi_comment] = rule_info("multi_comment", "\"{-\" in_multi")
3956
+ Rules[:_in_multi] = rule_info("in_multi", "(/[^\\-\\{\\}]*/ \"-}\" | /[^\\-\\{\\}]*/ \"{-\" in_multi /[^\\-\\{\\}]*/ \"-}\" | /[^\\-\\{\\}]*/ /[-{}]/ in_multi)")
3957
+ Rules[:_delim] = rule_info("delim", "(wsp \",\" wsp | (sp \"\\n\" sp)+ &{ current_column >= c })")
3958
+ Rules[:_expression] = rule_info("expression", "level3")
3959
+ Rules[:_expressions] = rule_info("expressions", "{ current_column }:c expression:x (delim(c) expression)*:xs delim(c)? { [x] + Array(xs) }")
3960
+ Rules[:_level0] = rule_info("level0", "(true | false | self | nil | number | quote | quasi_quote | splice | unquote | string | constant | variable | block | list | unary)")
3961
+ Rules[:_level1] = rule_info("level1", "(headless | grouped | level0)")
3962
+ Rules[:_level2] = rule_info("level2", "(send | level1)")
3963
+ Rules[:_level3] = rule_info("level3", "(macro | op_assoc_prec | binary_send | level2)")
3964
+ Rules[:_true] = rule_info("true", "line:line \"true\" !ident_letter { Atomy::AST::Primitive.new(line, :true) }")
3965
+ Rules[:_false] = rule_info("false", "line:line \"false\" !ident_letter { Atomy::AST::Primitive.new(line, :false) }")
3966
+ Rules[:_self] = rule_info("self", "line:line \"self\" !ident_letter { Atomy::AST::Primitive.new(line, :self) }")
3967
+ Rules[:_nil] = rule_info("nil", "line:line \"nil\" !ident_letter { Atomy::AST::Primitive.new(line, :nil) }")
3968
+ Rules[:_number] = rule_info("number", "(line:line < /[\\+\\-]?0[oO][\\da-fA-F]+/ > { Atomy::AST::Primitive.new(line, text.to_i(8)) } | line:line < /[\\+\\-]?0[xX][0-7]+/ > { Atomy::AST::Primitive.new(line, text.to_i(16)) } | line:line < /[\\+\\-]?\\d+(\\.\\d+)?[eE][\\+\\-]?\\d+/ > { Atomy::AST::Primitive.new(line, text.to_f) } | line:line < /[\\+\\-]?\\d+\\.\\d+/ > { Atomy::AST::Primitive.new(line, text.to_f) } | line:line < /[\\+\\-]?\\d+/ > { Atomy::AST::Primitive.new(line, text.to_i) })")
3969
+ Rules[:_macro] = rule_info("macro", "line:line \"macro\" \"(\" wsp expression:p wsp \")\" wsp block:b { Atomy::AST::Macro.new(line, p, b.block_body) }")
3970
+ Rules[:_op_assoc] = rule_info("op_assoc", "sig_wsp < /left|right/ > { text.to_sym }")
3971
+ Rules[:_op_prec] = rule_info("op_prec", "sig_wsp < /[0-9]+/ > { text.to_i }")
3972
+ Rules[:_op_assoc_prec] = rule_info("op_assoc_prec", "line:line \"operator\" op_assoc?:assoc op_prec:prec (sig_wsp operator)+:os { Atomy::Macro.set_op_info(os, assoc, prec) Atomy::AST::Operator.new(line, assoc, prec, os) }")
3973
+ Rules[:_quote] = rule_info("quote", "line:line \"'\" level1:e { Atomy::AST::Quote.new(line, e) }")
3974
+ Rules[:_quasi_quote] = rule_info("quasi_quote", "line:line \"`\" level1:e { Atomy::AST::QuasiQuote.new(line, e) }")
3975
+ Rules[:_splice] = rule_info("splice", "line:line \"~*\" level1:e { Atomy::AST::Splice.new(line, e) }")
3976
+ Rules[:_unquote] = rule_info("unquote", "line:line \"~\" level1:e { Atomy::AST::Unquote.new(line, e) }")
3977
+ Rules[:_escape] = rule_info("escape", "(number_escapes | escapes)")
3978
+ Rules[:_str_seq] = rule_info("str_seq", "< /[^\\\\\"]+/ > { text }")
3979
+ Rules[:_string] = rule_info("string", "line:line \"\\\"\" < (\"\\\\\" escape | str_seq)*:c > \"\\\"\" { Atomy::AST::String.new( line, c.join, text.gsub(\"\\\\\\\"\", \"\\\"\") ) }")
3980
+ Rules[:_constant_name] = rule_info("constant_name", "< /[A-Z][a-zA-Z0-9_]*/ > { text }")
3981
+ Rules[:_constant] = rule_info("constant", "(line:line constant_name:m (\"::\" constant_name)*:s { names = [m] + Array(s) const_chain(line, names) } | line:line (\"::\" constant_name)+:s { names = Array(s) const_chain(line, names, true) })")
3982
+ Rules[:_variable] = rule_info("variable", "line:line identifier:n { Atomy::AST::Variable.new(line, n.gsub(\"/\", Atomy::NAMESPACE_DELIM)) }")
3983
+ Rules[:_unary] = rule_info("unary", "line:line !\":\" op_letter:o level1:e { Atomy::AST::Unary.new(line, e, o) }")
3984
+ Rules[:_args] = rule_info("args", "\"(\" wsp expressions?:as wsp \")\" { Array(as) }")
3985
+ Rules[:_block] = rule_info("block", "(line:line \":\" !operator wsp expressions?:es (wsp \";\")? { Atomy::AST::Block.new(line, Array(es), []) } | line:line \"{\" wsp expressions?:es wsp \"}\" { Atomy::AST::Block.new(line, Array(es), []) })")
3986
+ Rules[:_list] = rule_info("list", "line:line \"[\" wsp expressions?:es wsp \"]\" { Atomy::AST::List.new(line, Array(es)) }")
3987
+ Rules[:_sends] = rule_info("sends", "(line:line send:r cont(pos) level0:n args?:as { Atomy::AST::Send.new(line, r, Array(as), n) } | line:line level1:r cont(pos) level0:n args?:as { Atomy::AST::Send.new(line, r, Array(as), n) })")
3988
+ Rules[:_send] = rule_info("send", "sends(current_position)")
3989
+ Rules[:_headless] = rule_info("headless", "line:line level0:n args:as { Atomy::AST::Send.new( line, Atomy::AST::Primitive.new(line, :self), as, n, nil, nil, true ) }")
3990
+ Rules[:_binary_c] = rule_info("binary_c", "(cont(pos) operator:o sig_wsp level2:e { [o, e] })+:bs { bs.flatten }")
3991
+ Rules[:_binary_send] = rule_info("binary_send", "(level2:l binary_c(current_position):c { resolve(nil, l, c).first } | line:line operator:o sig_wsp expression:r { Atomy::AST::BinarySend.new( line, Atomy::AST::Primitive.new(line, :self), r, o, true ) })")
3992
+ Rules[:_escapes] = rule_info("escapes", "(\"n\" { \"\\n\" } | \"s\" { \" \" } | \"r\" { \"\\r\" } | \"t\" { \"\\t\" } | \"v\" { \"\\v\" } | \"f\" { \"\\f\" } | \"b\" { \"\\b\" } | \"a\" { \"\\a\" } | \"e\" { \"\\e\" } | \"\\\\\" { \"\\\\\" } | \"\\\"\" { \"\\\"\" } | \"BS\" { \"\\b\" } | \"HT\" { \"\\t\" } | \"LF\" { \"\\n\" } | \"VT\" { \"\\v\" } | \"FF\" { \"\\f\" } | \"CR\" { \"\\r\" } | \"SO\" { \"\\016\" } | \"SI\" { \"\\017\" } | \"EM\" { \"\\031\" } | \"FS\" { \"\\034\" } | \"GS\" { \"\\035\" } | \"RS\" { \"\\036\" } | \"US\" { \"\\037\" } | \"SP\" { \" \" } | \"NUL\" { \"\\000\" } | \"SOH\" { \"\\001\" } | \"STX\" { \"\\002\" } | \"ETX\" { \"\\003\" } | \"EOT\" { \"\\004\" } | \"ENQ\" { \"\\005\" } | \"ACK\" { \"\\006\" } | \"BEL\" { \"\\a\" } | \"DLE\" { \"\\020\" } | \"DC1\" { \"\\021\" } | \"DC2\" { \"\\022\" } | \"DC3\" { \"\\023\" } | \"DC4\" { \"\\024\" } | \"NAK\" { \"\\025\" } | \"SYN\" { \"\\026\" } | \"ETB\" { \"\\027\" } | \"CAN\" { \"\\030\" } | \"SUB\" { \"\\032\" } | \"ESC\" { \"\\e\" } | \"DEL\" { \"\\177\" } | < . > { \"\\\\\" + text })")
3993
+ Rules[:_number_escapes] = rule_info("number_escapes", "(/[xX]/ < /[0-9a-fA-F]{1,5}/ > { [text.to_i(16)].pack(\"U\") } | < /\\d{1,6}/ > { [text.to_i].pack(\"U\") } | /[oO]/ < /[0-7]{1,7}/ > { [text.to_i(16)].pack(\"U\") } | /[uU]/ < /[0-9a-fA-F]{4}/ > { [text.to_i(16)].pack(\"U\") })")
3994
+ Rules[:_root] = rule_info("root", "wsp expressions:es wsp !. { Array(es) }")
3995
+ end