delorean_lang 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +4 -4
- data/Makefile +2 -0
- data/README.md +34 -0
- data/lib/delorean/base.rb +13 -5
- data/lib/delorean/delorean.rb +545 -35
- data/lib/delorean/delorean.treetop +24 -1
- data/lib/delorean/engine.rb +21 -1
- data/lib/delorean/nodes.rb +150 -0
- data/lib/delorean/ruby/whitelists/default.rb +166 -128
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +390 -0
- data/spec/parse_spec.rb +83 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9255b38f00277f412eb2a42699d03646470199d261d6cc66298e9e55aa8bd7c0
|
4
|
+
data.tar.gz: 3ae838764cd7a0f7355d1586b60112b1e073feb367d4b513a239a495b63940ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d05eb327cd542977ff5eb795cb57326bd2daed68b6d599e62365adf6a0d828df2bcc7514095605a9318ce281d7dcf6bfb636b1dbdae6055708b2cb4c32835ff
|
7
|
+
data.tar.gz: b315ab0405e667e6484b2a109b435f0a53a403fec92baa41d483be8b1978477002a82930d8457c1819c076f37f009494c80c313867cabed1af2f3e307c10f65a
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -37,7 +37,7 @@ Lint/Void:
|
|
37
37
|
|
38
38
|
# Offense count: 19
|
39
39
|
Metrics/AbcSize:
|
40
|
-
Max:
|
40
|
+
Max: 250
|
41
41
|
|
42
42
|
# Offense count: 2
|
43
43
|
# Configuration parameters: CountComments.
|
@@ -46,16 +46,16 @@ Metrics/ClassLength:
|
|
46
46
|
|
47
47
|
# Offense count: 6
|
48
48
|
Metrics/CyclomaticComplexity:
|
49
|
-
Max:
|
49
|
+
Max: 15
|
50
50
|
|
51
51
|
# Offense count: 16
|
52
52
|
# Configuration parameters: CountComments, ExcludedMethods.
|
53
53
|
Metrics/MethodLength:
|
54
|
-
Max:
|
54
|
+
Max: 300
|
55
55
|
|
56
56
|
# Offense count: 4
|
57
57
|
Metrics/PerceivedComplexity:
|
58
|
-
Max:
|
58
|
+
Max: 15
|
59
59
|
|
60
60
|
# Offense count: 1
|
61
61
|
Naming/AccessorMethodName:
|
data/Makefile
ADDED
data/README.md
CHANGED
@@ -163,6 +163,10 @@ There are two ways of calling ruby code from delorean. First one is to whitelist
|
|
163
163
|
|
164
164
|
```ruby
|
165
165
|
|
166
|
+
::Delorean::Ruby.whitelist.add__method :any? do |method|
|
167
|
+
method.called_on Enumerable
|
168
|
+
end
|
169
|
+
|
166
170
|
::Delorean::Ruby.whitelist.add_method :length do |method|
|
167
171
|
method.called_on String
|
168
172
|
method.called_on Enumerable
|
@@ -221,6 +225,24 @@ ExampleScript:
|
|
221
225
|
b = DummyModule.heres_my_number(867, 5309)'
|
222
226
|
```
|
223
227
|
|
228
|
+
You can use blocks in your Delorean code:
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
ExampleScript:
|
232
|
+
a = [1, 2, 3]
|
233
|
+
b = c.any? { |v| v > 2 }
|
234
|
+
b2 = c.any? do |v| v > 2 end
|
235
|
+
|
236
|
+
c = a.reduce(0) { |sum, el|
|
237
|
+
sum + el
|
238
|
+
}
|
239
|
+
c2 = a.reduce() do |sum, el|
|
240
|
+
sum + el
|
241
|
+
end
|
242
|
+
```
|
243
|
+
|
244
|
+
Note that `do ... end` syntax is not yet supported
|
245
|
+
|
224
246
|
### Caching
|
225
247
|
|
226
248
|
Delorean provides `cache` flag for `delorean_fn` method that will cache result based on arguments.
|
@@ -268,6 +290,18 @@ Delorean expects it to have methods with following signatures:
|
|
268
290
|
|
269
291
|
TODO: provide details
|
270
292
|
|
293
|
+
## Development
|
294
|
+
|
295
|
+
### Treetop
|
296
|
+
|
297
|
+
Edit treetop rules in `lib/delorean/delorean.treetop`
|
298
|
+
|
299
|
+
Use `make treetop-generate` to regenerate `lib/delorean/delorean.rb` based on Treetop logic in `lib/delorean/delorean.treetop`
|
300
|
+
|
301
|
+
### Testing
|
302
|
+
|
303
|
+
Use `rspec` to run the tests.
|
304
|
+
|
271
305
|
## License
|
272
306
|
|
273
307
|
Delorean has been released under the MIT license. Please check the
|
data/lib/delorean/base.rb
CHANGED
@@ -173,7 +173,7 @@ module Delorean
|
|
173
173
|
|
174
174
|
######################################################################
|
175
175
|
|
176
|
-
def self._instance_call(obj, method, args, _e)
|
176
|
+
def self._instance_call(obj, method, args, _e, &block)
|
177
177
|
begin
|
178
178
|
msg = method.to_sym
|
179
179
|
rescue NoMethodError
|
@@ -193,14 +193,22 @@ module Delorean
|
|
193
193
|
raise "no such method #{method}" unless matcher
|
194
194
|
|
195
195
|
if matcher.match_to?
|
196
|
-
|
197
|
-
|
198
|
-
|
196
|
+
if block
|
197
|
+
return(
|
198
|
+
_instance_call(obj, matcher.match_to, args, _e, &block)
|
199
|
+
)
|
200
|
+
else
|
201
|
+
return(
|
202
|
+
_instance_call(obj, matcher.match_to, args, _e)
|
203
|
+
)
|
204
|
+
end
|
199
205
|
end
|
200
206
|
|
201
207
|
matcher.match!(klass: klass, args: args)
|
202
208
|
|
203
|
-
obj.public_send(msg, *args)
|
209
|
+
return obj.public_send(msg, *args) unless block
|
210
|
+
|
211
|
+
obj.public_send(msg, *args, &block)
|
204
212
|
end
|
205
213
|
|
206
214
|
######################################################################
|
data/lib/delorean/delorean.rb
CHANGED
@@ -1103,6 +1103,268 @@ module Delorean
|
|
1103
1103
|
r0
|
1104
1104
|
end
|
1105
1105
|
|
1106
|
+
module BlockArgs0
|
1107
|
+
def sp41
|
1108
|
+
elements[0]
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
def sp42
|
1112
|
+
elements[1]
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
def i
|
1116
|
+
elements[3]
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
def e
|
1120
|
+
elements[7]
|
1121
|
+
end
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
module BlockArgs1
|
1125
|
+
def sp41
|
1126
|
+
elements[0]
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
def sp42
|
1130
|
+
elements[1]
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
def i
|
1134
|
+
elements[3]
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
def _nt_block_args
|
1140
|
+
start_index = index
|
1141
|
+
if node_cache[:block_args].has_key?(index)
|
1142
|
+
cached = node_cache[:block_args][index]
|
1143
|
+
if cached
|
1144
|
+
node_cache[:block_args][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1145
|
+
@index = cached.interval.end
|
1146
|
+
end
|
1147
|
+
return cached
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
i0 = index
|
1151
|
+
i1, s1 = index, []
|
1152
|
+
r2 = _nt_sp4
|
1153
|
+
s1 << r2
|
1154
|
+
if r2
|
1155
|
+
r3 = _nt_sp4
|
1156
|
+
s1 << r3
|
1157
|
+
if r3
|
1158
|
+
r5 = _nt_sp
|
1159
|
+
if r5
|
1160
|
+
r4 = r5
|
1161
|
+
else
|
1162
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1163
|
+
end
|
1164
|
+
s1 << r4
|
1165
|
+
if r4
|
1166
|
+
r6 = _nt_identifier
|
1167
|
+
s1 << r6
|
1168
|
+
if r6
|
1169
|
+
r8 = _nt_sp
|
1170
|
+
if r8
|
1171
|
+
r7 = r8
|
1172
|
+
else
|
1173
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
1174
|
+
end
|
1175
|
+
s1 << r7
|
1176
|
+
if r7
|
1177
|
+
if (match_len = has_terminal?('=?', false, index))
|
1178
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1179
|
+
@index += match_len
|
1180
|
+
else
|
1181
|
+
terminal_parse_failure('\'=?\'')
|
1182
|
+
r9 = nil
|
1183
|
+
end
|
1184
|
+
s1 << r9
|
1185
|
+
if r9
|
1186
|
+
r11 = _nt_sp1
|
1187
|
+
if r11
|
1188
|
+
r10 = r11
|
1189
|
+
else
|
1190
|
+
r10 = instantiate_node(SyntaxNode,input, index...index)
|
1191
|
+
end
|
1192
|
+
s1 << r10
|
1193
|
+
if r10
|
1194
|
+
r12 = _nt_expression
|
1195
|
+
s1 << r12
|
1196
|
+
end
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
end
|
1200
|
+
end
|
1201
|
+
end
|
1202
|
+
end
|
1203
|
+
if s1.last
|
1204
|
+
r1 = instantiate_node(BlockParameterDefault,input, i1...index, s1)
|
1205
|
+
r1.extend(BlockArgs0)
|
1206
|
+
else
|
1207
|
+
@index = i1
|
1208
|
+
r1 = nil
|
1209
|
+
end
|
1210
|
+
if r1
|
1211
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1212
|
+
r0 = r1
|
1213
|
+
else
|
1214
|
+
i13, s13 = index, []
|
1215
|
+
r14 = _nt_sp4
|
1216
|
+
s13 << r14
|
1217
|
+
if r14
|
1218
|
+
r15 = _nt_sp4
|
1219
|
+
s13 << r15
|
1220
|
+
if r15
|
1221
|
+
r17 = _nt_sp
|
1222
|
+
if r17
|
1223
|
+
r16 = r17
|
1224
|
+
else
|
1225
|
+
r16 = instantiate_node(SyntaxNode,input, index...index)
|
1226
|
+
end
|
1227
|
+
s13 << r16
|
1228
|
+
if r16
|
1229
|
+
r18 = _nt_identifier
|
1230
|
+
s13 << r18
|
1231
|
+
if r18
|
1232
|
+
r20 = _nt_sp
|
1233
|
+
if r20
|
1234
|
+
r19 = r20
|
1235
|
+
else
|
1236
|
+
r19 = instantiate_node(SyntaxNode,input, index...index)
|
1237
|
+
end
|
1238
|
+
s13 << r19
|
1239
|
+
if r19
|
1240
|
+
if (match_len = has_terminal?('=?', false, index))
|
1241
|
+
r21 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1242
|
+
@index += match_len
|
1243
|
+
else
|
1244
|
+
terminal_parse_failure('\'=?\'')
|
1245
|
+
r21 = nil
|
1246
|
+
end
|
1247
|
+
s13 << r21
|
1248
|
+
end
|
1249
|
+
end
|
1250
|
+
end
|
1251
|
+
end
|
1252
|
+
end
|
1253
|
+
if s13.last
|
1254
|
+
r13 = instantiate_node(BlockParameter,input, i13...index, s13)
|
1255
|
+
r13.extend(BlockArgs1)
|
1256
|
+
else
|
1257
|
+
@index = i13
|
1258
|
+
r13 = nil
|
1259
|
+
end
|
1260
|
+
if r13
|
1261
|
+
r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
|
1262
|
+
r0 = r13
|
1263
|
+
else
|
1264
|
+
@index = i0
|
1265
|
+
r0 = nil
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
node_cache[:block_args][start_index] = r0
|
1270
|
+
|
1271
|
+
r0
|
1272
|
+
end
|
1273
|
+
|
1274
|
+
module BlockFormulas0
|
1275
|
+
def sp41
|
1276
|
+
elements[0]
|
1277
|
+
end
|
1278
|
+
|
1279
|
+
def sp42
|
1280
|
+
elements[1]
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
def i
|
1284
|
+
elements[3]
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
def e
|
1288
|
+
elements[7]
|
1289
|
+
end
|
1290
|
+
end
|
1291
|
+
|
1292
|
+
def _nt_block_formulas
|
1293
|
+
start_index = index
|
1294
|
+
if node_cache[:block_formulas].has_key?(index)
|
1295
|
+
cached = node_cache[:block_formulas][index]
|
1296
|
+
if cached
|
1297
|
+
node_cache[:block_formulas][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1298
|
+
@index = cached.interval.end
|
1299
|
+
end
|
1300
|
+
return cached
|
1301
|
+
end
|
1302
|
+
|
1303
|
+
i0, s0 = index, []
|
1304
|
+
r1 = _nt_sp4
|
1305
|
+
s0 << r1
|
1306
|
+
if r1
|
1307
|
+
r2 = _nt_sp4
|
1308
|
+
s0 << r2
|
1309
|
+
if r2
|
1310
|
+
r4 = _nt_sp
|
1311
|
+
if r4
|
1312
|
+
r3 = r4
|
1313
|
+
else
|
1314
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
1315
|
+
end
|
1316
|
+
s0 << r3
|
1317
|
+
if r3
|
1318
|
+
r5 = _nt_identifier
|
1319
|
+
s0 << r5
|
1320
|
+
if r5
|
1321
|
+
r7 = _nt_sp
|
1322
|
+
if r7
|
1323
|
+
r6 = r7
|
1324
|
+
else
|
1325
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
1326
|
+
end
|
1327
|
+
s0 << r6
|
1328
|
+
if r6
|
1329
|
+
if (match_len = has_terminal?('=', false, index))
|
1330
|
+
r8 = true
|
1331
|
+
@index += match_len
|
1332
|
+
else
|
1333
|
+
terminal_parse_failure('\'=\'')
|
1334
|
+
r8 = nil
|
1335
|
+
end
|
1336
|
+
s0 << r8
|
1337
|
+
if r8
|
1338
|
+
r10 = _nt_sp
|
1339
|
+
if r10
|
1340
|
+
r9 = r10
|
1341
|
+
else
|
1342
|
+
r9 = instantiate_node(SyntaxNode,input, index...index)
|
1343
|
+
end
|
1344
|
+
s0 << r9
|
1345
|
+
if r9
|
1346
|
+
r11 = _nt_expression
|
1347
|
+
s0 << r11
|
1348
|
+
end
|
1349
|
+
end
|
1350
|
+
end
|
1351
|
+
end
|
1352
|
+
end
|
1353
|
+
end
|
1354
|
+
end
|
1355
|
+
if s0.last
|
1356
|
+
r0 = instantiate_node(BlockFormula,input, i0...index, s0)
|
1357
|
+
r0.extend(BlockFormulas0)
|
1358
|
+
else
|
1359
|
+
@index = i0
|
1360
|
+
r0 = nil
|
1361
|
+
end
|
1362
|
+
|
1363
|
+
node_cache[:block_formulas][start_index] = r0
|
1364
|
+
|
1365
|
+
r0
|
1366
|
+
end
|
1367
|
+
|
1106
1368
|
module GetattrExp0
|
1107
1369
|
def v
|
1108
1370
|
elements[0]
|
@@ -1227,12 +1489,44 @@ module Delorean
|
|
1227
1489
|
elements[5]
|
1228
1490
|
end
|
1229
1491
|
|
1492
|
+
def b_args
|
1493
|
+
elements[8]
|
1494
|
+
end
|
1495
|
+
|
1496
|
+
def expressions
|
1497
|
+
elements[9]
|
1498
|
+
end
|
1230
1499
|
end
|
1231
1500
|
|
1232
1501
|
module DotExp3
|
1233
1502
|
def i
|
1234
1503
|
elements[2]
|
1235
1504
|
end
|
1505
|
+
|
1506
|
+
def al
|
1507
|
+
elements[5]
|
1508
|
+
end
|
1509
|
+
|
1510
|
+
end
|
1511
|
+
|
1512
|
+
module DotExp4
|
1513
|
+
def i
|
1514
|
+
elements[2]
|
1515
|
+
end
|
1516
|
+
|
1517
|
+
def b_args
|
1518
|
+
elements[3]
|
1519
|
+
end
|
1520
|
+
|
1521
|
+
def expressions
|
1522
|
+
elements[4]
|
1523
|
+
end
|
1524
|
+
end
|
1525
|
+
|
1526
|
+
module DotExp5
|
1527
|
+
def i
|
1528
|
+
elements[2]
|
1529
|
+
end
|
1236
1530
|
end
|
1237
1531
|
|
1238
1532
|
def _nt_dot_exp
|
@@ -1418,6 +1712,37 @@ module Delorean
|
|
1418
1712
|
r30 = nil
|
1419
1713
|
end
|
1420
1714
|
s18 << r30
|
1715
|
+
if r30
|
1716
|
+
s31, i31 = [], index
|
1717
|
+
loop do
|
1718
|
+
r32 = _nt_block_args
|
1719
|
+
if r32
|
1720
|
+
s31 << r32
|
1721
|
+
else
|
1722
|
+
break
|
1723
|
+
end
|
1724
|
+
end
|
1725
|
+
r31 = instantiate_node(SyntaxNode,input, i31...index, s31)
|
1726
|
+
s18 << r31
|
1727
|
+
if r31
|
1728
|
+
s33, i33 = [], index
|
1729
|
+
loop do
|
1730
|
+
r34 = _nt_block_formulas
|
1731
|
+
if r34
|
1732
|
+
s33 << r34
|
1733
|
+
else
|
1734
|
+
break
|
1735
|
+
end
|
1736
|
+
end
|
1737
|
+
if s33.empty?
|
1738
|
+
@index = i33
|
1739
|
+
r33 = nil
|
1740
|
+
else
|
1741
|
+
r33 = instantiate_node(SyntaxNode,input, i33...index, s33)
|
1742
|
+
end
|
1743
|
+
s18 << r33
|
1744
|
+
end
|
1745
|
+
end
|
1421
1746
|
end
|
1422
1747
|
end
|
1423
1748
|
end
|
@@ -1426,7 +1751,7 @@ module Delorean
|
|
1426
1751
|
end
|
1427
1752
|
end
|
1428
1753
|
if s18.last
|
1429
|
-
r18 = instantiate_node(
|
1754
|
+
r18 = instantiate_node(BlockExpression,input, i18...index, s18)
|
1430
1755
|
r18.extend(DotExp2)
|
1431
1756
|
else
|
1432
1757
|
@index = i18
|
@@ -1436,55 +1761,201 @@ module Delorean
|
|
1436
1761
|
r18 = SyntaxNode.new(input, (index-1)...index) if r18 == true
|
1437
1762
|
r0 = r18
|
1438
1763
|
else
|
1439
|
-
|
1764
|
+
i35, s35 = index, []
|
1440
1765
|
if (match_len = has_terminal?('.', false, index))
|
1441
|
-
|
1766
|
+
r36 = true
|
1442
1767
|
@index += match_len
|
1443
1768
|
else
|
1444
1769
|
terminal_parse_failure('\'.\'')
|
1445
|
-
|
1770
|
+
r36 = nil
|
1446
1771
|
end
|
1447
|
-
|
1448
|
-
if
|
1449
|
-
|
1450
|
-
if
|
1451
|
-
|
1772
|
+
s35 << r36
|
1773
|
+
if r36
|
1774
|
+
r38 = _nt_sp
|
1775
|
+
if r38
|
1776
|
+
r37 = r38
|
1452
1777
|
else
|
1453
|
-
|
1778
|
+
r37 = instantiate_node(SyntaxNode,input, index...index)
|
1454
1779
|
end
|
1455
|
-
|
1456
|
-
if
|
1457
|
-
|
1458
|
-
|
1459
|
-
if
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
r37 = _nt_integer
|
1464
|
-
if r37
|
1465
|
-
r37 = SyntaxNode.new(input, (index-1)...index) if r37 == true
|
1466
|
-
r35 = r37
|
1780
|
+
s35 << r37
|
1781
|
+
if r37
|
1782
|
+
r39 = _nt_identifier
|
1783
|
+
s35 << r39
|
1784
|
+
if r39
|
1785
|
+
if (match_len = has_terminal?('(', false, index))
|
1786
|
+
r40 = true
|
1787
|
+
@index += match_len
|
1467
1788
|
else
|
1468
|
-
|
1469
|
-
|
1789
|
+
terminal_parse_failure('\'(\'')
|
1790
|
+
r40 = nil
|
1791
|
+
end
|
1792
|
+
s35 << r40
|
1793
|
+
if r40
|
1794
|
+
r42 = _nt_sp
|
1795
|
+
if r42
|
1796
|
+
r41 = r42
|
1797
|
+
else
|
1798
|
+
r41 = instantiate_node(SyntaxNode,input, index...index)
|
1799
|
+
end
|
1800
|
+
s35 << r41
|
1801
|
+
if r41
|
1802
|
+
r44 = _nt_fn_args
|
1803
|
+
if r44
|
1804
|
+
r43 = r44
|
1805
|
+
else
|
1806
|
+
r43 = instantiate_node(SyntaxNode,input, index...index)
|
1807
|
+
end
|
1808
|
+
s35 << r43
|
1809
|
+
if r43
|
1810
|
+
r46 = _nt_sp
|
1811
|
+
if r46
|
1812
|
+
r45 = r46
|
1813
|
+
else
|
1814
|
+
r45 = instantiate_node(SyntaxNode,input, index...index)
|
1815
|
+
end
|
1816
|
+
s35 << r45
|
1817
|
+
if r45
|
1818
|
+
if (match_len = has_terminal?(')', false, index))
|
1819
|
+
r47 = true
|
1820
|
+
@index += match_len
|
1821
|
+
else
|
1822
|
+
terminal_parse_failure('\')\'')
|
1823
|
+
r47 = nil
|
1824
|
+
end
|
1825
|
+
s35 << r47
|
1826
|
+
end
|
1827
|
+
end
|
1828
|
+
end
|
1470
1829
|
end
|
1471
1830
|
end
|
1472
|
-
s31 << r35
|
1473
1831
|
end
|
1474
1832
|
end
|
1475
|
-
if
|
1476
|
-
|
1477
|
-
|
1833
|
+
if s35.last
|
1834
|
+
r35 = instantiate_node(Call,input, i35...index, s35)
|
1835
|
+
r35.extend(DotExp3)
|
1478
1836
|
else
|
1479
|
-
@index =
|
1480
|
-
|
1837
|
+
@index = i35
|
1838
|
+
r35 = nil
|
1481
1839
|
end
|
1482
|
-
if
|
1483
|
-
|
1484
|
-
r0 =
|
1840
|
+
if r35
|
1841
|
+
r35 = SyntaxNode.new(input, (index-1)...index) if r35 == true
|
1842
|
+
r0 = r35
|
1485
1843
|
else
|
1486
|
-
|
1487
|
-
|
1844
|
+
i48, s48 = index, []
|
1845
|
+
if (match_len = has_terminal?('.', false, index))
|
1846
|
+
r49 = true
|
1847
|
+
@index += match_len
|
1848
|
+
else
|
1849
|
+
terminal_parse_failure('\'.\'')
|
1850
|
+
r49 = nil
|
1851
|
+
end
|
1852
|
+
s48 << r49
|
1853
|
+
if r49
|
1854
|
+
r51 = _nt_sp
|
1855
|
+
if r51
|
1856
|
+
r50 = r51
|
1857
|
+
else
|
1858
|
+
r50 = instantiate_node(SyntaxNode,input, index...index)
|
1859
|
+
end
|
1860
|
+
s48 << r50
|
1861
|
+
if r50
|
1862
|
+
r52 = _nt_identifier
|
1863
|
+
s48 << r52
|
1864
|
+
if r52
|
1865
|
+
s53, i53 = [], index
|
1866
|
+
loop do
|
1867
|
+
r54 = _nt_block_args
|
1868
|
+
if r54
|
1869
|
+
s53 << r54
|
1870
|
+
else
|
1871
|
+
break
|
1872
|
+
end
|
1873
|
+
end
|
1874
|
+
r53 = instantiate_node(SyntaxNode,input, i53...index, s53)
|
1875
|
+
s48 << r53
|
1876
|
+
if r53
|
1877
|
+
s55, i55 = [], index
|
1878
|
+
loop do
|
1879
|
+
r56 = _nt_block_formulas
|
1880
|
+
if r56
|
1881
|
+
s55 << r56
|
1882
|
+
else
|
1883
|
+
break
|
1884
|
+
end
|
1885
|
+
end
|
1886
|
+
if s55.empty?
|
1887
|
+
@index = i55
|
1888
|
+
r55 = nil
|
1889
|
+
else
|
1890
|
+
r55 = instantiate_node(SyntaxNode,input, i55...index, s55)
|
1891
|
+
end
|
1892
|
+
s48 << r55
|
1893
|
+
end
|
1894
|
+
end
|
1895
|
+
end
|
1896
|
+
end
|
1897
|
+
if s48.last
|
1898
|
+
r48 = instantiate_node(BlockExpression,input, i48...index, s48)
|
1899
|
+
r48.extend(DotExp4)
|
1900
|
+
else
|
1901
|
+
@index = i48
|
1902
|
+
r48 = nil
|
1903
|
+
end
|
1904
|
+
if r48
|
1905
|
+
r48 = SyntaxNode.new(input, (index-1)...index) if r48 == true
|
1906
|
+
r0 = r48
|
1907
|
+
else
|
1908
|
+
i57, s57 = index, []
|
1909
|
+
if (match_len = has_terminal?('.', false, index))
|
1910
|
+
r58 = true
|
1911
|
+
@index += match_len
|
1912
|
+
else
|
1913
|
+
terminal_parse_failure('\'.\'')
|
1914
|
+
r58 = nil
|
1915
|
+
end
|
1916
|
+
s57 << r58
|
1917
|
+
if r58
|
1918
|
+
r60 = _nt_sp
|
1919
|
+
if r60
|
1920
|
+
r59 = r60
|
1921
|
+
else
|
1922
|
+
r59 = instantiate_node(SyntaxNode,input, index...index)
|
1923
|
+
end
|
1924
|
+
s57 << r59
|
1925
|
+
if r59
|
1926
|
+
i61 = index
|
1927
|
+
r62 = _nt_identifier
|
1928
|
+
if r62
|
1929
|
+
r62 = SyntaxNode.new(input, (index-1)...index) if r62 == true
|
1930
|
+
r61 = r62
|
1931
|
+
else
|
1932
|
+
r63 = _nt_integer
|
1933
|
+
if r63
|
1934
|
+
r63 = SyntaxNode.new(input, (index-1)...index) if r63 == true
|
1935
|
+
r61 = r63
|
1936
|
+
else
|
1937
|
+
@index = i61
|
1938
|
+
r61 = nil
|
1939
|
+
end
|
1940
|
+
end
|
1941
|
+
s57 << r61
|
1942
|
+
end
|
1943
|
+
end
|
1944
|
+
if s57.last
|
1945
|
+
r57 = instantiate_node(GetAttr,input, i57...index, s57)
|
1946
|
+
r57.extend(DotExp5)
|
1947
|
+
else
|
1948
|
+
@index = i57
|
1949
|
+
r57 = nil
|
1950
|
+
end
|
1951
|
+
if r57
|
1952
|
+
r57 = SyntaxNode.new(input, (index-1)...index) if r57 == true
|
1953
|
+
r0 = r57
|
1954
|
+
else
|
1955
|
+
@index = i0
|
1956
|
+
r0 = nil
|
1957
|
+
end
|
1958
|
+
end
|
1488
1959
|
end
|
1489
1960
|
end
|
1490
1961
|
end
|
@@ -4006,6 +4477,21 @@ module Delorean
|
|
4006
4477
|
end
|
4007
4478
|
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
4008
4479
|
s0 << r2
|
4480
|
+
if r2
|
4481
|
+
if (match_len = has_terminal?('?', false, index))
|
4482
|
+
r5 = true
|
4483
|
+
@index += match_len
|
4484
|
+
else
|
4485
|
+
terminal_parse_failure('\'?\'')
|
4486
|
+
r5 = nil
|
4487
|
+
end
|
4488
|
+
if r5
|
4489
|
+
r4 = r5
|
4490
|
+
else
|
4491
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
4492
|
+
end
|
4493
|
+
s0 << r4
|
4494
|
+
end
|
4009
4495
|
end
|
4010
4496
|
if s0.last
|
4011
4497
|
r0 = instantiate_node(Identifier,input, i0...index, s0)
|
@@ -4160,6 +4646,30 @@ module Delorean
|
|
4160
4646
|
r0
|
4161
4647
|
end
|
4162
4648
|
|
4649
|
+
def _nt_sp1
|
4650
|
+
start_index = index
|
4651
|
+
if node_cache[:sp1].has_key?(index)
|
4652
|
+
cached = node_cache[:sp1][index]
|
4653
|
+
if cached
|
4654
|
+
node_cache[:sp1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
4655
|
+
@index = cached.interval.end
|
4656
|
+
end
|
4657
|
+
return cached
|
4658
|
+
end
|
4659
|
+
|
4660
|
+
if (match_len = has_terminal?(' ', false, index))
|
4661
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4662
|
+
@index += match_len
|
4663
|
+
else
|
4664
|
+
terminal_parse_failure('\' \'')
|
4665
|
+
r0 = nil
|
4666
|
+
end
|
4667
|
+
|
4668
|
+
node_cache[:sp1][start_index] = r0
|
4669
|
+
|
4670
|
+
r0
|
4671
|
+
end
|
4672
|
+
|
4163
4673
|
def _nt_sp
|
4164
4674
|
start_index = index
|
4165
4675
|
if node_cache[:sp].has_key?(index)
|