heist 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +17 -0
- data/Manifest.txt +5 -0
- data/README.txt +65 -51
- data/Rakefile +25 -1
- data/lib/builtin/library.scm +244 -9
- data/lib/builtin/primitives.rb +122 -10
- data/lib/builtin/syntax.scm +10 -14
- data/lib/heist.rb +5 -13
- data/lib/parser/nodes.rb +25 -5
- data/lib/parser/scheme.rb +394 -142
- data/lib/parser/scheme.tt +18 -6
- data/lib/repl.rb +19 -13
- data/lib/runtime/binding.rb +1 -0
- data/lib/runtime/callable/continuation.rb +1 -0
- data/lib/runtime/callable/macro.rb +37 -2
- data/lib/runtime/callable/macro/expansion.rb +34 -2
- data/lib/runtime/callable/syntax.rb +1 -0
- data/lib/runtime/data/character.rb +83 -0
- data/lib/runtime/data/cons.rb +17 -19
- data/lib/runtime/data/vector.rb +65 -0
- data/lib/runtime/frame.rb +7 -0
- data/lib/runtime/runtime.rb +2 -1
- data/lib/runtime/scope.rb +5 -9
- data/lib/runtime/stackless.rb +7 -0
- data/lib/trie.rb +141 -0
- data/test/equivalence.scm +7 -0
- data/test/let.scm +13 -0
- data/test/lists.scm +2 -3
- data/test/macros.scm +14 -0
- data/test/strings.scm +110 -0
- data/test/test_heist.rb +2 -0
- data/test/vectors.scm +83 -0
- metadata +10 -7
data/lib/builtin/primitives.rb
CHANGED
@@ -124,21 +124,14 @@ end
|
|
124
124
|
|
125
125
|
# TODO write a more exact implementation, and implement (eq?)
|
126
126
|
define('eqv?') do |op1, op2|
|
127
|
-
(Identifier === op1 and op1 == op2) or
|
127
|
+
([Identifier, Character].any? { |type| type === op1 } and op1 == op2) or
|
128
|
+
op1.equal?(op2)
|
128
129
|
end
|
129
130
|
|
130
131
|
define('equal?') do |op1, op2|
|
131
132
|
op1 == op2
|
132
133
|
end
|
133
134
|
|
134
|
-
# Returns true iff the given number is exact i.e. an integer, a
|
135
|
-
# rational, or a complex made of integers
|
136
|
-
define('exact?') do |value|
|
137
|
-
call('rational?', value) || (Complex === value &&
|
138
|
-
call('rational?', value.real) &&
|
139
|
-
call('rational?', value.imag))
|
140
|
-
end
|
141
|
-
|
142
135
|
# Returns true iff the arguments are monotonically decreasing
|
143
136
|
define('>') do |*args|
|
144
137
|
result = true
|
@@ -187,6 +180,10 @@ define('integer?') do |value|
|
|
187
180
|
Integer === value
|
188
181
|
end
|
189
182
|
|
183
|
+
define('char?') do |value|
|
184
|
+
Character === value
|
185
|
+
end
|
186
|
+
|
190
187
|
define('string?') do |value|
|
191
188
|
String === value
|
192
189
|
end
|
@@ -203,6 +200,10 @@ define('pair?') do |value|
|
|
203
200
|
Cons === value and value.pair?
|
204
201
|
end
|
205
202
|
|
203
|
+
define('vector?') do |value|
|
204
|
+
Vector === value
|
205
|
+
end
|
206
|
+
|
206
207
|
#----------------------------------------------------------------
|
207
208
|
|
208
209
|
# Numerical functions
|
@@ -266,7 +267,7 @@ end
|
|
266
267
|
# Returns a new complex number with the given real and
|
267
268
|
# imaginary parts
|
268
269
|
define('make-rectangular') do |real, imag|
|
269
|
-
Complex
|
270
|
+
Complex(real, imag)
|
270
271
|
end
|
271
272
|
|
272
273
|
# Returns the real part of a number
|
@@ -321,6 +322,117 @@ end
|
|
321
322
|
|
322
323
|
#----------------------------------------------------------------
|
323
324
|
|
325
|
+
# Symbol functions
|
326
|
+
|
327
|
+
# Returns a new string by casting the given symbol to a string
|
328
|
+
define('symbol->string') do |symbol|
|
329
|
+
symbol.to_s
|
330
|
+
end
|
331
|
+
|
332
|
+
# Returns the symbol whose name is the given string
|
333
|
+
define('string->symbol') do |string|
|
334
|
+
Identifier.new(string)
|
335
|
+
end
|
336
|
+
|
337
|
+
#----------------------------------------------------------------
|
338
|
+
|
339
|
+
# Character functions
|
340
|
+
|
341
|
+
# Returns true iff the two characters are equal
|
342
|
+
define('char=?') do |op1, op2|
|
343
|
+
Character === op1 and op1 == op2
|
344
|
+
end
|
345
|
+
|
346
|
+
define('char<?') do |op1, op2|
|
347
|
+
Character === op1 and Character === op2 and op1 < op2
|
348
|
+
end
|
349
|
+
|
350
|
+
define('char>?') do |op1, op2|
|
351
|
+
Character === op1 and Character === op2 and op1 > op2
|
352
|
+
end
|
353
|
+
|
354
|
+
define('char<=?') do |op1, op2|
|
355
|
+
Character === op1 and Character === op2 and op1 <= op2
|
356
|
+
end
|
357
|
+
|
358
|
+
define('char>=?') do |op1, op2|
|
359
|
+
Character === op1 and Character === op2 and op1 >= op2
|
360
|
+
end
|
361
|
+
|
362
|
+
# Returns a new character from an ASCII code
|
363
|
+
define('integer->char') do |code|
|
364
|
+
Character.new(code.chr)
|
365
|
+
end
|
366
|
+
|
367
|
+
# Returns the ASCII code for a character
|
368
|
+
define('char->integer') do |char|
|
369
|
+
char.char_code
|
370
|
+
end
|
371
|
+
|
372
|
+
#----------------------------------------------------------------
|
373
|
+
|
374
|
+
# String functions
|
375
|
+
|
376
|
+
# Returns a new string of the given size, filled with the given
|
377
|
+
# character. If no character is given, a space is used.
|
378
|
+
define('make-string') do |size, char|
|
379
|
+
char = " " if char.nil?
|
380
|
+
char.to_s * size
|
381
|
+
end
|
382
|
+
|
383
|
+
# Returns the length of the string
|
384
|
+
define('string-length') do |string|
|
385
|
+
string.length
|
386
|
+
end
|
387
|
+
|
388
|
+
# Returns the kth character in the string
|
389
|
+
define('string-ref') do |string, k|
|
390
|
+
size = string.length
|
391
|
+
raise BadIndexError.new("Cannot access index #{k} in string \"#{string}\"") if k >= size
|
392
|
+
char = string[k]
|
393
|
+
char = char.chr if Numeric === char
|
394
|
+
Character.new(char)
|
395
|
+
end
|
396
|
+
|
397
|
+
# Sets the kth character in string equal to char
|
398
|
+
define('string-set!') do |string, k, char|
|
399
|
+
raise ImmutableError.new("Cannot modify string constant") if string.frozen?
|
400
|
+
string[k] = char.to_s
|
401
|
+
string
|
402
|
+
end
|
403
|
+
|
404
|
+
#----------------------------------------------------------------
|
405
|
+
|
406
|
+
# Vector functions
|
407
|
+
|
408
|
+
# Returns a new vector of the given size, filled with the given
|
409
|
+
# filler value (this defaults to the NULL list)
|
410
|
+
define('make-vector') do |size, fill|
|
411
|
+
fill = Cons::NULL if fill.nil?
|
412
|
+
Vector.new(size, fill)
|
413
|
+
end
|
414
|
+
|
415
|
+
# Returns the length of the vector
|
416
|
+
define('vector-length') do |vector|
|
417
|
+
vector.size
|
418
|
+
end
|
419
|
+
|
420
|
+
# Returns the kth element of a vector
|
421
|
+
define('vector-ref') do |vector, k|
|
422
|
+
size = vector.size
|
423
|
+
raise BadIndexError.new("Cannot access index #{k} of vector of length #{size}") if k >= size
|
424
|
+
vector[k]
|
425
|
+
end
|
426
|
+
|
427
|
+
# Sets the kth element of a vector to object
|
428
|
+
define('vector-set!') do |vector, k, object|
|
429
|
+
size = vector.size
|
430
|
+
raise BadIndexError.new("Cannot modify index #{k} of vector of length #{size}") if k >= size
|
431
|
+
vector[k] = object
|
432
|
+
end
|
433
|
+
|
434
|
+
#----------------------------------------------------------------
|
435
|
+
|
324
436
|
# Control features
|
325
437
|
|
326
438
|
# Calls a function using a list for the arguments
|
data/lib/builtin/syntax.scm
CHANGED
@@ -61,11 +61,11 @@
|
|
61
61
|
; for several nested (let)s. Variables may refer to those that
|
62
62
|
; preceed them but not vice versa.
|
63
63
|
(define-syntax let* (syntax-rules ()
|
64
|
-
[(let* ([
|
65
|
-
(let ([name expression]) body ...)]
|
66
|
-
[(let* ([n1 e1] [n2 e2] ...) body ...)
|
64
|
+
[(let* ([n1 e1] [n2 e2] [n3 e3] ...) body ...) ; 2 or more bindings
|
67
65
|
(let ([n1 e1])
|
68
|
-
(let* ([n2 e2] ...) body ...))]
|
66
|
+
(let* ([n2 e2] [n3 e3] ...) body ...))]
|
67
|
+
[(let* ([name expression] ...) body ...) ; 0 or 1 binding
|
68
|
+
(let ([name expression] ...) body ...)]))
|
69
69
|
|
70
70
|
; (letrec) evaluates values in the inner scope, so lambdas are
|
71
71
|
; able to refer to other values assigned using the (letrec).
|
@@ -159,14 +159,10 @@
|
|
159
159
|
; it will evaluate it and insert the result into the
|
160
160
|
; surrounding quoted list.
|
161
161
|
(define-syntax quasiquote (syntax-rules (unquote unquote-splicing)
|
162
|
-
[
|
163
|
-
|
164
|
-
[(
|
165
|
-
|
166
|
-
[(
|
167
|
-
|
168
|
-
[(quasiquote (first . rest))
|
169
|
-
(cons (quasiquote first) (quasiquote rest))]
|
170
|
-
[(quasiquote expr)
|
171
|
-
'expr]))
|
162
|
+
[`,expr expr]
|
163
|
+
[`(,@first . rest) (append first `rest)]
|
164
|
+
[`(first . rest) (cons `first `rest)]
|
165
|
+
[`#(,@first rest ...) (list->vector `(,@first rest ...))]
|
166
|
+
[`#(expr ...) (list->vector `(expr ...))]
|
167
|
+
[`expr 'expr]))
|
172
168
|
|
data/lib/heist.rb
CHANGED
@@ -9,7 +9,7 @@ require 'treetop'
|
|
9
9
|
# utility methods that don't belong anywhere else. See the README for an
|
10
10
|
# overview of Heist's features.
|
11
11
|
module Heist
|
12
|
-
VERSION = '0.
|
12
|
+
VERSION = '0.3.0'
|
13
13
|
|
14
14
|
ROOT_PATH = File.expand_path(File.dirname(__FILE__))
|
15
15
|
PARSER_PATH = ROOT_PATH + '/parser/'
|
@@ -21,6 +21,7 @@ module Heist
|
|
21
21
|
require PARSER_PATH + 'scheme'
|
22
22
|
require PARSER_PATH + 'nodes'
|
23
23
|
require RUNTIME_PATH + 'runtime'
|
24
|
+
require ROOT_PATH + '/trie'
|
24
25
|
require ROOT_PATH + '/repl'
|
25
26
|
|
26
27
|
LOAD_PATH = [LIB_PATH]
|
@@ -33,6 +34,7 @@ module Heist
|
|
33
34
|
class MacroError < SyntaxError; end
|
34
35
|
class MacroTemplateMismatch < MacroError; end
|
35
36
|
class TypeError < RuntimeError; end
|
37
|
+
class BadIndexError < TypeError; end
|
36
38
|
class ImmutableError < TypeError; end
|
37
39
|
|
38
40
|
class << self
|
@@ -55,25 +57,15 @@ module Heist
|
|
55
57
|
expression
|
56
58
|
end
|
57
59
|
|
58
|
-
# Returns a new complex number with the given +real+ and +imaginary+ parts.
|
59
|
-
def complex(real, imaginary)
|
60
|
-
Complex.new(real, imaginary)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Returns a new rational number with the given +numerator+ and +denominator+.
|
64
|
-
def rational(numerator, denominator)
|
65
|
-
Rational(numerator, denominator)
|
66
|
-
end
|
67
|
-
|
68
60
|
# Returns the result of dividing the first argument by the second. If both
|
69
61
|
# arguments are integers, returns a rational rather than performing
|
70
62
|
# integer division as Ruby would normally do.
|
71
63
|
def divide(op1, op2)
|
72
64
|
[op1, op2].all? { |value| Integer === value } ?
|
73
|
-
|
65
|
+
Rational(op1, op2) :
|
74
66
|
op1.to_f / op2
|
75
67
|
end
|
68
|
+
|
76
69
|
end
|
77
|
-
|
78
70
|
end
|
79
71
|
|
data/lib/parser/nodes.rb
CHANGED
@@ -31,7 +31,7 @@ module Heist
|
|
31
31
|
# Converts all the +Treetop+ objects in the +Program+ to Heist objects
|
32
32
|
# and raw Ruby data ready for interpretation using a +Runtime+.
|
33
33
|
def convert!
|
34
|
-
return if @data
|
34
|
+
return @data if @data
|
35
35
|
@data = Runtime::Cons.construct(elements[1].elements, true) { |c| c.eval }
|
36
36
|
end
|
37
37
|
end
|
@@ -55,6 +55,17 @@ module Heist
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
# A +Vector+ is an array-like structure if integer-indexed cells
|
59
|
+
module Vector
|
60
|
+
def eval
|
61
|
+
Runtime::Vector.new(cells) { |cell| cell.eval }
|
62
|
+
end
|
63
|
+
|
64
|
+
def cells
|
65
|
+
@cells ||= elements[2].elements
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
58
69
|
# <tt>QuotedCell</tt> are generated using the quoting shorthands.
|
59
70
|
class QuotedCell < Treetop::Runtime::SyntaxNode
|
60
71
|
# Evaluating a +QuotedCell+ produces a +Cons+ that expresses a function
|
@@ -81,7 +92,7 @@ module Heist
|
|
81
92
|
end
|
82
93
|
end
|
83
94
|
|
84
|
-
|
95
|
+
class Boolean < Treetop::Runtime::SyntaxNode
|
85
96
|
def eval
|
86
97
|
@value ||= (text_value == "#t")
|
87
98
|
end
|
@@ -89,7 +100,7 @@ module Heist
|
|
89
100
|
|
90
101
|
class Complex < Treetop::Runtime::SyntaxNode
|
91
102
|
def eval
|
92
|
-
@value ||=
|
103
|
+
@value ||= Complex(real.eval, imaginary.eval)
|
93
104
|
end
|
94
105
|
end
|
95
106
|
|
@@ -101,7 +112,7 @@ module Heist
|
|
101
112
|
|
102
113
|
class Rational < Treetop::Runtime::SyntaxNode
|
103
114
|
def eval
|
104
|
-
@value ||=
|
115
|
+
@value ||= Rational(numerator.eval, denominator.eval)
|
105
116
|
end
|
106
117
|
end
|
107
118
|
|
@@ -111,9 +122,18 @@ module Heist
|
|
111
122
|
end
|
112
123
|
end
|
113
124
|
|
125
|
+
class Character < Treetop::Runtime::SyntaxNode
|
126
|
+
def eval
|
127
|
+
Runtime::Character.new(glyph.text_value)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
114
131
|
class String < Treetop::Runtime::SyntaxNode
|
115
132
|
def eval
|
116
|
-
@value
|
133
|
+
return @value if @value
|
134
|
+
@value = Kernel.eval(text_value)
|
135
|
+
@value.freeze
|
136
|
+
@value
|
117
137
|
end
|
118
138
|
end
|
119
139
|
|
data/lib/parser/scheme.rb
CHANGED
@@ -22,7 +22,7 @@ module Heist
|
|
22
22
|
if r2
|
23
23
|
r1 = r2
|
24
24
|
else
|
25
|
-
r1 = SyntaxNode
|
25
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
26
26
|
end
|
27
27
|
s0 << r1
|
28
28
|
if r1
|
@@ -35,11 +35,11 @@ module Heist
|
|
35
35
|
break
|
36
36
|
end
|
37
37
|
end
|
38
|
-
r3 = SyntaxNode
|
38
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
39
39
|
s0 << r3
|
40
40
|
end
|
41
41
|
if s0.last
|
42
|
-
r0 = (Program
|
42
|
+
r0 = instantiate_node(Program,input, i0...index, s0)
|
43
43
|
r0.extend(Program0)
|
44
44
|
else
|
45
45
|
self.index = i0
|
@@ -75,11 +75,11 @@ module Heist
|
|
75
75
|
break
|
76
76
|
end
|
77
77
|
end
|
78
|
-
r1 = SyntaxNode
|
78
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
79
79
|
s0 << r1
|
80
80
|
if r1
|
81
81
|
if input.index("#!", index) == index
|
82
|
-
r3 = (SyntaxNode
|
82
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
83
83
|
@index += 2
|
84
84
|
else
|
85
85
|
terminal_parse_failure("#!")
|
@@ -92,7 +92,7 @@ module Heist
|
|
92
92
|
i5, s5 = index, []
|
93
93
|
i6 = index
|
94
94
|
if input.index(Regexp.new('[\\n\\r]'), index) == index
|
95
|
-
r7 = (SyntaxNode
|
95
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
96
96
|
@index += 1
|
97
97
|
else
|
98
98
|
r7 = nil
|
@@ -101,12 +101,12 @@ module Heist
|
|
101
101
|
r6 = nil
|
102
102
|
else
|
103
103
|
self.index = i6
|
104
|
-
r6 = SyntaxNode
|
104
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
105
105
|
end
|
106
106
|
s5 << r6
|
107
107
|
if r6
|
108
108
|
if index < input_length
|
109
|
-
r8 = (SyntaxNode
|
109
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
110
110
|
@index += 1
|
111
111
|
else
|
112
112
|
terminal_parse_failure("any character")
|
@@ -115,7 +115,7 @@ module Heist
|
|
115
115
|
s5 << r8
|
116
116
|
end
|
117
117
|
if s5.last
|
118
|
-
r5 = (SyntaxNode
|
118
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
119
119
|
r5.extend(Shebang0)
|
120
120
|
else
|
121
121
|
self.index = i5
|
@@ -127,12 +127,12 @@ module Heist
|
|
127
127
|
break
|
128
128
|
end
|
129
129
|
end
|
130
|
-
r4 = SyntaxNode
|
130
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
131
131
|
s0 << r4
|
132
132
|
end
|
133
133
|
end
|
134
134
|
if s0.last
|
135
|
-
r0 = (SyntaxNode
|
135
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
136
136
|
r0.extend(Shebang1)
|
137
137
|
else
|
138
138
|
self.index = i0
|
@@ -189,7 +189,7 @@ module Heist
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
if s1.last
|
192
|
-
r1 = (QuotedCell
|
192
|
+
r1 = instantiate_node(QuotedCell,input, i1...index, s1)
|
193
193
|
r1.extend(Cell0)
|
194
194
|
else
|
195
195
|
self.index = i1
|
@@ -207,22 +207,27 @@ module Heist
|
|
207
207
|
if r8
|
208
208
|
r7 = r8
|
209
209
|
else
|
210
|
-
r9 =
|
210
|
+
r9 = _nt_vector
|
211
211
|
if r9
|
212
212
|
r7 = r9
|
213
213
|
else
|
214
|
-
|
215
|
-
|
214
|
+
r10 = _nt_atom
|
215
|
+
if r10
|
216
|
+
r7 = r10
|
217
|
+
else
|
218
|
+
self.index = i7
|
219
|
+
r7 = nil
|
220
|
+
end
|
216
221
|
end
|
217
222
|
end
|
218
223
|
s5 << r7
|
219
224
|
if r7
|
220
|
-
|
221
|
-
s5 <<
|
225
|
+
r11 = _nt_ignore
|
226
|
+
s5 << r11
|
222
227
|
end
|
223
228
|
end
|
224
229
|
if s5.last
|
225
|
-
r5 = (Cell
|
230
|
+
r5 = instantiate_node(Cell,input, i5...index, s5)
|
226
231
|
r5.extend(Cell1)
|
227
232
|
else
|
228
233
|
self.index = i5
|
@@ -251,7 +256,7 @@ module Heist
|
|
251
256
|
|
252
257
|
i0 = index
|
253
258
|
if input.index("'", index) == index
|
254
|
-
r1 = (SyntaxNode
|
259
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
255
260
|
@index += 1
|
256
261
|
else
|
257
262
|
terminal_parse_failure("'")
|
@@ -261,7 +266,7 @@ module Heist
|
|
261
266
|
r0 = r1
|
262
267
|
else
|
263
268
|
if input.index("`", index) == index
|
264
|
-
r2 = (SyntaxNode
|
269
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
265
270
|
@index += 1
|
266
271
|
else
|
267
272
|
terminal_parse_failure("`")
|
@@ -271,7 +276,7 @@ module Heist
|
|
271
276
|
r0 = r2
|
272
277
|
else
|
273
278
|
if input.index(",@", index) == index
|
274
|
-
r3 = (SyntaxNode
|
279
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
275
280
|
@index += 2
|
276
281
|
else
|
277
282
|
terminal_parse_failure(",@")
|
@@ -281,7 +286,7 @@ module Heist
|
|
281
286
|
r0 = r3
|
282
287
|
else
|
283
288
|
if input.index(",", index) == index
|
284
|
-
r4 = (SyntaxNode
|
289
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
285
290
|
@index += 1
|
286
291
|
else
|
287
292
|
terminal_parse_failure(",")
|
@@ -311,7 +316,7 @@ module Heist
|
|
311
316
|
end
|
312
317
|
|
313
318
|
if input.index(".", index) == index
|
314
|
-
r0 = (SyntaxNode
|
319
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
315
320
|
@index += 1
|
316
321
|
else
|
317
322
|
terminal_parse_failure(".")
|
@@ -323,6 +328,27 @@ module Heist
|
|
323
328
|
return r0
|
324
329
|
end
|
325
330
|
|
331
|
+
def _nt_hash
|
332
|
+
start_index = index
|
333
|
+
if node_cache[:hash].has_key?(index)
|
334
|
+
cached = node_cache[:hash][index]
|
335
|
+
@index = cached.interval.end if cached
|
336
|
+
return cached
|
337
|
+
end
|
338
|
+
|
339
|
+
if input.index("#", index) == index
|
340
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
341
|
+
@index += 1
|
342
|
+
else
|
343
|
+
terminal_parse_failure("#")
|
344
|
+
r0 = nil
|
345
|
+
end
|
346
|
+
|
347
|
+
node_cache[:hash][start_index] = r0
|
348
|
+
|
349
|
+
return r0
|
350
|
+
end
|
351
|
+
|
326
352
|
module List0 #:nodoc:
|
327
353
|
def cells
|
328
354
|
elements[1]
|
@@ -348,7 +374,7 @@ module Heist
|
|
348
374
|
i0 = index
|
349
375
|
i1, s1 = index, []
|
350
376
|
if input.index("(", index) == index
|
351
|
-
r2 = (SyntaxNode
|
377
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
352
378
|
@index += 1
|
353
379
|
else
|
354
380
|
terminal_parse_failure("(")
|
@@ -360,7 +386,7 @@ module Heist
|
|
360
386
|
s1 << r3
|
361
387
|
if r3
|
362
388
|
if input.index(")", index) == index
|
363
|
-
r4 = (SyntaxNode
|
389
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
364
390
|
@index += 1
|
365
391
|
else
|
366
392
|
terminal_parse_failure(")")
|
@@ -370,7 +396,7 @@ module Heist
|
|
370
396
|
end
|
371
397
|
end
|
372
398
|
if s1.last
|
373
|
-
r1 = (SyntaxNode
|
399
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
374
400
|
r1.extend(List0)
|
375
401
|
else
|
376
402
|
self.index = i1
|
@@ -382,7 +408,7 @@ module Heist
|
|
382
408
|
else
|
383
409
|
i5, s5 = index, []
|
384
410
|
if input.index("[", index) == index
|
385
|
-
r6 = (SyntaxNode
|
411
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
386
412
|
@index += 1
|
387
413
|
else
|
388
414
|
terminal_parse_failure("[")
|
@@ -394,7 +420,7 @@ module Heist
|
|
394
420
|
s5 << r7
|
395
421
|
if r7
|
396
422
|
if input.index("]", index) == index
|
397
|
-
r8 = (SyntaxNode
|
423
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
398
424
|
@index += 1
|
399
425
|
else
|
400
426
|
terminal_parse_failure("]")
|
@@ -404,7 +430,7 @@ module Heist
|
|
404
430
|
end
|
405
431
|
end
|
406
432
|
if s5.last
|
407
|
-
r5 = (SyntaxNode
|
433
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
408
434
|
r5.extend(List1)
|
409
435
|
else
|
410
436
|
self.index = i5
|
@@ -470,7 +496,7 @@ module Heist
|
|
470
496
|
self.index = i2
|
471
497
|
r2 = nil
|
472
498
|
else
|
473
|
-
r2 = SyntaxNode
|
499
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
474
500
|
end
|
475
501
|
s1 << r2
|
476
502
|
if r2
|
@@ -486,7 +512,7 @@ module Heist
|
|
486
512
|
end
|
487
513
|
end
|
488
514
|
if s4.last
|
489
|
-
r4 = (SyntaxNode
|
515
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
490
516
|
r4.extend(Cells0)
|
491
517
|
else
|
492
518
|
self.index = i4
|
@@ -495,7 +521,7 @@ module Heist
|
|
495
521
|
s1 << r4
|
496
522
|
end
|
497
523
|
if s1.last
|
498
|
-
r1 = (SyntaxNode
|
524
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
499
525
|
r1.extend(Cells1)
|
500
526
|
else
|
501
527
|
self.index = i1
|
@@ -514,14 +540,14 @@ module Heist
|
|
514
540
|
break
|
515
541
|
end
|
516
542
|
end
|
517
|
-
r9 = SyntaxNode
|
543
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
518
544
|
s8 << r9
|
519
545
|
if r9
|
520
546
|
r11 = _nt_ignore
|
521
547
|
s8 << r11
|
522
548
|
end
|
523
549
|
if s8.last
|
524
|
-
r8 = (SyntaxNode
|
550
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
525
551
|
r8.extend(Cells2)
|
526
552
|
else
|
527
553
|
self.index = i8
|
@@ -540,6 +566,149 @@ module Heist
|
|
540
566
|
return r0
|
541
567
|
end
|
542
568
|
|
569
|
+
module Vector0 #:nodoc:
|
570
|
+
def hash
|
571
|
+
elements[0]
|
572
|
+
end
|
573
|
+
|
574
|
+
def ignore
|
575
|
+
elements[3]
|
576
|
+
end
|
577
|
+
|
578
|
+
end
|
579
|
+
|
580
|
+
module Vector1 #:nodoc:
|
581
|
+
def hash
|
582
|
+
elements[0]
|
583
|
+
end
|
584
|
+
|
585
|
+
def ignore
|
586
|
+
elements[3]
|
587
|
+
end
|
588
|
+
|
589
|
+
end
|
590
|
+
|
591
|
+
def _nt_vector
|
592
|
+
start_index = index
|
593
|
+
if node_cache[:vector].has_key?(index)
|
594
|
+
cached = node_cache[:vector][index]
|
595
|
+
@index = cached.interval.end if cached
|
596
|
+
return cached
|
597
|
+
end
|
598
|
+
|
599
|
+
i0 = index
|
600
|
+
i1, s1 = index, []
|
601
|
+
r2 = _nt_hash
|
602
|
+
s1 << r2
|
603
|
+
if r2
|
604
|
+
if input.index("(", index) == index
|
605
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
606
|
+
@index += 1
|
607
|
+
else
|
608
|
+
terminal_parse_failure("(")
|
609
|
+
r3 = nil
|
610
|
+
end
|
611
|
+
s1 << r3
|
612
|
+
if r3
|
613
|
+
s4, i4 = [], index
|
614
|
+
loop do
|
615
|
+
r5 = _nt_cell
|
616
|
+
if r5
|
617
|
+
s4 << r5
|
618
|
+
else
|
619
|
+
break
|
620
|
+
end
|
621
|
+
end
|
622
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
623
|
+
s1 << r4
|
624
|
+
if r4
|
625
|
+
r6 = _nt_ignore
|
626
|
+
s1 << r6
|
627
|
+
if r6
|
628
|
+
if input.index(")", index) == index
|
629
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
630
|
+
@index += 1
|
631
|
+
else
|
632
|
+
terminal_parse_failure(")")
|
633
|
+
r7 = nil
|
634
|
+
end
|
635
|
+
s1 << r7
|
636
|
+
end
|
637
|
+
end
|
638
|
+
end
|
639
|
+
end
|
640
|
+
if s1.last
|
641
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
642
|
+
r1.extend(Vector0)
|
643
|
+
else
|
644
|
+
self.index = i1
|
645
|
+
r1 = nil
|
646
|
+
end
|
647
|
+
if r1
|
648
|
+
r0 = r1
|
649
|
+
r0.extend(Vector)
|
650
|
+
else
|
651
|
+
i8, s8 = index, []
|
652
|
+
r9 = _nt_hash
|
653
|
+
s8 << r9
|
654
|
+
if r9
|
655
|
+
if input.index("[", index) == index
|
656
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
657
|
+
@index += 1
|
658
|
+
else
|
659
|
+
terminal_parse_failure("[")
|
660
|
+
r10 = nil
|
661
|
+
end
|
662
|
+
s8 << r10
|
663
|
+
if r10
|
664
|
+
s11, i11 = [], index
|
665
|
+
loop do
|
666
|
+
r12 = _nt_cell
|
667
|
+
if r12
|
668
|
+
s11 << r12
|
669
|
+
else
|
670
|
+
break
|
671
|
+
end
|
672
|
+
end
|
673
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
674
|
+
s8 << r11
|
675
|
+
if r11
|
676
|
+
r13 = _nt_ignore
|
677
|
+
s8 << r13
|
678
|
+
if r13
|
679
|
+
if input.index("]", index) == index
|
680
|
+
r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
681
|
+
@index += 1
|
682
|
+
else
|
683
|
+
terminal_parse_failure("]")
|
684
|
+
r14 = nil
|
685
|
+
end
|
686
|
+
s8 << r14
|
687
|
+
end
|
688
|
+
end
|
689
|
+
end
|
690
|
+
end
|
691
|
+
if s8.last
|
692
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
693
|
+
r8.extend(Vector1)
|
694
|
+
else
|
695
|
+
self.index = i8
|
696
|
+
r8 = nil
|
697
|
+
end
|
698
|
+
if r8
|
699
|
+
r0 = r8
|
700
|
+
r0.extend(Vector)
|
701
|
+
else
|
702
|
+
self.index = i0
|
703
|
+
r0 = nil
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
node_cache[:vector][start_index] = r0
|
708
|
+
|
709
|
+
return r0
|
710
|
+
end
|
711
|
+
|
543
712
|
def _nt_atom
|
544
713
|
start_index = index
|
545
714
|
if node_cache[:atom].has_key?(index)
|
@@ -591,55 +760,60 @@ module Heist
|
|
591
760
|
if r3
|
592
761
|
r1 = r3
|
593
762
|
else
|
594
|
-
r4 =
|
763
|
+
r4 = _nt_character
|
595
764
|
if r4
|
596
765
|
r1 = r4
|
597
766
|
else
|
598
|
-
|
599
|
-
|
767
|
+
r5 = _nt_string
|
768
|
+
if r5
|
769
|
+
r1 = r5
|
770
|
+
else
|
771
|
+
self.index = i1
|
772
|
+
r1 = nil
|
773
|
+
end
|
600
774
|
end
|
601
775
|
end
|
602
776
|
end
|
603
777
|
s0 << r1
|
604
778
|
if r1
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
if
|
610
|
-
|
779
|
+
i6 = index
|
780
|
+
i7, s7 = index, []
|
781
|
+
i8 = index
|
782
|
+
r9 = _nt_delimiter
|
783
|
+
if r9
|
784
|
+
r8 = nil
|
611
785
|
else
|
612
|
-
self.index =
|
613
|
-
|
786
|
+
self.index = i8
|
787
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
614
788
|
end
|
615
|
-
|
616
|
-
if
|
789
|
+
s7 << r8
|
790
|
+
if r8
|
617
791
|
if index < input_length
|
618
|
-
|
792
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
619
793
|
@index += 1
|
620
794
|
else
|
621
795
|
terminal_parse_failure("any character")
|
622
|
-
|
796
|
+
r10 = nil
|
623
797
|
end
|
624
|
-
|
798
|
+
s7 << r10
|
625
799
|
end
|
626
|
-
if
|
627
|
-
|
628
|
-
|
800
|
+
if s7.last
|
801
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
802
|
+
r7.extend(Datum0)
|
629
803
|
else
|
630
|
-
self.index =
|
631
|
-
|
804
|
+
self.index = i7
|
805
|
+
r7 = nil
|
632
806
|
end
|
633
|
-
if
|
634
|
-
|
807
|
+
if r7
|
808
|
+
r6 = nil
|
635
809
|
else
|
636
|
-
self.index =
|
637
|
-
|
810
|
+
self.index = i6
|
811
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
638
812
|
end
|
639
|
-
s0 <<
|
813
|
+
s0 << r6
|
640
814
|
end
|
641
815
|
if s0.last
|
642
|
-
r0 = (Datum
|
816
|
+
r0 = instantiate_node(Datum,input, i0...index, s0)
|
643
817
|
r0.extend(Datum1)
|
644
818
|
else
|
645
819
|
self.index = i0
|
@@ -651,6 +825,13 @@ module Heist
|
|
651
825
|
return r0
|
652
826
|
end
|
653
827
|
|
828
|
+
module Boolean0 #:nodoc:
|
829
|
+
def hash
|
830
|
+
elements[0]
|
831
|
+
end
|
832
|
+
|
833
|
+
end
|
834
|
+
|
654
835
|
def _nt_boolean
|
655
836
|
start_index = index
|
656
837
|
if node_cache[:boolean].has_key?(index)
|
@@ -659,32 +840,24 @@ module Heist
|
|
659
840
|
return cached
|
660
841
|
end
|
661
842
|
|
662
|
-
i0 = index
|
663
|
-
|
664
|
-
|
665
|
-
@index += 2
|
666
|
-
else
|
667
|
-
terminal_parse_failure("#t")
|
668
|
-
r1 = nil
|
669
|
-
end
|
843
|
+
i0, s0 = index, []
|
844
|
+
r1 = _nt_hash
|
845
|
+
s0 << r1
|
670
846
|
if r1
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
if input.index("#f", index) == index
|
675
|
-
r2 = (SyntaxNode).new(input, index...(index + 2))
|
676
|
-
@index += 2
|
847
|
+
if input.index(Regexp.new('[tf]'), index) == index
|
848
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
849
|
+
@index += 1
|
677
850
|
else
|
678
|
-
terminal_parse_failure("#f")
|
679
851
|
r2 = nil
|
680
852
|
end
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
853
|
+
s0 << r2
|
854
|
+
end
|
855
|
+
if s0.last
|
856
|
+
r0 = instantiate_node(Boolean,input, i0...index, s0)
|
857
|
+
r0.extend(Boolean0)
|
858
|
+
else
|
859
|
+
self.index = i0
|
860
|
+
r0 = nil
|
688
861
|
end
|
689
862
|
|
690
863
|
node_cache[:boolean][start_index] = r0
|
@@ -765,7 +938,7 @@ module Heist
|
|
765
938
|
s0 << r1
|
766
939
|
if r1
|
767
940
|
if input.index("+", index) == index
|
768
|
-
r4 = (SyntaxNode
|
941
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
769
942
|
@index += 1
|
770
943
|
else
|
771
944
|
terminal_parse_failure("+")
|
@@ -789,7 +962,7 @@ module Heist
|
|
789
962
|
s0 << r5
|
790
963
|
if r5
|
791
964
|
if input.index("i", index) == index
|
792
|
-
r8 = (SyntaxNode
|
965
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
793
966
|
@index += 1
|
794
967
|
else
|
795
968
|
terminal_parse_failure("i")
|
@@ -800,7 +973,7 @@ module Heist
|
|
800
973
|
end
|
801
974
|
end
|
802
975
|
if s0.last
|
803
|
-
r0 = (Complex
|
976
|
+
r0 = instantiate_node(Complex,input, i0...index, s0)
|
804
977
|
r0.extend(Complex0)
|
805
978
|
else
|
806
979
|
self.index = i0
|
@@ -836,7 +1009,7 @@ module Heist
|
|
836
1009
|
if r1
|
837
1010
|
i2, s2 = index, []
|
838
1011
|
if input.index(".", index) == index
|
839
|
-
r3 = (SyntaxNode
|
1012
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
840
1013
|
@index += 1
|
841
1014
|
else
|
842
1015
|
terminal_parse_failure(".")
|
@@ -857,12 +1030,12 @@ module Heist
|
|
857
1030
|
self.index = i4
|
858
1031
|
r4 = nil
|
859
1032
|
else
|
860
|
-
r4 = SyntaxNode
|
1033
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
861
1034
|
end
|
862
1035
|
s2 << r4
|
863
1036
|
end
|
864
1037
|
if s2.last
|
865
|
-
r2 = (SyntaxNode
|
1038
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
866
1039
|
r2.extend(Real0)
|
867
1040
|
else
|
868
1041
|
self.index = i2
|
@@ -871,7 +1044,7 @@ module Heist
|
|
871
1044
|
s0 << r2
|
872
1045
|
end
|
873
1046
|
if s0.last
|
874
|
-
r0 = (Real
|
1047
|
+
r0 = instantiate_node(Real,input, i0...index, s0)
|
875
1048
|
r0.extend(Real1)
|
876
1049
|
else
|
877
1050
|
self.index = i0
|
@@ -906,7 +1079,7 @@ module Heist
|
|
906
1079
|
s0 << r1
|
907
1080
|
if r1
|
908
1081
|
if input.index("/", index) == index
|
909
|
-
r2 = (SyntaxNode
|
1082
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
910
1083
|
@index += 1
|
911
1084
|
else
|
912
1085
|
terminal_parse_failure("/")
|
@@ -919,7 +1092,7 @@ module Heist
|
|
919
1092
|
end
|
920
1093
|
end
|
921
1094
|
if s0.last
|
922
|
-
r0 = (Rational
|
1095
|
+
r0 = instantiate_node(Rational,input, i0...index, s0)
|
923
1096
|
r0.extend(Rational0)
|
924
1097
|
else
|
925
1098
|
self.index = i0
|
@@ -947,7 +1120,7 @@ module Heist
|
|
947
1120
|
|
948
1121
|
i0, s0 = index, []
|
949
1122
|
if input.index("-", index) == index
|
950
|
-
r2 = (SyntaxNode
|
1123
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
951
1124
|
@index += 1
|
952
1125
|
else
|
953
1126
|
terminal_parse_failure("-")
|
@@ -956,13 +1129,13 @@ module Heist
|
|
956
1129
|
if r2
|
957
1130
|
r1 = r2
|
958
1131
|
else
|
959
|
-
r1 = SyntaxNode
|
1132
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
960
1133
|
end
|
961
1134
|
s0 << r1
|
962
1135
|
if r1
|
963
1136
|
i3 = index
|
964
1137
|
if input.index("0", index) == index
|
965
|
-
r4 = (SyntaxNode
|
1138
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
966
1139
|
@index += 1
|
967
1140
|
else
|
968
1141
|
terminal_parse_failure("0")
|
@@ -973,7 +1146,7 @@ module Heist
|
|
973
1146
|
else
|
974
1147
|
i5, s5 = index, []
|
975
1148
|
if input.index(Regexp.new('[1-9]'), index) == index
|
976
|
-
r6 = (SyntaxNode
|
1149
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
977
1150
|
@index += 1
|
978
1151
|
else
|
979
1152
|
r6 = nil
|
@@ -989,11 +1162,11 @@ module Heist
|
|
989
1162
|
break
|
990
1163
|
end
|
991
1164
|
end
|
992
|
-
r7 = SyntaxNode
|
1165
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
993
1166
|
s5 << r7
|
994
1167
|
end
|
995
1168
|
if s5.last
|
996
|
-
r5 = (SyntaxNode
|
1169
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
997
1170
|
r5.extend(Integer0)
|
998
1171
|
else
|
999
1172
|
self.index = i5
|
@@ -1009,7 +1182,7 @@ module Heist
|
|
1009
1182
|
s0 << r3
|
1010
1183
|
end
|
1011
1184
|
if s0.last
|
1012
|
-
r0 = (Integer
|
1185
|
+
r0 = instantiate_node(Integer,input, i0...index, s0)
|
1013
1186
|
r0.extend(Integer1)
|
1014
1187
|
else
|
1015
1188
|
self.index = i0
|
@@ -1021,6 +1194,64 @@ module Heist
|
|
1021
1194
|
return r0
|
1022
1195
|
end
|
1023
1196
|
|
1197
|
+
module Character0 #:nodoc:
|
1198
|
+
def glyph
|
1199
|
+
elements[1]
|
1200
|
+
end
|
1201
|
+
end
|
1202
|
+
|
1203
|
+
def _nt_character
|
1204
|
+
start_index = index
|
1205
|
+
if node_cache[:character].has_key?(index)
|
1206
|
+
cached = node_cache[:character][index]
|
1207
|
+
@index = cached.interval.end if cached
|
1208
|
+
return cached
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
i0, s0 = index, []
|
1212
|
+
if input.index("#\\", index) == index
|
1213
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1214
|
+
@index += 2
|
1215
|
+
else
|
1216
|
+
terminal_parse_failure("#\\")
|
1217
|
+
r1 = nil
|
1218
|
+
end
|
1219
|
+
s0 << r1
|
1220
|
+
if r1
|
1221
|
+
i2 = index
|
1222
|
+
r3 = _nt_identifier
|
1223
|
+
if r3
|
1224
|
+
r2 = r3
|
1225
|
+
else
|
1226
|
+
if index < input_length
|
1227
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1228
|
+
@index += 1
|
1229
|
+
else
|
1230
|
+
terminal_parse_failure("any character")
|
1231
|
+
r4 = nil
|
1232
|
+
end
|
1233
|
+
if r4
|
1234
|
+
r2 = r4
|
1235
|
+
else
|
1236
|
+
self.index = i2
|
1237
|
+
r2 = nil
|
1238
|
+
end
|
1239
|
+
end
|
1240
|
+
s0 << r2
|
1241
|
+
end
|
1242
|
+
if s0.last
|
1243
|
+
r0 = instantiate_node(Character,input, i0...index, s0)
|
1244
|
+
r0.extend(Character0)
|
1245
|
+
else
|
1246
|
+
self.index = i0
|
1247
|
+
r0 = nil
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
node_cache[:character][start_index] = r0
|
1251
|
+
|
1252
|
+
return r0
|
1253
|
+
end
|
1254
|
+
|
1024
1255
|
module String0 #:nodoc:
|
1025
1256
|
end
|
1026
1257
|
|
@@ -1034,7 +1265,7 @@ module Heist
|
|
1034
1265
|
|
1035
1266
|
i0, s0 = index, []
|
1036
1267
|
if input.index('"', index) == index
|
1037
|
-
r1 = (SyntaxNode
|
1268
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1038
1269
|
@index += 1
|
1039
1270
|
else
|
1040
1271
|
terminal_parse_failure('"')
|
@@ -1046,7 +1277,7 @@ module Heist
|
|
1046
1277
|
loop do
|
1047
1278
|
i3 = index
|
1048
1279
|
if input.index('\\"', index) == index
|
1049
|
-
r4 = (SyntaxNode
|
1280
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1050
1281
|
@index += 2
|
1051
1282
|
else
|
1052
1283
|
terminal_parse_failure('\\"')
|
@@ -1056,7 +1287,7 @@ module Heist
|
|
1056
1287
|
r3 = r4
|
1057
1288
|
else
|
1058
1289
|
if input.index(Regexp.new('[^"]'), index) == index
|
1059
|
-
r5 = (SyntaxNode
|
1290
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1060
1291
|
@index += 1
|
1061
1292
|
else
|
1062
1293
|
r5 = nil
|
@@ -1074,11 +1305,11 @@ module Heist
|
|
1074
1305
|
break
|
1075
1306
|
end
|
1076
1307
|
end
|
1077
|
-
r2 = SyntaxNode
|
1308
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1078
1309
|
s0 << r2
|
1079
1310
|
if r2
|
1080
1311
|
if input.index('"', index) == index
|
1081
|
-
r6 = (SyntaxNode
|
1312
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1082
1313
|
@index += 1
|
1083
1314
|
else
|
1084
1315
|
terminal_parse_failure('"')
|
@@ -1088,7 +1319,7 @@ module Heist
|
|
1088
1319
|
end
|
1089
1320
|
end
|
1090
1321
|
if s0.last
|
1091
|
-
r0 = (String
|
1322
|
+
r0 = instantiate_node(String,input, i0...index, s0)
|
1092
1323
|
r0.extend(String0)
|
1093
1324
|
else
|
1094
1325
|
self.index = i0
|
@@ -1129,12 +1360,12 @@ module Heist
|
|
1129
1360
|
r3 = nil
|
1130
1361
|
else
|
1131
1362
|
self.index = i3
|
1132
|
-
r3 = SyntaxNode
|
1363
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1133
1364
|
end
|
1134
1365
|
s2 << r3
|
1135
1366
|
if r3
|
1136
1367
|
if index < input_length
|
1137
|
-
r5 = (SyntaxNode
|
1368
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1138
1369
|
@index += 1
|
1139
1370
|
else
|
1140
1371
|
terminal_parse_failure("any character")
|
@@ -1143,7 +1374,7 @@ module Heist
|
|
1143
1374
|
s2 << r5
|
1144
1375
|
end
|
1145
1376
|
if s2.last
|
1146
|
-
r2 = (SyntaxNode
|
1377
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1147
1378
|
r2.extend(Identifier0)
|
1148
1379
|
else
|
1149
1380
|
self.index = i2
|
@@ -1160,12 +1391,12 @@ module Heist
|
|
1160
1391
|
r8 = nil
|
1161
1392
|
else
|
1162
1393
|
self.index = i8
|
1163
|
-
r8 = SyntaxNode
|
1394
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
1164
1395
|
end
|
1165
1396
|
s7 << r8
|
1166
1397
|
if r8
|
1167
1398
|
if index < input_length
|
1168
|
-
r10 = (SyntaxNode
|
1399
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1169
1400
|
@index += 1
|
1170
1401
|
else
|
1171
1402
|
terminal_parse_failure("any character")
|
@@ -1174,7 +1405,7 @@ module Heist
|
|
1174
1405
|
s7 << r10
|
1175
1406
|
end
|
1176
1407
|
if s7.last
|
1177
|
-
r7 = (SyntaxNode
|
1408
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1178
1409
|
r7.extend(Identifier1)
|
1179
1410
|
else
|
1180
1411
|
self.index = i7
|
@@ -1190,12 +1421,12 @@ module Heist
|
|
1190
1421
|
self.index = i6
|
1191
1422
|
r6 = nil
|
1192
1423
|
else
|
1193
|
-
r6 = SyntaxNode
|
1424
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1194
1425
|
end
|
1195
1426
|
s1 << r6
|
1196
1427
|
end
|
1197
1428
|
if s1.last
|
1198
|
-
r1 = (SyntaxNode
|
1429
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1199
1430
|
r1.extend(Identifier2)
|
1200
1431
|
else
|
1201
1432
|
self.index = i1
|
@@ -1212,12 +1443,12 @@ module Heist
|
|
1212
1443
|
r12 = nil
|
1213
1444
|
else
|
1214
1445
|
self.index = i12
|
1215
|
-
r12 = SyntaxNode
|
1446
|
+
r12 = instantiate_node(SyntaxNode,input, index...index)
|
1216
1447
|
end
|
1217
1448
|
s11 << r12
|
1218
1449
|
if r12
|
1219
1450
|
if index < input_length
|
1220
|
-
r14 = (SyntaxNode
|
1451
|
+
r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1221
1452
|
@index += 1
|
1222
1453
|
else
|
1223
1454
|
terminal_parse_failure("any character")
|
@@ -1226,7 +1457,7 @@ module Heist
|
|
1226
1457
|
s11 << r14
|
1227
1458
|
end
|
1228
1459
|
if s11.last
|
1229
|
-
r11 = (SyntaxNode
|
1460
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
1230
1461
|
r11.extend(Identifier3)
|
1231
1462
|
else
|
1232
1463
|
self.index = i11
|
@@ -1255,7 +1486,7 @@ module Heist
|
|
1255
1486
|
end
|
1256
1487
|
|
1257
1488
|
if input.index(Regexp.new('[0-9]'), index) == index
|
1258
|
-
r0 = (SyntaxNode
|
1489
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1259
1490
|
@index += 1
|
1260
1491
|
else
|
1261
1492
|
r0 = nil
|
@@ -1306,16 +1537,21 @@ module Heist
|
|
1306
1537
|
if r1
|
1307
1538
|
r0 = r1
|
1308
1539
|
else
|
1309
|
-
r2 =
|
1540
|
+
r2 = _nt_hash
|
1310
1541
|
if r2
|
1311
1542
|
r0 = r2
|
1312
1543
|
else
|
1313
|
-
r3 =
|
1544
|
+
r3 = _nt_paren
|
1314
1545
|
if r3
|
1315
1546
|
r0 = r3
|
1316
1547
|
else
|
1317
|
-
|
1318
|
-
|
1548
|
+
r4 = _nt_space
|
1549
|
+
if r4
|
1550
|
+
r0 = r4
|
1551
|
+
else
|
1552
|
+
self.index = i0
|
1553
|
+
r0 = nil
|
1554
|
+
end
|
1319
1555
|
end
|
1320
1556
|
end
|
1321
1557
|
end
|
@@ -1334,7 +1570,7 @@ module Heist
|
|
1334
1570
|
end
|
1335
1571
|
|
1336
1572
|
if input.index(Regexp.new('[\\(\\)\\[\\]]'), index) == index
|
1337
|
-
r0 = (SyntaxNode
|
1573
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1338
1574
|
@index += 1
|
1339
1575
|
else
|
1340
1576
|
r0 = nil
|
@@ -1354,7 +1590,7 @@ module Heist
|
|
1354
1590
|
end
|
1355
1591
|
|
1356
1592
|
if input.index(Regexp.new('[\\s\\n\\r\\t]'), index) == index
|
1357
|
-
r0 = (SyntaxNode
|
1593
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1358
1594
|
@index += 1
|
1359
1595
|
else
|
1360
1596
|
r0 = nil
|
@@ -1366,6 +1602,16 @@ module Heist
|
|
1366
1602
|
end
|
1367
1603
|
|
1368
1604
|
module Ignore0 #:nodoc:
|
1605
|
+
def comment
|
1606
|
+
elements[0]
|
1607
|
+
end
|
1608
|
+
|
1609
|
+
def ignore
|
1610
|
+
elements[1]
|
1611
|
+
end
|
1612
|
+
end
|
1613
|
+
|
1614
|
+
module Ignore1 #:nodoc:
|
1369
1615
|
end
|
1370
1616
|
|
1371
1617
|
def _nt_ignore
|
@@ -1386,20 +1632,33 @@ module Heist
|
|
1386
1632
|
break
|
1387
1633
|
end
|
1388
1634
|
end
|
1389
|
-
r1 = SyntaxNode
|
1635
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1390
1636
|
s0 << r1
|
1391
1637
|
if r1
|
1392
|
-
|
1638
|
+
i4, s4 = index, []
|
1639
|
+
r5 = _nt_comment
|
1640
|
+
s4 << r5
|
1641
|
+
if r5
|
1642
|
+
r6 = _nt_ignore
|
1643
|
+
s4 << r6
|
1644
|
+
end
|
1645
|
+
if s4.last
|
1646
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1647
|
+
r4.extend(Ignore0)
|
1648
|
+
else
|
1649
|
+
self.index = i4
|
1650
|
+
r4 = nil
|
1651
|
+
end
|
1393
1652
|
if r4
|
1394
1653
|
r3 = r4
|
1395
1654
|
else
|
1396
|
-
r3 = SyntaxNode
|
1655
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1397
1656
|
end
|
1398
1657
|
s0 << r3
|
1399
1658
|
end
|
1400
1659
|
if s0.last
|
1401
|
-
r0 = (SyntaxNode
|
1402
|
-
r0.extend(
|
1660
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1661
|
+
r0.extend(Ignore1)
|
1403
1662
|
else
|
1404
1663
|
self.index = i0
|
1405
1664
|
r0 = nil
|
@@ -1414,9 +1673,6 @@ module Heist
|
|
1414
1673
|
end
|
1415
1674
|
|
1416
1675
|
module Comment1 #:nodoc:
|
1417
|
-
def ignore
|
1418
|
-
elements[2]
|
1419
|
-
end
|
1420
1676
|
end
|
1421
1677
|
|
1422
1678
|
def _nt_comment
|
@@ -1429,7 +1685,7 @@ module Heist
|
|
1429
1685
|
|
1430
1686
|
i0, s0 = index, []
|
1431
1687
|
if input.index(";", index) == index
|
1432
|
-
r1 = (SyntaxNode
|
1688
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1433
1689
|
@index += 1
|
1434
1690
|
else
|
1435
1691
|
terminal_parse_failure(";")
|
@@ -1442,7 +1698,7 @@ module Heist
|
|
1442
1698
|
i3, s3 = index, []
|
1443
1699
|
i4 = index
|
1444
1700
|
if input.index(Regexp.new('[\\n\\r]'), index) == index
|
1445
|
-
r5 = (SyntaxNode
|
1701
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1446
1702
|
@index += 1
|
1447
1703
|
else
|
1448
1704
|
r5 = nil
|
@@ -1451,12 +1707,12 @@ module Heist
|
|
1451
1707
|
r4 = nil
|
1452
1708
|
else
|
1453
1709
|
self.index = i4
|
1454
|
-
r4 = SyntaxNode
|
1710
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1455
1711
|
end
|
1456
1712
|
s3 << r4
|
1457
1713
|
if r4
|
1458
1714
|
if index < input_length
|
1459
|
-
r6 = (SyntaxNode
|
1715
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1460
1716
|
@index += 1
|
1461
1717
|
else
|
1462
1718
|
terminal_parse_failure("any character")
|
@@ -1465,7 +1721,7 @@ module Heist
|
|
1465
1721
|
s3 << r6
|
1466
1722
|
end
|
1467
1723
|
if s3.last
|
1468
|
-
r3 = (SyntaxNode
|
1724
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1469
1725
|
r3.extend(Comment0)
|
1470
1726
|
else
|
1471
1727
|
self.index = i3
|
@@ -1477,15 +1733,11 @@ module Heist
|
|
1477
1733
|
break
|
1478
1734
|
end
|
1479
1735
|
end
|
1480
|
-
r2 = SyntaxNode
|
1736
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1481
1737
|
s0 << r2
|
1482
|
-
if r2
|
1483
|
-
r7 = _nt_ignore
|
1484
|
-
s0 << r7
|
1485
|
-
end
|
1486
1738
|
end
|
1487
1739
|
if s0.last
|
1488
|
-
r0 = (SyntaxNode
|
1740
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1489
1741
|
r0.extend(Comment1)
|
1490
1742
|
else
|
1491
1743
|
self.index = i0
|