ql 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/q.treetop +1 -1
  3. data/lib/q/parser.rb +273 -212
  4. data/lib/q/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1274bf508e426ef6714a7e9b95b311370b36cddf
4
- data.tar.gz: 302f4ce8b8383246eab4dd1cfea056f16a7dbdc3
3
+ metadata.gz: 5f4ccf181c9bb7a8d5afdf82358167c2c5acf324
4
+ data.tar.gz: 75d5222d1aafaf65a2bf19d37f295885f9bb13d7
5
5
  SHA512:
6
- metadata.gz: 8911228fc7f5602f58982e29941e4345ff6581e039a84179b83626897088d5631ebff9c1b52e09cb5d4f45487c09dbdecaa53ec365112c874fceb4dfe8775478
7
- data.tar.gz: 3ada2ca17e79543b6e7b87e366f42bc1e6decf06ef1ab3dd2d7e1c439f66d4e5d7d6bd531b98c52852265079be32e2add13c089047a63dab8981eaac4a7d992a
6
+ metadata.gz: b75ccdff15f2130137b0c7247570dfd8cb10cc63bd70713f3568f05b177616d6dcdaf4e92fd94567cca8783fa37b32880c5c995a7c6c4a797b671fcea6de770b
7
+ data.tar.gz: c13b4c0ec48dffb0eb2cd143f378aabf539930f7a612c918f5ec23a383de3c4adfcdee779fadfc17ed59be5cbb3bb6c057dbc140d887dca1c7a74ec769b31092
@@ -174,7 +174,7 @@ grammar Q
174
174
  rule gt
175
175
  '>' {
176
176
  def apply scope, a, b
177
- a.eval(scope) < b.eval(scope)
177
+ a.eval(scope) > b.eval(scope)
178
178
  end
179
179
  }
180
180
  end
@@ -40,7 +40,7 @@ module Q
40
40
  if node_cache[:statements].has_key?(index)
41
41
  cached = node_cache[:statements][index]
42
42
  if cached
43
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
43
+ node_cache[:statements][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
44
44
  @index = cached.interval.end
45
45
  end
46
46
  return cached
@@ -65,10 +65,12 @@ module Q
65
65
  i5 = index
66
66
  r6 = _nt_comment
67
67
  if r6
68
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
68
69
  r5 = r6
69
70
  else
70
71
  r7 = _nt_statement
71
72
  if r7
73
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
72
74
  r5 = r7
73
75
  else
74
76
  @index = i5
@@ -150,7 +152,7 @@ module Q
150
152
  if node_cache[:statement].has_key?(index)
151
153
  cached = node_cache[:statement][index]
152
154
  if cached
153
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
155
+ node_cache[:statement][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
154
156
  @index = cached.interval.end
155
157
  end
156
158
  return cached
@@ -172,9 +174,9 @@ module Q
172
174
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
173
175
  s0 << r2
174
176
  if r2
175
- if has_terminal?(';', false, index)
176
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
177
- @index += 1
177
+ if (match_len = has_terminal?(';', false, index))
178
+ r4 = true
179
+ @index += match_len
178
180
  else
179
181
  terminal_parse_failure(';')
180
182
  r4 = nil
@@ -201,7 +203,7 @@ module Q
201
203
  if node_cache[:expression].has_key?(index)
202
204
  cached = node_cache[:expression][index]
203
205
  if cached
204
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
206
+ node_cache[:expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
205
207
  @index = cached.interval.end
206
208
  end
207
209
  return cached
@@ -210,18 +212,22 @@ module Q
210
212
  i0 = index
211
213
  r1 = _nt_call
212
214
  if r1
215
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
213
216
  r0 = r1
214
217
  else
215
218
  r2 = _nt_assignment
216
219
  if r2
220
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
217
221
  r0 = r2
218
222
  else
219
223
  r3 = _nt_conditional
220
224
  if r3
225
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
221
226
  r0 = r3
222
227
  else
223
228
  r4 = _nt_binomial
224
229
  if r4
230
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
225
231
  r0 = r4
226
232
  else
227
233
  @index = i0
@@ -259,16 +265,16 @@ module Q
259
265
  if node_cache[:function].has_key?(index)
260
266
  cached = node_cache[:function][index]
261
267
  if cached
262
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
268
+ node_cache[:function][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
263
269
  @index = cached.interval.end
264
270
  end
265
271
  return cached
266
272
  end
267
273
 
268
274
  i0, s0 = index, []
269
- if has_terminal?('(', false, index)
270
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
271
- @index += 1
275
+ if (match_len = has_terminal?('(', false, index))
276
+ r1 = true
277
+ @index += match_len
272
278
  else
273
279
  terminal_parse_failure('(')
274
280
  r1 = nil
@@ -322,18 +328,18 @@ module Q
322
328
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
323
329
  s0 << r2
324
330
  if r2
325
- if has_terminal?(')', false, index)
326
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
327
- @index += 1
331
+ if (match_len = has_terminal?(')', false, index))
332
+ r9 = true
333
+ @index += match_len
328
334
  else
329
335
  terminal_parse_failure(')')
330
336
  r9 = nil
331
337
  end
332
338
  s0 << r9
333
339
  if r9
334
- if has_terminal?('{', false, index)
335
- r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
336
- @index += 1
340
+ if (match_len = has_terminal?('{', false, index))
341
+ r10 = true
342
+ @index += match_len
337
343
  else
338
344
  terminal_parse_failure('{')
339
345
  r10 = nil
@@ -343,9 +349,9 @@ module Q
343
349
  r11 = _nt_statements
344
350
  s0 << r11
345
351
  if r11
346
- if has_terminal?('}', false, index)
347
- r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
348
- @index += 1
352
+ if (match_len = has_terminal?('}', false, index))
353
+ r12 = true
354
+ @index += match_len
349
355
  else
350
356
  terminal_parse_failure('}')
351
357
  r12 = nil
@@ -390,7 +396,7 @@ module Q
390
396
  if node_cache[:assignment].has_key?(index)
391
397
  cached = node_cache[:assignment][index]
392
398
  if cached
393
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
399
+ node_cache[:assignment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
394
400
  @index = cached.interval.end
395
401
  end
396
402
  return cached
@@ -400,10 +406,12 @@ module Q
400
406
  i1 = index
401
407
  r2 = _nt_self
402
408
  if r2
409
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
403
410
  r1 = r2
404
411
  else
405
412
  r3 = _nt_identifier
406
413
  if r3
414
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
407
415
  r1 = r3
408
416
  else
409
417
  @index = i1
@@ -424,9 +432,9 @@ module Q
424
432
  r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
425
433
  s0 << r4
426
434
  if r4
427
- if has_terminal?('<:', false, index)
428
- r6 = instantiate_node(SyntaxNode,input, index...(index + 2))
429
- @index += 2
435
+ if (match_len = has_terminal?('<:', false, index))
436
+ r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
437
+ @index += match_len
430
438
  else
431
439
  terminal_parse_failure('<:')
432
440
  r6 = nil
@@ -504,7 +512,7 @@ module Q
504
512
  if node_cache[:call].has_key?(index)
505
513
  cached = node_cache[:call][index]
506
514
  if cached
507
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
515
+ node_cache[:call][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
508
516
  @index = cached.interval.end
509
517
  end
510
518
  return cached
@@ -514,14 +522,17 @@ module Q
514
522
  i1 = index
515
523
  r2 = _nt_function
516
524
  if r2
525
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
517
526
  r1 = r2
518
527
  else
519
528
  r3 = _nt_self
520
529
  if r3
530
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
521
531
  r1 = r3
522
532
  else
523
533
  r4 = _nt_identifier
524
534
  if r4
535
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
525
536
  r1 = r4
526
537
  else
527
538
  @index = i1
@@ -543,9 +554,9 @@ module Q
543
554
  r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
544
555
  s0 << r5
545
556
  if r5
546
- if has_terminal?('(', false, index)
547
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
548
- @index += 1
557
+ if (match_len = has_terminal?('(', false, index))
558
+ r7 = true
559
+ @index += match_len
549
560
  else
550
561
  terminal_parse_failure('(')
551
562
  r7 = nil
@@ -599,9 +610,9 @@ module Q
599
610
  r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
600
611
  s0 << r8
601
612
  if r8
602
- if has_terminal?(')', false, index)
603
- r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
604
- @index += 1
613
+ if (match_len = has_terminal?(')', false, index))
614
+ r15 = true
615
+ @index += match_len
605
616
  else
606
617
  terminal_parse_failure(')')
607
618
  r15 = nil
@@ -676,7 +687,7 @@ module Q
676
687
  if node_cache[:binomial].has_key?(index)
677
688
  cached = node_cache[:binomial][index]
678
689
  if cached
679
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
690
+ node_cache[:binomial][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
680
691
  @index = cached.interval.end
681
692
  end
682
693
  return cached
@@ -810,7 +821,7 @@ module Q
810
821
  if node_cache[:monomial].has_key?(index)
811
822
  cached = node_cache[:monomial][index]
812
823
  if cached
813
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
824
+ node_cache[:monomial][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
814
825
  @index = cached.interval.end
815
826
  end
816
827
  return cached
@@ -924,16 +935,16 @@ module Q
924
935
  if node_cache[:conditional].has_key?(index)
925
936
  cached = node_cache[:conditional][index]
926
937
  if cached
927
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
938
+ node_cache[:conditional][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
928
939
  @index = cached.interval.end
929
940
  end
930
941
  return cached
931
942
  end
932
943
 
933
944
  i0, s0 = index, []
934
- if has_terminal?('if', false, index)
935
- r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
936
- @index += 2
945
+ if (match_len = has_terminal?('if', false, index))
946
+ r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
947
+ @index += match_len
937
948
  else
938
949
  terminal_parse_failure('if')
939
950
  r1 = nil
@@ -952,9 +963,9 @@ module Q
952
963
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
953
964
  s0 << r2
954
965
  if r2
955
- if has_terminal?('[', false, index)
956
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
957
- @index += 1
966
+ if (match_len = has_terminal?('[', false, index))
967
+ r4 = true
968
+ @index += match_len
958
969
  else
959
970
  terminal_parse_failure('[')
960
971
  r4 = nil
@@ -964,10 +975,12 @@ module Q
964
975
  i5 = index
965
976
  r6 = _nt_conditional_expression
966
977
  if r6
978
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
967
979
  r5 = r6
968
980
  else
969
981
  r7 = _nt_statements
970
982
  if r7
983
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
971
984
  r5 = r7
972
985
  else
973
986
  @index = i5
@@ -976,9 +989,9 @@ module Q
976
989
  end
977
990
  s0 << r5
978
991
  if r5
979
- if has_terminal?(']', false, index)
980
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
981
- @index += 1
992
+ if (match_len = has_terminal?(']', false, index))
993
+ r8 = true
994
+ @index += match_len
982
995
  else
983
996
  terminal_parse_failure(']')
984
997
  r8 = nil
@@ -997,9 +1010,9 @@ module Q
997
1010
  r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
998
1011
  s0 << r9
999
1012
  if r9
1000
- if has_terminal?('then', false, index)
1001
- r11 = instantiate_node(SyntaxNode,input, index...(index + 4))
1002
- @index += 4
1013
+ if (match_len = has_terminal?('then', false, index))
1014
+ r11 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1015
+ @index += match_len
1003
1016
  else
1004
1017
  terminal_parse_failure('then')
1005
1018
  r11 = nil
@@ -1018,9 +1031,9 @@ module Q
1018
1031
  r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1019
1032
  s0 << r12
1020
1033
  if r12
1021
- if has_terminal?('[', false, index)
1022
- r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
1023
- @index += 1
1034
+ if (match_len = has_terminal?('[', false, index))
1035
+ r14 = true
1036
+ @index += match_len
1024
1037
  else
1025
1038
  terminal_parse_failure('[')
1026
1039
  r14 = nil
@@ -1030,10 +1043,12 @@ module Q
1030
1043
  i15 = index
1031
1044
  r16 = _nt_conditional_expression
1032
1045
  if r16
1046
+ r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
1033
1047
  r15 = r16
1034
1048
  else
1035
1049
  r17 = _nt_statements
1036
1050
  if r17
1051
+ r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true
1037
1052
  r15 = r17
1038
1053
  else
1039
1054
  @index = i15
@@ -1042,9 +1057,9 @@ module Q
1042
1057
  end
1043
1058
  s0 << r15
1044
1059
  if r15
1045
- if has_terminal?(']', false, index)
1046
- r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
1047
- @index += 1
1060
+ if (match_len = has_terminal?(']', false, index))
1061
+ r18 = true
1062
+ @index += match_len
1048
1063
  else
1049
1064
  terminal_parse_failure(']')
1050
1065
  r18 = nil
@@ -1064,9 +1079,9 @@ module Q
1064
1079
  r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
1065
1080
  s20 << r21
1066
1081
  if r21
1067
- if has_terminal?('else', false, index)
1068
- r23 = instantiate_node(SyntaxNode,input, index...(index + 4))
1069
- @index += 4
1082
+ if (match_len = has_terminal?('else', false, index))
1083
+ r23 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1084
+ @index += match_len
1070
1085
  else
1071
1086
  terminal_parse_failure('else')
1072
1087
  r23 = nil
@@ -1085,9 +1100,9 @@ module Q
1085
1100
  r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
1086
1101
  s20 << r24
1087
1102
  if r24
1088
- if has_terminal?('[', false, index)
1089
- r26 = instantiate_node(SyntaxNode,input, index...(index + 1))
1090
- @index += 1
1103
+ if (match_len = has_terminal?('[', false, index))
1104
+ r26 = true
1105
+ @index += match_len
1091
1106
  else
1092
1107
  terminal_parse_failure('[')
1093
1108
  r26 = nil
@@ -1097,10 +1112,12 @@ module Q
1097
1112
  i27 = index
1098
1113
  r28 = _nt_conditional_expression
1099
1114
  if r28
1115
+ r28 = SyntaxNode.new(input, (index-1)...index) if r28 == true
1100
1116
  r27 = r28
1101
1117
  else
1102
1118
  r29 = _nt_statements
1103
1119
  if r29
1120
+ r29 = SyntaxNode.new(input, (index-1)...index) if r29 == true
1104
1121
  r27 = r29
1105
1122
  else
1106
1123
  @index = i27
@@ -1109,9 +1126,9 @@ module Q
1109
1126
  end
1110
1127
  s20 << r27
1111
1128
  if r27
1112
- if has_terminal?(']', false, index)
1113
- r30 = instantiate_node(SyntaxNode,input, index...(index + 1))
1114
- @index += 1
1129
+ if (match_len = has_terminal?(']', false, index))
1130
+ r30 = true
1131
+ @index += match_len
1115
1132
  else
1116
1133
  terminal_parse_failure(']')
1117
1134
  r30 = nil
@@ -1177,7 +1194,7 @@ module Q
1177
1194
  if node_cache[:conditional_expression].has_key?(index)
1178
1195
  cached = node_cache[:conditional_expression][index]
1179
1196
  if cached
1180
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1197
+ node_cache[:conditional_expression][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1181
1198
  @index = cached.interval.end
1182
1199
  end
1183
1200
  return cached
@@ -1212,9 +1229,9 @@ module Q
1212
1229
  s0 << r4
1213
1230
  if r4
1214
1231
  i6 = index
1215
- if has_terminal?(']', false, index)
1216
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
1217
- @index += 1
1232
+ if (match_len = has_terminal?(']', false, index))
1233
+ r7 = true
1234
+ @index += match_len
1218
1235
  else
1219
1236
  terminal_parse_failure(']')
1220
1237
  r7 = nil
@@ -1261,7 +1278,7 @@ module Q
1261
1278
  if node_cache[:primary].has_key?(index)
1262
1279
  cached = node_cache[:primary][index]
1263
1280
  if cached
1264
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1281
+ node_cache[:primary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1265
1282
  @index = cached.interval.end
1266
1283
  end
1267
1284
  return cached
@@ -1270,32 +1287,38 @@ module Q
1270
1287
  i0 = index
1271
1288
  r1 = _nt_call
1272
1289
  if r1
1290
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1273
1291
  r0 = r1
1274
1292
  else
1275
1293
  r2 = _nt_function
1276
1294
  if r2
1295
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1277
1296
  r0 = r2
1278
1297
  else
1279
1298
  r3 = _nt_self
1280
1299
  if r3
1300
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1281
1301
  r0 = r3
1282
1302
  else
1283
1303
  r4 = _nt_unary
1284
1304
  if r4
1305
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
1285
1306
  r0 = r4
1286
1307
  else
1287
1308
  r5 = _nt_value
1288
1309
  if r5
1310
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
1289
1311
  r0 = r5
1290
1312
  else
1291
1313
  r6 = _nt_identifier
1292
1314
  if r6
1315
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
1293
1316
  r0 = r6
1294
1317
  else
1295
1318
  i7, s7 = index, []
1296
- if has_terminal?('(', false, index)
1297
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
1298
- @index += 1
1319
+ if (match_len = has_terminal?('(', false, index))
1320
+ r8 = true
1321
+ @index += match_len
1299
1322
  else
1300
1323
  terminal_parse_failure('(')
1301
1324
  r8 = nil
@@ -1329,9 +1352,9 @@ module Q
1329
1352
  r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1330
1353
  s7 << r12
1331
1354
  if r12
1332
- if has_terminal?(')', false, index)
1333
- r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
1334
- @index += 1
1355
+ if (match_len = has_terminal?(')', false, index))
1356
+ r14 = true
1357
+ @index += match_len
1335
1358
  else
1336
1359
  terminal_parse_failure(')')
1337
1360
  r14 = nil
@@ -1350,6 +1373,7 @@ module Q
1350
1373
  r7 = nil
1351
1374
  end
1352
1375
  if r7
1376
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
1353
1377
  r0 = r7
1354
1378
  else
1355
1379
  @index = i0
@@ -1372,7 +1396,7 @@ module Q
1372
1396
  if node_cache[:binomial_operator].has_key?(index)
1373
1397
  cached = node_cache[:binomial_operator][index]
1374
1398
  if cached
1375
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1399
+ node_cache[:binomial_operator][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1376
1400
  @index = cached.interval.end
1377
1401
  end
1378
1402
  return cached
@@ -1381,14 +1405,17 @@ module Q
1381
1405
  i0 = index
1382
1406
  r1 = _nt_minus
1383
1407
  if r1
1408
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1384
1409
  r0 = r1
1385
1410
  else
1386
1411
  r2 = _nt_plus
1387
1412
  if r2
1413
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1388
1414
  r0 = r2
1389
1415
  else
1390
1416
  r3 = _nt_comparison_operators
1391
1417
  if r3
1418
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1392
1419
  r0 = r3
1393
1420
  else
1394
1421
  @index = i0
@@ -1407,7 +1434,7 @@ module Q
1407
1434
  if node_cache[:monomial_operator].has_key?(index)
1408
1435
  cached = node_cache[:monomial_operator][index]
1409
1436
  if cached
1410
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1437
+ node_cache[:monomial_operator][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1411
1438
  @index = cached.interval.end
1412
1439
  end
1413
1440
  return cached
@@ -1416,10 +1443,12 @@ module Q
1416
1443
  i0 = index
1417
1444
  r1 = _nt_slash
1418
1445
  if r1
1446
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1419
1447
  r0 = r1
1420
1448
  else
1421
1449
  r2 = _nt_star
1422
1450
  if r2
1451
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1423
1452
  r0 = r2
1424
1453
  else
1425
1454
  @index = i0
@@ -1437,7 +1466,7 @@ module Q
1437
1466
  if node_cache[:unary].has_key?(index)
1438
1467
  cached = node_cache[:unary][index]
1439
1468
  if cached
1440
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1469
+ node_cache[:unary][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1441
1470
  @index = cached.interval.end
1442
1471
  end
1443
1472
  return cached
@@ -1446,10 +1475,12 @@ module Q
1446
1475
  i0 = index
1447
1476
  r1 = _nt_negative
1448
1477
  if r1
1478
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1449
1479
  r0 = r1
1450
1480
  else
1451
1481
  r2 = _nt_negation
1452
1482
  if r2
1483
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1453
1484
  r0 = r2
1454
1485
  else
1455
1486
  @index = i0
@@ -1479,16 +1510,16 @@ module Q
1479
1510
  if node_cache[:negation].has_key?(index)
1480
1511
  cached = node_cache[:negation][index]
1481
1512
  if cached
1482
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1513
+ node_cache[:negation][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1483
1514
  @index = cached.interval.end
1484
1515
  end
1485
1516
  return cached
1486
1517
  end
1487
1518
 
1488
1519
  i0, s0 = index, []
1489
- if has_terminal?('!', false, index)
1490
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1491
- @index += 1
1520
+ if (match_len = has_terminal?('!', false, index))
1521
+ r1 = true
1522
+ @index += match_len
1492
1523
  else
1493
1524
  terminal_parse_failure('!')
1494
1525
  r1 = nil
@@ -1542,16 +1573,16 @@ module Q
1542
1573
  if node_cache[:negative].has_key?(index)
1543
1574
  cached = node_cache[:negative][index]
1544
1575
  if cached
1545
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1576
+ node_cache[:negative][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1546
1577
  @index = cached.interval.end
1547
1578
  end
1548
1579
  return cached
1549
1580
  end
1550
1581
 
1551
1582
  i0, s0 = index, []
1552
- if has_terminal?('-', false, index)
1553
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
1554
- @index += 1
1583
+ if (match_len = has_terminal?('-', false, index))
1584
+ r1 = true
1585
+ @index += match_len
1555
1586
  else
1556
1587
  terminal_parse_failure('-')
1557
1588
  r1 = nil
@@ -1593,7 +1624,7 @@ module Q
1593
1624
  if node_cache[:comparison_operators].has_key?(index)
1594
1625
  cached = node_cache[:comparison_operators][index]
1595
1626
  if cached
1596
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1627
+ node_cache[:comparison_operators][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1597
1628
  @index = cached.interval.end
1598
1629
  end
1599
1630
  return cached
@@ -1602,26 +1633,32 @@ module Q
1602
1633
  i0 = index
1603
1634
  r1 = _nt_lt
1604
1635
  if r1
1636
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1605
1637
  r0 = r1
1606
1638
  else
1607
1639
  r2 = _nt_lte
1608
1640
  if r2
1641
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1609
1642
  r0 = r2
1610
1643
  else
1611
1644
  r3 = _nt_gt
1612
1645
  if r3
1646
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1613
1647
  r0 = r3
1614
1648
  else
1615
1649
  r4 = _nt_gte
1616
1650
  if r4
1651
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
1617
1652
  r0 = r4
1618
1653
  else
1619
1654
  r5 = _nt_neq
1620
1655
  if r5
1656
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
1621
1657
  r0 = r5
1622
1658
  else
1623
1659
  r6 = _nt_eq
1624
1660
  if r6
1661
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
1625
1662
  r0 = r6
1626
1663
  else
1627
1664
  @index = i0
@@ -1649,16 +1686,16 @@ module Q
1649
1686
  if node_cache[:lt].has_key?(index)
1650
1687
  cached = node_cache[:lt][index]
1651
1688
  if cached
1652
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1689
+ node_cache[:lt][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1653
1690
  @index = cached.interval.end
1654
1691
  end
1655
1692
  return cached
1656
1693
  end
1657
1694
 
1658
- if has_terminal?('<', false, index)
1659
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1695
+ if (match_len = has_terminal?('<', false, index))
1696
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1660
1697
  r0.extend(Lt0)
1661
- @index += 1
1698
+ @index += match_len
1662
1699
  else
1663
1700
  terminal_parse_failure('<')
1664
1701
  r0 = nil
@@ -1671,7 +1708,7 @@ module Q
1671
1708
 
1672
1709
  module Gt0
1673
1710
  def apply scope, a, b
1674
- a.eval(scope) < b.eval(scope)
1711
+ a.eval(scope) > b.eval(scope)
1675
1712
  end
1676
1713
  end
1677
1714
 
@@ -1680,16 +1717,16 @@ module Q
1680
1717
  if node_cache[:gt].has_key?(index)
1681
1718
  cached = node_cache[:gt][index]
1682
1719
  if cached
1683
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1720
+ node_cache[:gt][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1684
1721
  @index = cached.interval.end
1685
1722
  end
1686
1723
  return cached
1687
1724
  end
1688
1725
 
1689
- if has_terminal?('>', false, index)
1690
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1726
+ if (match_len = has_terminal?('>', false, index))
1727
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1691
1728
  r0.extend(Gt0)
1692
- @index += 1
1729
+ @index += match_len
1693
1730
  else
1694
1731
  terminal_parse_failure('>')
1695
1732
  r0 = nil
@@ -1711,16 +1748,16 @@ module Q
1711
1748
  if node_cache[:lte].has_key?(index)
1712
1749
  cached = node_cache[:lte][index]
1713
1750
  if cached
1714
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1751
+ node_cache[:lte][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1715
1752
  @index = cached.interval.end
1716
1753
  end
1717
1754
  return cached
1718
1755
  end
1719
1756
 
1720
- if has_terminal?('<=', false, index)
1721
- r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
1757
+ if (match_len = has_terminal?('<=', false, index))
1758
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1722
1759
  r0.extend(Lte0)
1723
- @index += 2
1760
+ @index += match_len
1724
1761
  else
1725
1762
  terminal_parse_failure('<=')
1726
1763
  r0 = nil
@@ -1742,16 +1779,16 @@ module Q
1742
1779
  if node_cache[:gte].has_key?(index)
1743
1780
  cached = node_cache[:gte][index]
1744
1781
  if cached
1745
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1782
+ node_cache[:gte][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1746
1783
  @index = cached.interval.end
1747
1784
  end
1748
1785
  return cached
1749
1786
  end
1750
1787
 
1751
- if has_terminal?('>=', false, index)
1752
- r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
1788
+ if (match_len = has_terminal?('>=', false, index))
1789
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1753
1790
  r0.extend(Gte0)
1754
- @index += 2
1791
+ @index += match_len
1755
1792
  else
1756
1793
  terminal_parse_failure('>=')
1757
1794
  r0 = nil
@@ -1773,16 +1810,16 @@ module Q
1773
1810
  if node_cache[:eq].has_key?(index)
1774
1811
  cached = node_cache[:eq][index]
1775
1812
  if cached
1776
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1813
+ node_cache[:eq][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1777
1814
  @index = cached.interval.end
1778
1815
  end
1779
1816
  return cached
1780
1817
  end
1781
1818
 
1782
- if has_terminal?('=', false, index)
1783
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1819
+ if (match_len = has_terminal?('=', false, index))
1820
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1784
1821
  r0.extend(Eq0)
1785
- @index += 1
1822
+ @index += match_len
1786
1823
  else
1787
1824
  terminal_parse_failure('=')
1788
1825
  r0 = nil
@@ -1804,16 +1841,16 @@ module Q
1804
1841
  if node_cache[:neq].has_key?(index)
1805
1842
  cached = node_cache[:neq][index]
1806
1843
  if cached
1807
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1844
+ node_cache[:neq][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1808
1845
  @index = cached.interval.end
1809
1846
  end
1810
1847
  return cached
1811
1848
  end
1812
1849
 
1813
- if has_terminal?('!=', false, index)
1814
- r0 = instantiate_node(SyntaxNode,input, index...(index + 2))
1850
+ if (match_len = has_terminal?('!=', false, index))
1851
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1815
1852
  r0.extend(Neq0)
1816
- @index += 2
1853
+ @index += match_len
1817
1854
  else
1818
1855
  terminal_parse_failure('!=')
1819
1856
  r0 = nil
@@ -1835,16 +1872,16 @@ module Q
1835
1872
  if node_cache[:plus].has_key?(index)
1836
1873
  cached = node_cache[:plus][index]
1837
1874
  if cached
1838
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1875
+ node_cache[:plus][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1839
1876
  @index = cached.interval.end
1840
1877
  end
1841
1878
  return cached
1842
1879
  end
1843
1880
 
1844
- if has_terminal?('+', false, index)
1845
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1881
+ if (match_len = has_terminal?('+', false, index))
1882
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1846
1883
  r0.extend(Plus0)
1847
- @index += 1
1884
+ @index += match_len
1848
1885
  else
1849
1886
  terminal_parse_failure('+')
1850
1887
  r0 = nil
@@ -1866,16 +1903,16 @@ module Q
1866
1903
  if node_cache[:minus].has_key?(index)
1867
1904
  cached = node_cache[:minus][index]
1868
1905
  if cached
1869
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1906
+ node_cache[:minus][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1870
1907
  @index = cached.interval.end
1871
1908
  end
1872
1909
  return cached
1873
1910
  end
1874
1911
 
1875
- if has_terminal?('-', false, index)
1876
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1912
+ if (match_len = has_terminal?('-', false, index))
1913
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1877
1914
  r0.extend(Minus0)
1878
- @index += 1
1915
+ @index += match_len
1879
1916
  else
1880
1917
  terminal_parse_failure('-')
1881
1918
  r0 = nil
@@ -1897,16 +1934,16 @@ module Q
1897
1934
  if node_cache[:star].has_key?(index)
1898
1935
  cached = node_cache[:star][index]
1899
1936
  if cached
1900
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1937
+ node_cache[:star][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1901
1938
  @index = cached.interval.end
1902
1939
  end
1903
1940
  return cached
1904
1941
  end
1905
1942
 
1906
- if has_terminal?('*', false, index)
1907
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1943
+ if (match_len = has_terminal?('*', false, index))
1944
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1908
1945
  r0.extend(Star0)
1909
- @index += 1
1946
+ @index += match_len
1910
1947
  else
1911
1948
  terminal_parse_failure('*')
1912
1949
  r0 = nil
@@ -1928,16 +1965,16 @@ module Q
1928
1965
  if node_cache[:slash].has_key?(index)
1929
1966
  cached = node_cache[:slash][index]
1930
1967
  if cached
1931
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1968
+ node_cache[:slash][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1932
1969
  @index = cached.interval.end
1933
1970
  end
1934
1971
  return cached
1935
1972
  end
1936
1973
 
1937
- if has_terminal?('/', false, index)
1938
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
1974
+ if (match_len = has_terminal?('/', false, index))
1975
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
1939
1976
  r0.extend(Slash0)
1940
- @index += 1
1977
+ @index += match_len
1941
1978
  else
1942
1979
  terminal_parse_failure('/')
1943
1980
  r0 = nil
@@ -1953,7 +1990,7 @@ module Q
1953
1990
  if node_cache[:value].has_key?(index)
1954
1991
  cached = node_cache[:value][index]
1955
1992
  if cached
1956
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1993
+ node_cache[:value][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1957
1994
  @index = cached.interval.end
1958
1995
  end
1959
1996
  return cached
@@ -1962,22 +1999,27 @@ module Q
1962
1999
  i0 = index
1963
2000
  r1 = _nt_number
1964
2001
  if r1
2002
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
1965
2003
  r0 = r1
1966
2004
  else
1967
2005
  r2 = _nt_string
1968
2006
  if r2
2007
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
1969
2008
  r0 = r2
1970
2009
  else
1971
2010
  r3 = _nt_truth
1972
2011
  if r3
2012
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
1973
2013
  r0 = r3
1974
2014
  else
1975
2015
  r4 = _nt_lie
1976
2016
  if r4
2017
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
1977
2018
  r0 = r4
1978
2019
  else
1979
2020
  r5 = _nt_nil
1980
2021
  if r5
2022
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
1981
2023
  r0 = r5
1982
2024
  else
1983
2025
  @index = i0
@@ -2004,16 +2046,16 @@ module Q
2004
2046
  if node_cache[:truth].has_key?(index)
2005
2047
  cached = node_cache[:truth][index]
2006
2048
  if cached
2007
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2049
+ node_cache[:truth][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2008
2050
  @index = cached.interval.end
2009
2051
  end
2010
2052
  return cached
2011
2053
  end
2012
2054
 
2013
- if has_terminal?('true', false, index)
2014
- r0 = instantiate_node(SyntaxNode,input, index...(index + 4))
2055
+ if (match_len = has_terminal?('true', false, index))
2056
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2015
2057
  r0.extend(Truth0)
2016
- @index += 4
2058
+ @index += match_len
2017
2059
  else
2018
2060
  terminal_parse_failure('true')
2019
2061
  r0 = nil
@@ -2035,16 +2077,16 @@ module Q
2035
2077
  if node_cache[:lie].has_key?(index)
2036
2078
  cached = node_cache[:lie][index]
2037
2079
  if cached
2038
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2080
+ node_cache[:lie][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2039
2081
  @index = cached.interval.end
2040
2082
  end
2041
2083
  return cached
2042
2084
  end
2043
2085
 
2044
- if has_terminal?('false', false, index)
2045
- r0 = instantiate_node(SyntaxNode,input, index...(index + 5))
2086
+ if (match_len = has_terminal?('false', false, index))
2087
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2046
2088
  r0.extend(Lie0)
2047
- @index += 5
2089
+ @index += match_len
2048
2090
  else
2049
2091
  terminal_parse_failure('false')
2050
2092
  r0 = nil
@@ -2066,16 +2108,16 @@ module Q
2066
2108
  if node_cache[:nil].has_key?(index)
2067
2109
  cached = node_cache[:nil][index]
2068
2110
  if cached
2069
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2111
+ node_cache[:nil][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2070
2112
  @index = cached.interval.end
2071
2113
  end
2072
2114
  return cached
2073
2115
  end
2074
2116
 
2075
- if has_terminal?('nil', false, index)
2076
- r0 = instantiate_node(SyntaxNode,input, index...(index + 3))
2117
+ if (match_len = has_terminal?('nil', false, index))
2118
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2077
2119
  r0.extend(Nil0)
2078
- @index += 3
2120
+ @index += match_len
2079
2121
  else
2080
2122
  terminal_parse_failure('nil')
2081
2123
  r0 = nil
@@ -2091,7 +2133,7 @@ module Q
2091
2133
  if node_cache[:string].has_key?(index)
2092
2134
  cached = node_cache[:string][index]
2093
2135
  if cached
2094
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2136
+ node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2095
2137
  @index = cached.interval.end
2096
2138
  end
2097
2139
  return cached
@@ -2100,10 +2142,12 @@ module Q
2100
2142
  i0 = index
2101
2143
  r1 = _nt_single_quote_string
2102
2144
  if r1
2145
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2103
2146
  r0 = r1
2104
2147
  else
2105
2148
  r2 = _nt_double_quote_string
2106
2149
  if r2
2150
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2107
2151
  r0 = r2
2108
2152
  else
2109
2153
  @index = i0
@@ -2137,16 +2181,16 @@ module Q
2137
2181
  if node_cache[:single_quote_string].has_key?(index)
2138
2182
  cached = node_cache[:single_quote_string][index]
2139
2183
  if cached
2140
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2184
+ node_cache[:single_quote_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2141
2185
  @index = cached.interval.end
2142
2186
  end
2143
2187
  return cached
2144
2188
  end
2145
2189
 
2146
2190
  i0, s0 = index, []
2147
- if has_terminal?("'", false, index)
2148
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2149
- @index += 1
2191
+ if (match_len = has_terminal?("'", false, index))
2192
+ r1 = true
2193
+ @index += match_len
2150
2194
  else
2151
2195
  terminal_parse_failure("'")
2152
2196
  r1 = nil
@@ -2156,21 +2200,22 @@ module Q
2156
2200
  s2, i2 = [], index
2157
2201
  loop do
2158
2202
  i3 = index
2159
- if has_terminal?("\\'", false, index)
2160
- r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
2161
- @index += 2
2203
+ if (match_len = has_terminal?("\\'", false, index))
2204
+ r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2205
+ @index += match_len
2162
2206
  else
2163
2207
  terminal_parse_failure("\\'")
2164
2208
  r4 = nil
2165
2209
  end
2166
2210
  if r4
2211
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
2167
2212
  r3 = r4
2168
2213
  else
2169
2214
  i5, s5 = index, []
2170
2215
  i6 = index
2171
- if has_terminal?("'", false, index)
2172
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2173
- @index += 1
2216
+ if (match_len = has_terminal?("'", false, index))
2217
+ r7 = true
2218
+ @index += match_len
2174
2219
  else
2175
2220
  terminal_parse_failure("'")
2176
2221
  r7 = nil
@@ -2184,7 +2229,7 @@ module Q
2184
2229
  s5 << r6
2185
2230
  if r6
2186
2231
  if index < input_length
2187
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2232
+ r8 = true
2188
2233
  @index += 1
2189
2234
  else
2190
2235
  terminal_parse_failure("any character")
@@ -2200,6 +2245,7 @@ module Q
2200
2245
  r5 = nil
2201
2246
  end
2202
2247
  if r5
2248
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
2203
2249
  r3 = r5
2204
2250
  else
2205
2251
  @index = i3
@@ -2215,9 +2261,9 @@ module Q
2215
2261
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2216
2262
  s0 << r2
2217
2263
  if r2
2218
- if has_terminal?("'", false, index)
2219
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2220
- @index += 1
2264
+ if (match_len = has_terminal?("'", false, index))
2265
+ r9 = true
2266
+ @index += match_len
2221
2267
  else
2222
2268
  terminal_parse_failure("'")
2223
2269
  r9 = nil
@@ -2260,16 +2306,16 @@ module Q
2260
2306
  if node_cache[:double_quote_string].has_key?(index)
2261
2307
  cached = node_cache[:double_quote_string][index]
2262
2308
  if cached
2263
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2309
+ node_cache[:double_quote_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2264
2310
  @index = cached.interval.end
2265
2311
  end
2266
2312
  return cached
2267
2313
  end
2268
2314
 
2269
2315
  i0, s0 = index, []
2270
- if has_terminal?('"', false, index)
2271
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2272
- @index += 1
2316
+ if (match_len = has_terminal?('"', false, index))
2317
+ r1 = true
2318
+ @index += match_len
2273
2319
  else
2274
2320
  terminal_parse_failure('"')
2275
2321
  r1 = nil
@@ -2279,21 +2325,22 @@ module Q
2279
2325
  s2, i2 = [], index
2280
2326
  loop do
2281
2327
  i3 = index
2282
- if has_terminal?('\"', false, index)
2283
- r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
2284
- @index += 2
2328
+ if (match_len = has_terminal?('\"', false, index))
2329
+ r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2330
+ @index += match_len
2285
2331
  else
2286
2332
  terminal_parse_failure('\"')
2287
2333
  r4 = nil
2288
2334
  end
2289
2335
  if r4
2336
+ r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
2290
2337
  r3 = r4
2291
2338
  else
2292
2339
  i5, s5 = index, []
2293
2340
  i6 = index
2294
- if has_terminal?('"', false, index)
2295
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2296
- @index += 1
2341
+ if (match_len = has_terminal?('"', false, index))
2342
+ r7 = true
2343
+ @index += match_len
2297
2344
  else
2298
2345
  terminal_parse_failure('"')
2299
2346
  r7 = nil
@@ -2307,7 +2354,7 @@ module Q
2307
2354
  s5 << r6
2308
2355
  if r6
2309
2356
  if index < input_length
2310
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2357
+ r8 = true
2311
2358
  @index += 1
2312
2359
  else
2313
2360
  terminal_parse_failure("any character")
@@ -2323,6 +2370,7 @@ module Q
2323
2370
  r5 = nil
2324
2371
  end
2325
2372
  if r5
2373
+ r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
2326
2374
  r3 = r5
2327
2375
  else
2328
2376
  @index = i3
@@ -2338,9 +2386,9 @@ module Q
2338
2386
  r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2339
2387
  s0 << r2
2340
2388
  if r2
2341
- if has_terminal?('"', false, index)
2342
- r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2343
- @index += 1
2389
+ if (match_len = has_terminal?('"', false, index))
2390
+ r9 = true
2391
+ @index += match_len
2344
2392
  else
2345
2393
  terminal_parse_failure('"')
2346
2394
  r9 = nil
@@ -2384,7 +2432,7 @@ module Q
2384
2432
  if node_cache[:number].has_key?(index)
2385
2433
  cached = node_cache[:number][index]
2386
2434
  if cached
2387
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2435
+ node_cache[:number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2388
2436
  @index = cached.interval.end
2389
2437
  end
2390
2438
  return cached
@@ -2393,10 +2441,11 @@ module Q
2393
2441
  i0, s0 = index, []
2394
2442
  s1, i1 = [], index
2395
2443
  loop do
2396
- if has_terminal?('\G[0-9]', true, index)
2444
+ if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
2397
2445
  r2 = true
2398
2446
  @index += 1
2399
2447
  else
2448
+ terminal_parse_failure('[0-9]')
2400
2449
  r2 = nil
2401
2450
  end
2402
2451
  if r2
@@ -2413,9 +2462,9 @@ module Q
2413
2462
  end
2414
2463
  s0 << r1
2415
2464
  if r1
2416
- if has_terminal?('.', false, index)
2417
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
2418
- @index += 1
2465
+ if (match_len = has_terminal?('.', false, index))
2466
+ r4 = true
2467
+ @index += match_len
2419
2468
  else
2420
2469
  terminal_parse_failure('.')
2421
2470
  r4 = nil
@@ -2429,10 +2478,11 @@ module Q
2429
2478
  if r3
2430
2479
  s5, i5 = [], index
2431
2480
  loop do
2432
- if has_terminal?('\G[0-9]', true, index)
2481
+ if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
2433
2482
  r6 = true
2434
2483
  @index += 1
2435
2484
  else
2485
+ terminal_parse_failure('[0-9]')
2436
2486
  r6 = nil
2437
2487
  end
2438
2488
  if r6
@@ -2473,27 +2523,29 @@ module Q
2473
2523
  if node_cache[:identifier].has_key?(index)
2474
2524
  cached = node_cache[:identifier][index]
2475
2525
  if cached
2476
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2526
+ node_cache[:identifier][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2477
2527
  @index = cached.interval.end
2478
2528
  end
2479
2529
  return cached
2480
2530
  end
2481
2531
 
2482
2532
  i0, s0 = index, []
2483
- if has_terminal?('\G[a-zA-Z_]', true, index)
2533
+ if has_terminal?(@regexps[gr = '\A[a-zA-Z_]'] ||= Regexp.new(gr), :regexp, index)
2484
2534
  r1 = true
2485
2535
  @index += 1
2486
2536
  else
2537
+ terminal_parse_failure('[a-zA-Z_]')
2487
2538
  r1 = nil
2488
2539
  end
2489
2540
  s0 << r1
2490
2541
  if r1
2491
2542
  s2, i2 = [], index
2492
2543
  loop do
2493
- if has_terminal?('\G[a-zA-Z0-9_]', true, index)
2544
+ if has_terminal?(@regexps[gr = '\A[a-zA-Z0-9_]'] ||= Regexp.new(gr), :regexp, index)
2494
2545
  r3 = true
2495
2546
  @index += 1
2496
2547
  else
2548
+ terminal_parse_failure('[a-zA-Z0-9_]')
2497
2549
  r3 = nil
2498
2550
  end
2499
2551
  if r3
@@ -2506,24 +2558,26 @@ module Q
2506
2558
  s0 << r2
2507
2559
  if r2
2508
2560
  i5 = index
2509
- if has_terminal?('?', false, index)
2510
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
2511
- @index += 1
2561
+ if (match_len = has_terminal?('?', false, index))
2562
+ r6 = true
2563
+ @index += match_len
2512
2564
  else
2513
2565
  terminal_parse_failure('?')
2514
2566
  r6 = nil
2515
2567
  end
2516
2568
  if r6
2569
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
2517
2570
  r5 = r6
2518
2571
  else
2519
- if has_terminal?('!', false, index)
2520
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2521
- @index += 1
2572
+ if (match_len = has_terminal?('!', false, index))
2573
+ r7 = true
2574
+ @index += match_len
2522
2575
  else
2523
2576
  terminal_parse_failure('!')
2524
2577
  r7 = nil
2525
2578
  end
2526
2579
  if r7
2580
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
2527
2581
  r5 = r7
2528
2582
  else
2529
2583
  @index = i5
@@ -2563,16 +2617,16 @@ module Q
2563
2617
  if node_cache[:self].has_key?(index)
2564
2618
  cached = node_cache[:self][index]
2565
2619
  if cached
2566
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2620
+ node_cache[:self][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2567
2621
  @index = cached.interval.end
2568
2622
  end
2569
2623
  return cached
2570
2624
  end
2571
2625
 
2572
- if has_terminal?('@', false, index)
2573
- r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
2626
+ if (match_len = has_terminal?('@', false, index))
2627
+ r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
2574
2628
  r0.extend(Self0)
2575
- @index += 1
2629
+ @index += match_len
2576
2630
  else
2577
2631
  terminal_parse_failure('@')
2578
2632
  r0 = nil
@@ -2600,16 +2654,16 @@ module Q
2600
2654
  if node_cache[:comment].has_key?(index)
2601
2655
  cached = node_cache[:comment][index]
2602
2656
  if cached
2603
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2657
+ node_cache[:comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2604
2658
  @index = cached.interval.end
2605
2659
  end
2606
2660
  return cached
2607
2661
  end
2608
2662
 
2609
2663
  i0, s0 = index, []
2610
- if has_terminal?('#', false, index)
2611
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2612
- @index += 1
2664
+ if (match_len = has_terminal?('#', false, index))
2665
+ r1 = true
2666
+ @index += match_len
2613
2667
  else
2614
2668
  terminal_parse_failure('#')
2615
2669
  r1 = nil
@@ -2621,24 +2675,26 @@ module Q
2621
2675
  i3, s3 = index, []
2622
2676
  i4 = index
2623
2677
  i5 = index
2624
- if has_terminal?("\n", false, index)
2625
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
2626
- @index += 1
2678
+ if (match_len = has_terminal?("\n", false, index))
2679
+ r6 = true
2680
+ @index += match_len
2627
2681
  else
2628
2682
  terminal_parse_failure("\n")
2629
2683
  r6 = nil
2630
2684
  end
2631
2685
  if r6
2686
+ r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
2632
2687
  r5 = r6
2633
2688
  else
2634
- if has_terminal?("\r", false, index)
2635
- r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2636
- @index += 1
2689
+ if (match_len = has_terminal?("\r", false, index))
2690
+ r7 = true
2691
+ @index += match_len
2637
2692
  else
2638
2693
  terminal_parse_failure("\r")
2639
2694
  r7 = nil
2640
2695
  end
2641
2696
  if r7
2697
+ r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
2642
2698
  r5 = r7
2643
2699
  else
2644
2700
  @index = i5
@@ -2654,7 +2710,7 @@ module Q
2654
2710
  s3 << r4
2655
2711
  if r4
2656
2712
  if index < input_length
2657
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2713
+ r8 = true
2658
2714
  @index += 1
2659
2715
  else
2660
2716
  terminal_parse_failure("any character")
@@ -2681,24 +2737,26 @@ module Q
2681
2737
  s9, i9 = [], index
2682
2738
  loop do
2683
2739
  i10 = index
2684
- if has_terminal?("\n", false, index)
2685
- r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
2686
- @index += 1
2740
+ if (match_len = has_terminal?("\n", false, index))
2741
+ r11 = true
2742
+ @index += match_len
2687
2743
  else
2688
2744
  terminal_parse_failure("\n")
2689
2745
  r11 = nil
2690
2746
  end
2691
2747
  if r11
2748
+ r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
2692
2749
  r10 = r11
2693
2750
  else
2694
- if has_terminal?("\r", false, index)
2695
- r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
2696
- @index += 1
2751
+ if (match_len = has_terminal?("\r", false, index))
2752
+ r12 = true
2753
+ @index += match_len
2697
2754
  else
2698
2755
  terminal_parse_failure("\r")
2699
2756
  r12 = nil
2700
2757
  end
2701
2758
  if r12
2759
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
2702
2760
  r10 = r12
2703
2761
  else
2704
2762
  @index = i10
@@ -2739,41 +2797,44 @@ module Q
2739
2797
  if node_cache[:ws].has_key?(index)
2740
2798
  cached = node_cache[:ws][index]
2741
2799
  if cached
2742
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2800
+ node_cache[:ws][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2743
2801
  @index = cached.interval.end
2744
2802
  end
2745
2803
  return cached
2746
2804
  end
2747
2805
 
2748
2806
  i0 = index
2749
- if has_terminal?(' ', false, index)
2750
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2751
- @index += 1
2807
+ if (match_len = has_terminal?(' ', false, index))
2808
+ r1 = true
2809
+ @index += match_len
2752
2810
  else
2753
2811
  terminal_parse_failure(' ')
2754
2812
  r1 = nil
2755
2813
  end
2756
2814
  if r1
2815
+ r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
2757
2816
  r0 = r1
2758
2817
  else
2759
- if has_terminal?("\n", false, index)
2760
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
2761
- @index += 1
2818
+ if (match_len = has_terminal?("\n", false, index))
2819
+ r2 = true
2820
+ @index += match_len
2762
2821
  else
2763
2822
  terminal_parse_failure("\n")
2764
2823
  r2 = nil
2765
2824
  end
2766
2825
  if r2
2826
+ r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
2767
2827
  r0 = r2
2768
2828
  else
2769
- if has_terminal?("\r", false, index)
2770
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
2771
- @index += 1
2829
+ if (match_len = has_terminal?("\r", false, index))
2830
+ r3 = true
2831
+ @index += match_len
2772
2832
  else
2773
2833
  terminal_parse_failure("\r")
2774
2834
  r3 = nil
2775
2835
  end
2776
2836
  if r3
2837
+ r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
2777
2838
  r0 = r3
2778
2839
  else
2779
2840
  @index = i0