sportdb-parser 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f227e5b41ea4ddd20904f5a582756eca266ce645d4a0c0c520b0297b996fbd80
4
- data.tar.gz: 0e61ae4e7c8057825d41cf3e17baddd14f6413d19457ef390ff89d222b186e2d
3
+ metadata.gz: 17e2ccd1472c3f56b5c1f4f4374e66de6b5297c67a5a0fa86206489ac560a00e
4
+ data.tar.gz: 1c6de22e1c9dda2cc2a0b75654737882b7ce4c7e9f191b61889887c844fc35b9
5
5
  SHA512:
6
- metadata.gz: e52ba0276a0e9d656b051dc23ad9237d76fa0b6f699627cfcc0d7b55ac87b990ac267065139e73d5bf4abc446a6d87dc0362c7f65d0c9134610f47f71a524d3e
7
- data.tar.gz: 57b9b5a2218054ce8a7f698def21e931c90bc1737bfc364fa8e21c948f4bdc6090eff86c633f24f41687c25a30dce15483dfda63a7f175ddd019a8b908a6cac4
6
+ metadata.gz: ac121460004ce5f4287668ea8753feee5729124a265474bfcf065775ffd099a5f867109fc16b2d8d46b6ee7a327bdc8b4c14539f22d1ef43ee285f457097eae0
7
+ data.tar.gz: 340afd868ceceeaa31532ea89251d5bfa2874f649933a18124bb4a5ba28e837c3a59284144d376f17c125ca93c12436cc473c7fda94a3b72866960fdc2c9cba8
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.7.0
1
+ ### 0.7.1
2
2
  ### 0.0.1 / 2024-07-12
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -8,6 +8,7 @@ lib/sportdb/parser/lexer.rb
8
8
  lib/sportdb/parser/lexer_buffer.rb
9
9
  lib/sportdb/parser/lexer_tty.rb
10
10
  lib/sportdb/parser/parser.rb
11
+ lib/sportdb/parser/parser_runtime.rb
11
12
  lib/sportdb/parser/racc_parser.rb
12
13
  lib/sportdb/parser/racc_tree.rb
13
14
  lib/sportdb/parser/token-date.rb
data/Rakefile CHANGED
@@ -22,7 +22,6 @@ Hoe.spec 'sportdb-parser' do
22
22
 
23
23
  self.extra_deps = [
24
24
  ['cocos', '>= 0.4.1'],
25
- ['racc'], ## maybe inline runtime later if possible - why? why not?
26
25
  ]
27
26
 
28
27
  self.spec_extras = {
@@ -4,7 +4,9 @@
4
4
  # from Racc grammar file "parser.y".
5
5
  #
6
6
 
7
- require 'racc/parser.rb'
7
+ ## require 'racc/parser.rb'
8
+
9
+
8
10
  class RaccMatchParser < Racc::Parser
9
11
  ##### State transition tables begin ###
10
12
 
@@ -810,7 +812,7 @@ Racc_debug_parser = false
810
812
 
811
813
  module_eval(<<'.,.,', 'parser.y', 18)
812
814
  def _reduce_1(val, _values, result)
813
-
815
+
814
816
  result
815
817
  end
816
818
  .,.,
@@ -857,7 +859,7 @@ module_eval(<<'.,.,', 'parser.y', 18)
857
859
 
858
860
  module_eval(<<'.,.,', 'parser.y', 57)
859
861
  def _reduce_22(val, _values, result)
860
- trace( "REDUCE BLANK" )
862
+ trace( "REDUCE BLANK" )
861
863
  @tree << BlankLine.new
862
864
 
863
865
  result
@@ -880,7 +882,7 @@ module_eval(<<'.,.,', 'parser.y', 67)
880
882
  def _reduce_29(val, _values, result)
881
883
  puts "!! skipping invalid content (trying to recover from parse error):"
882
884
  pp val[0]
883
- ## note - do NOT report recover errors for now
885
+ ## note - do NOT report recover errors for now
884
886
  ## @errors << "parser error (recover) - skipping #{val[0].pretty_inspect}"
885
887
 
886
888
  result
@@ -973,7 +975,7 @@ module_eval(<<'.,.,', 'parser.y', 108)
973
975
  module_eval(<<'.,.,', 'parser.y', 113)
974
976
  def _reduce_43(val, _values, result)
975
977
  result = val
976
- ## e.g. val is ["Austria"]
978
+ ## e.g. val is ["Austria"]
977
979
 
978
980
  result
979
981
  end
@@ -1079,7 +1081,7 @@ module_eval(<<'.,.,', 'parser.y', 176)
1079
1081
 
1080
1082
  module_eval(<<'.,.,', 'parser.y', 189)
1081
1083
  def _reduce_61(val, _values, result)
1082
- @tree << DateHeader.new( **val[0] )
1084
+ @tree << DateHeader.new( **val[0] )
1083
1085
 
1084
1086
  result
1085
1087
  end
@@ -1087,8 +1089,8 @@ module_eval(<<'.,.,', 'parser.y', 189)
1087
1089
 
1088
1090
  module_eval(<<'.,.,', 'parser.y', 195)
1089
1091
  def _reduce_62(val, _values, result)
1090
- kwargs = val[0][1]
1091
- @tree << DateHeaderLegs.new( **kwargs )
1092
+ kwargs = val[0][1]
1093
+ @tree << DateHeaderLegs.new( **kwargs )
1092
1094
 
1093
1095
  result
1094
1096
  end
@@ -1105,9 +1107,9 @@ module_eval(<<'.,.,', 'parser.y', 195)
1105
1107
  module_eval(<<'.,.,', 'parser.y', 215)
1106
1108
  def _reduce_67(val, _values, result)
1107
1109
  ## note - header flag (header: true)
1108
- ## used downstream for scope / e.g. DateHeader merge/inheritance or such
1110
+ ## used downstream for scope / e.g. DateHeader merge/inheritance or such
1109
1111
  kwargs = { header: true }.merge( val[0], val[2] )
1110
- @tree << MatchLine.new( **kwargs )
1112
+ @tree << MatchLine.new( **kwargs )
1111
1113
 
1112
1114
  result
1113
1115
  end
@@ -1147,7 +1149,7 @@ module_eval(<<'.,.,', 'parser.y', 243)
1147
1149
 
1148
1150
  module_eval(<<'.,.,', 'parser.y', 256)
1149
1151
  def _reduce_73(val, _values, result)
1150
- result = {}.merge( val[0], val[1], val[2] )
1152
+ result = {}.merge( val[0], val[1], val[2] )
1151
1153
 
1152
1154
  result
1153
1155
  end
@@ -1155,7 +1157,7 @@ module_eval(<<'.,.,', 'parser.y', 256)
1155
1157
 
1156
1158
  module_eval(<<'.,.,', 'parser.y', 260)
1157
1159
  def _reduce_74(val, _values, result)
1158
- result = {}.merge( val[0], val[1] )
1160
+ result = {}.merge( val[0], val[1] )
1159
1161
 
1160
1162
  result
1161
1163
  end
@@ -1189,7 +1191,7 @@ module_eval(<<'.,.,', 'parser.y', 280)
1189
1191
  module_eval(<<'.,.,', 'parser.y', 292)
1190
1192
  def _reduce_79(val, _values, result)
1191
1193
  kwargs = { score: val[1][1] }.merge( val[0] )
1192
- @tree << MatchLineLegs.new( **kwargs )
1194
+ @tree << MatchLineLegs.new( **kwargs )
1193
1195
 
1194
1196
  result
1195
1197
  end
@@ -1248,7 +1250,7 @@ module_eval(<<'.,.,', 'parser.y', 322)
1248
1250
  module_eval(<<'.,.,', 'parser.y', 328)
1249
1251
  def _reduce_86(val, _values, result)
1250
1252
  kwargs = {}.merge( val[0], val[1] )
1251
- @tree << MatchLineBye.new( **kwargs )
1253
+ @tree << MatchLineBye.new( **kwargs )
1252
1254
 
1253
1255
  result
1254
1256
  end
@@ -1269,7 +1271,7 @@ module_eval(<<'.,.,', 'parser.y', 344)
1269
1271
  @tree << MatchLine.new( **kwargs )
1270
1272
 
1271
1273
  kwargs = val[2]
1272
- @tree << GoalLine.new( **kwargs )
1274
+ @tree << GoalLine.new( **kwargs )
1273
1275
 
1274
1276
  result
1275
1277
  end
@@ -1278,7 +1280,7 @@ module_eval(<<'.,.,', 'parser.y', 344)
1278
1280
  module_eval(<<'.,.,', 'parser.y', 355)
1279
1281
  def _reduce_89(val, _values, result)
1280
1282
  kwargs = {}.merge( val[0] )
1281
- @tree << MatchLine.new( **kwargs )
1283
+ @tree << MatchLine.new( **kwargs )
1282
1284
 
1283
1285
  result
1284
1286
  end
@@ -1311,7 +1313,7 @@ module_eval(<<'.,.,', 'parser.y', 377)
1311
1313
  def _reduce_93(val, _values, result)
1312
1314
  puts "status_line:"
1313
1315
  pp val[0]
1314
- result = val[0][1]
1316
+ result = val[0][1]
1315
1317
 
1316
1318
  result
1317
1319
  end
@@ -1323,22 +1325,22 @@ module_eval(<<'.,.,', 'parser.y', 390)
1323
1325
  ## pp val[0]
1324
1326
  ## pp val[2]
1325
1327
 
1326
- ## assume ht/ft
1328
+ ## assume ht/ft
1327
1329
  ## or let's use [[0,1],[1,2]] - why? why not?
1328
1330
  score_team1 = val[0][1][:score]
1329
1331
  score_team2 = val[2][1][:score]
1330
1332
 
1331
-
1333
+
1332
1334
  score = [[score_team1[0], score_team2[0]],
1333
- [score_team1[1], score_team2[1]]]
1335
+ [score_team1[1], score_team2[1]]]
1334
1336
 
1335
- result = { team1: val[0][1][:team],
1337
+ result = { team1: val[0][1][:team],
1336
1338
  team2: val[2][1][:team],
1337
1339
  score: score
1338
1340
  }
1339
1341
 
1340
1342
  ## puts " result:"
1341
- ## pp result
1343
+ ## pp result
1342
1344
 
1343
1345
  result
1344
1346
  end
@@ -1351,15 +1353,15 @@ module_eval(<<'.,.,', 'parser.y', 413)
1351
1353
  ## or let's use [[0,1],[1,2]] - why? why not?
1352
1354
  score_team1 = val[0][1][:score]
1353
1355
  score_team2 = val[2][1][:score]
1354
-
1356
+
1355
1357
  score = { '_': [score_team1[0], score_team2[0]],
1356
- pen: [score_team1[1], score_team2[1]]
1357
- }
1358
+ pen: [score_team1[1], score_team2[1]]
1359
+ }
1358
1360
 
1359
- result = { team1: val[0][1][:team],
1361
+ result = { team1: val[0][1][:team],
1360
1362
  team2: val[2][1][:team],
1361
1363
  score: score
1362
- }
1364
+ }
1363
1365
 
1364
1366
  result
1365
1367
  end
@@ -1369,10 +1371,10 @@ module_eval(<<'.,.,', 'parser.y', 430)
1369
1371
  def _reduce_96(val, _values, result)
1370
1372
  score_team1 = val[0][1][:score]
1371
1373
  score_team2 = val[2][1][:score]
1372
-
1373
- score = [score_team1, score_team2]
1374
1374
 
1375
- result = { team1: val[0][1][:team],
1375
+ score = [score_team1, score_team2]
1376
+
1377
+ result = { team1: val[0][1][:team],
1376
1378
  team2: val[2][1][:team],
1377
1379
  score: score
1378
1380
  }
@@ -1383,7 +1385,7 @@ module_eval(<<'.,.,', 'parser.y', 430)
1383
1385
 
1384
1386
  module_eval(<<'.,.,', 'parser.y', 442)
1385
1387
  def _reduce_97(val, _values, result)
1386
- result = { team1: val[0],
1388
+ result = { team1: val[0],
1387
1389
  team2: val[3],
1388
1390
  score: [val[1], val[4]]
1389
1391
  }
@@ -1394,15 +1396,15 @@ module_eval(<<'.,.,', 'parser.y', 442)
1394
1396
 
1395
1397
  module_eval(<<'.,.,', 'parser.y', 456)
1396
1398
  def _reduce_98(val, _values, result)
1397
- ## assume ht/ft
1399
+ ## assume ht/ft
1398
1400
  ## or let's use [[0,1],[1,2]] - why? why not?
1399
1401
  score_team1 = val[0][1][:score]
1400
1402
  score_team2 = val[1][1][:score]
1401
1403
 
1402
1404
  score = [[score_team1[0], score_team2[0]],
1403
- [score_team1[1], score_team2[1]]]
1405
+ [score_team1[1], score_team2[1]]]
1404
1406
 
1405
- result = { team1: val[0][1][:team],
1407
+ result = { team1: val[0][1][:team],
1406
1408
  team2: val[1][1][:team],
1407
1409
  score: score
1408
1410
  }
@@ -1418,15 +1420,15 @@ module_eval(<<'.,.,', 'parser.y', 471)
1418
1420
  ## or let's use [[0,1],[1,2]] - why? why not?
1419
1421
  score_team1 = val[0][1][:score]
1420
1422
  score_team2 = val[1][1][:score]
1421
-
1423
+
1422
1424
  score = { '_': [score_team1[0], score_team2[0]],
1423
- pen: [score_team1[1], score_team2[1]]
1424
- }
1425
+ pen: [score_team1[1], score_team2[1]]
1426
+ }
1425
1427
 
1426
- result = { team1: val[0][1][:team],
1428
+ result = { team1: val[0][1][:team],
1427
1429
  team2: val[1][1][:team],
1428
1430
  score: score
1429
- }
1431
+ }
1430
1432
 
1431
1433
  result
1432
1434
  end
@@ -1436,10 +1438,10 @@ module_eval(<<'.,.,', 'parser.y', 488)
1436
1438
  def _reduce_100(val, _values, result)
1437
1439
  score_team1 = val[0][1][:score]
1438
1440
  score_team2 = val[1][1][:score]
1439
-
1440
- score = [score_team1, score_team2]
1441
1441
 
1442
- result = { team1: val[0][1][:team],
1442
+ score = [score_team1, score_team2]
1443
+
1444
+ result = { team1: val[0][1][:team],
1443
1445
  team2: val[1][1][:team],
1444
1446
  score: score
1445
1447
  }
@@ -1450,7 +1452,7 @@ module_eval(<<'.,.,', 'parser.y', 488)
1450
1452
 
1451
1453
  module_eval(<<'.,.,', 'parser.y', 500)
1452
1454
  def _reduce_101(val, _values, result)
1453
- result = { team1: val[0],
1455
+ result = { team1: val[0],
1454
1456
  team2: val[2],
1455
1457
  score: [val[1], val[3]]
1456
1458
  }
@@ -1507,7 +1509,7 @@ module_eval(<<'.,.,', 'parser.y', 528)
1507
1509
 
1508
1510
  module_eval(<<'.,.,', 'parser.y', 549)
1509
1511
  def _reduce_111(val, _values, result)
1510
- result = {}.merge( val[0][1] )
1512
+ result = {}.merge( val[0][1] )
1511
1513
 
1512
1514
  result
1513
1515
  end
@@ -1515,7 +1517,7 @@ module_eval(<<'.,.,', 'parser.y', 549)
1515
1517
 
1516
1518
  module_eval(<<'.,.,', 'parser.y', 553)
1517
1519
  def _reduce_112(val, _values, result)
1518
- result = {}.merge( val[0][1], val[1], val[2] )
1520
+ result = {}.merge( val[0][1], val[1], val[2] )
1519
1521
 
1520
1522
  result
1521
1523
  end
@@ -1523,7 +1525,7 @@ module_eval(<<'.,.,', 'parser.y', 553)
1523
1525
 
1524
1526
  module_eval(<<'.,.,', 'parser.y', 557)
1525
1527
  def _reduce_113(val, _values, result)
1526
- result = {}.merge( val[0], val[1], val[2] )
1528
+ result = {}.merge( val[0], val[1], val[2] )
1527
1529
 
1528
1530
  result
1529
1531
  end
@@ -1625,7 +1627,7 @@ module_eval(<<'.,.,', 'parser.y', 626)
1625
1627
  def _reduce_133(val, _values, result)
1626
1628
  trace( "RECUDE match_fixture" )
1627
1629
  result = { team1: val[0],
1628
- team2: val[2] }
1630
+ team2: val[2] }
1629
1631
 
1630
1632
  result
1631
1633
  end
@@ -1639,7 +1641,7 @@ module_eval(<<'.,.,', 'parser.y', 635)
1639
1641
 
1640
1642
  result = { team1: val[0],
1641
1643
  team2: val[2],
1642
- status_inline: 'canceled' }
1644
+ status_inline: 'canceled' }
1643
1645
 
1644
1646
  result
1645
1647
  end
@@ -1649,7 +1651,7 @@ module_eval(<<'.,.,', 'parser.y', 645)
1649
1651
  def _reduce_135(val, _values, result)
1650
1652
  result = { team1: val[0],
1651
1653
  team2: val[2],
1652
- status_inline: 'canceled' }
1654
+ status_inline: 'canceled' }
1653
1655
 
1654
1656
  result
1655
1657
  end
@@ -1659,7 +1661,7 @@ module_eval(<<'.,.,', 'parser.y', 652)
1659
1661
  def _reduce_136(val, _values, result)
1660
1662
  result = { team1: val[0],
1661
1663
  team2: val[2],
1662
- status_inline: 'postponed' }
1664
+ status_inline: 'postponed' }
1663
1665
 
1664
1666
  result
1665
1667
  end
@@ -1672,11 +1674,11 @@ module_eval(<<'.,.,', 'parser.y', 652)
1672
1674
  module_eval(<<'.,.,', 'parser.y', 668)
1673
1675
  def _reduce_139(val, _values, result)
1674
1676
  trace( "REDUCE => match_result : TEAM SCORE TEAM" )
1675
-
1677
+
1676
1678
  ## note - use/keep generic score (as array!! NOT hash!!!)
1677
1679
  result = { team1: val[0], team2: val[2],
1678
1680
  score: val[1][1][:score] ## note - as array e.g. [1,1] !!
1679
- }
1681
+ }
1680
1682
  ## pp result
1681
1683
 
1682
1684
  result
@@ -1688,7 +1690,7 @@ module_eval(<<'.,.,', 'parser.y', 678)
1688
1690
  result = { team1: val[0], team2: val[2],
1689
1691
  score: val[1][1],
1690
1692
  status_inline: 'awarded'
1691
- }
1693
+ }
1692
1694
 
1693
1695
  result
1694
1696
  end
@@ -1696,9 +1698,9 @@ module_eval(<<'.,.,', 'parser.y', 678)
1696
1698
 
1697
1699
  module_eval(<<'.,.,', 'parser.y', 685)
1698
1700
  def _reduce_141(val, _values, result)
1699
- result = { team1: val[0], team2: val[2],
1700
- status_inline: 'awarded'
1701
- }
1701
+ result = { team1: val[0], team2: val[2],
1702
+ status_inline: 'awarded'
1703
+ }
1702
1704
 
1703
1705
  result
1704
1706
  end
@@ -1709,7 +1711,7 @@ module_eval(<<'.,.,', 'parser.y', 691)
1709
1711
  result = { team1: val[0], team2: val[2],
1710
1712
  score: val[1][1],
1711
1713
  status_inline: 'abandoned'
1712
- }
1714
+ }
1713
1715
 
1714
1716
  result
1715
1717
  end
@@ -1717,9 +1719,9 @@ module_eval(<<'.,.,', 'parser.y', 691)
1717
1719
 
1718
1720
  module_eval(<<'.,.,', 'parser.y', 698)
1719
1721
  def _reduce_143(val, _values, result)
1720
- result = { team1: val[0], team2: val[2],
1721
- status_inline: 'abandoned'
1722
- }
1722
+ result = { team1: val[0], team2: val[2],
1723
+ status_inline: 'abandoned'
1724
+ }
1723
1725
 
1724
1726
  result
1725
1727
  end
@@ -1727,9 +1729,9 @@ module_eval(<<'.,.,', 'parser.y', 698)
1727
1729
 
1728
1730
  module_eval(<<'.,.,', 'parser.y', 704)
1729
1731
  def _reduce_144(val, _values, result)
1730
- result = { team1: val[0], team2: val[2],
1731
- status_inline: 'annulled'
1732
- }
1732
+ result = { team1: val[0], team2: val[2],
1733
+ status_inline: 'annulled'
1734
+ }
1733
1735
 
1734
1736
  result
1735
1737
  end
@@ -1737,9 +1739,9 @@ module_eval(<<'.,.,', 'parser.y', 704)
1737
1739
 
1738
1740
  module_eval(<<'.,.,', 'parser.y', 710)
1739
1741
  def _reduce_145(val, _values, result)
1740
- result = { team1: val[0], team2: val[2],
1741
- status_inline: 'suspended'
1742
- }
1742
+ result = { team1: val[0], team2: val[2],
1743
+ status_inline: 'suspended'
1744
+ }
1743
1745
 
1744
1746
  result
1745
1747
  end
@@ -1749,26 +1751,26 @@ module_eval(<<'.,.,', 'parser.y', 717)
1749
1751
  def _reduce_146(val, _values, result)
1750
1752
  trace( "REDUCE => match_result : TEAM SCORE TEAM SCORE_FULLER_MORE" )
1751
1753
  score = nil
1752
- score = if val[3][1][:score] &&
1753
- val[3][1][:score]=='et' ## check aet flag present?
1754
+ score = if val[3][1][:score] &&
1755
+ val[3][1][:score]=='et' ## check aet flag present?
1754
1756
  val[3][1].delete( :score ) ## note - remove/delete flag
1755
1757
  { et: val[1][1][:score] }
1756
- elsif val[3][1][:score] &&
1758
+ elsif val[3][1][:score] &&
1757
1759
  val[3][1][:score]=='ht' ## check ht flag present?
1758
1760
  val[3][1].delete( :score ) ## note - remove/delete flag
1759
- { ht: val[1][1][:score] }
1760
- elsif val[3][1][:score] &&
1761
+ { ht: val[1][1][:score] }
1762
+ elsif val[3][1][:score] &&
1761
1763
  val[3][1][:score]=='ft' ## check ft flag present?
1762
1764
  val[3][1].delete( :score ) ## note - remove/delete flag
1763
1765
  { ft: val[1][1][:score] }
1764
1766
  else ## assume full-time (ft)
1765
1767
  { ft: val[1][1][:score] }
1766
- end
1768
+ end
1767
1769
 
1768
1770
  result = { team1: val[0],
1769
1771
  team2: val[2],
1770
1772
  score: score.merge( val[3][1] )
1771
- }
1773
+ }
1772
1774
 
1773
1775
  result
1774
1776
  end
@@ -1779,7 +1781,7 @@ module_eval(<<'.,.,', 'parser.y', 742)
1779
1781
  result = { team1: val[0],
1780
1782
  team2: val[2],
1781
1783
  score: val[1][1]
1782
- }
1784
+ }
1783
1785
 
1784
1786
  result
1785
1787
  end
@@ -1789,8 +1791,8 @@ module_eval(<<'.,.,', 'parser.y', 749)
1789
1791
  def _reduce_148(val, _values, result)
1790
1792
  trace( "REDUCE => match_result : match_fixture SCORE" )
1791
1793
  ## note - use/keep generic score (as array!! NOT hash!!!)
1792
- result = { score: val[1][1][:score] ## note - as array e.g. [1,1] !!
1793
- }.merge( val[0] )
1794
+ result = { score: val[1][1][:score] ## note - as array e.g. [1,1] !!
1795
+ }.merge( val[0] )
1794
1796
  ## pp result
1795
1797
 
1796
1798
  result
@@ -1800,7 +1802,7 @@ module_eval(<<'.,.,', 'parser.y', 749)
1800
1802
  module_eval(<<'.,.,', 'parser.y', 757)
1801
1803
  def _reduce_149(val, _values, result)
1802
1804
  trace( "REDUCE => match_result : match_fixture score" )
1803
- result = { score: val[1][1] }.merge( val[0] )
1805
+ result = { score: val[1][1] }.merge( val[0] )
1804
1806
  ## pp result
1805
1807
 
1806
1808
  result
@@ -1811,8 +1813,8 @@ module_eval(<<'.,.,', 'parser.y', 766)
1811
1813
  def _reduce_150(val, _values, result)
1812
1814
  trace( "REDUCE => match_result_base : match_fixture_base SCORE" )
1813
1815
  ## note - use/keep generic score (as array!! NOT hash!!!)
1814
- result = { score: val[1][1][:score] ## note - as array e.g. [1,1] !!
1815
- }.merge( val[0] )
1816
+ result = { score: val[1][1][:score] ## note - as array e.g. [1,1] !!
1817
+ }.merge( val[0] )
1816
1818
  ## pp result
1817
1819
 
1818
1820
  result
@@ -1822,7 +1824,7 @@ module_eval(<<'.,.,', 'parser.y', 766)
1822
1824
  module_eval(<<'.,.,', 'parser.y', 774)
1823
1825
  def _reduce_151(val, _values, result)
1824
1826
  trace( "REDUCE => match_result_base : match_fixture_base score" )
1825
- result = { score: val[1][1] }.merge( val[0] )
1827
+ result = { score: val[1][1] }.merge( val[0] )
1826
1828
  ## pp result
1827
1829
 
1828
1830
  result
@@ -1841,7 +1843,7 @@ module_eval(<<'.,.,', 'parser.y', 813)
1841
1843
  module_eval(<<'.,.,', 'parser.y', 818)
1842
1844
  def _reduce_153(val, _values, result)
1843
1845
  result = { goals1: val[0],
1844
- goals2: [] }
1846
+ goals2: [] }
1845
1847
 
1846
1848
  result
1847
1849
  end
@@ -1850,7 +1852,7 @@ module_eval(<<'.,.,', 'parser.y', 818)
1850
1852
  module_eval(<<'.,.,', 'parser.y', 821)
1851
1853
  def _reduce_154(val, _values, result)
1852
1854
  result = { goals1: [],
1853
- goals2: val[1] }
1855
+ goals2: val[1] }
1854
1856
 
1855
1857
  result
1856
1858
  end
@@ -1875,7 +1877,7 @@ module_eval(<<'.,.,', 'parser.y', 824)
1875
1877
 
1876
1878
  module_eval(<<'.,.,', 'parser.y', 835)
1877
1879
  def _reduce_160(val, _values, result)
1878
-
1880
+
1879
1881
  result
1880
1882
  end
1881
1883
  .,.,
@@ -1903,7 +1905,7 @@ module_eval(<<'.,.,', 'parser.y', 841)
1903
1905
  module_eval(<<'.,.,', 'parser.y', 849)
1904
1906
  def _reduce_166(val, _values, result)
1905
1907
  result = Goal.new( player: val[0],
1906
- minutes: val[1] )
1908
+ minutes: val[1] )
1907
1909
 
1908
1910
  result
1909
1911
  end
@@ -1912,7 +1914,7 @@ module_eval(<<'.,.,', 'parser.y', 849)
1912
1914
  module_eval(<<'.,.,', 'parser.y', 854)
1913
1915
  def _reduce_167(val, _values, result)
1914
1916
  ### todo/check:
1915
- ## auto convert/expand
1917
+ ## auto convert/expand
1916
1918
  ## count to minutes - why? why not?
1917
1919
  ## todo/fix - pass in empty minutes ary [] - why? why not?
1918
1920
  result = Goal.new( player: val[0],
@@ -1933,7 +1935,7 @@ module_eval(<<'.,.,', 'parser.y', 863)
1933
1935
 
1934
1936
  module_eval(<<'.,.,', 'parser.y', 870)
1935
1937
  def _reduce_169(val, _values, result)
1936
-
1938
+
1937
1939
  result
1938
1940
  end
1939
1941
  .,.,
@@ -1957,7 +1959,7 @@ module_eval(<<'.,.,', 'parser.y', 874)
1957
1959
  module_eval(<<'.,.,', 'parser.y', 878)
1958
1960
  def _reduce_173(val, _values, result)
1959
1961
  kwargs = {}.merge( val[0][1] )
1960
- result = GoalMinute.new( **kwargs )
1962
+ result = GoalMinute.new( **kwargs )
1961
1963
 
1962
1964
  result
1963
1965
  end
@@ -2020,7 +2022,7 @@ module_eval(<<'.,.,', 'parser.y', 922)
2020
2022
  module_eval(<<'.,.,', 'parser.y', 932)
2021
2023
  def _reduce_180(val, _values, result)
2022
2024
  result = GoalAlt.new( player: val[0],
2023
- score: val[1][1][:score] )
2025
+ score: val[1][1][:score] )
2024
2026
 
2025
2027
  result
2026
2028
  end
@@ -2029,7 +2031,7 @@ module_eval(<<'.,.,', 'parser.y', 932)
2029
2031
  module_eval(<<'.,.,', 'parser.y', 937)
2030
2032
  def _reduce_181(val, _values, result)
2031
2033
  goal_minute = GoalMinute.new( **val[1][1] )
2032
-
2034
+
2033
2035
  result = GoalAlt.new( player: val[0],
2034
2036
  minute: goal_minute.to_minute,
2035
2037
  goal_type: goal_minute.to_goal_type,
@@ -2123,7 +2125,7 @@ module_eval(<<'.,.,', 'parser.y', 1015)
2123
2125
 
2124
2126
  module_eval(<<'.,.,', 'parser.y', 1021)
2125
2127
  def _reduce_191(val, _values, result)
2126
- @tree << RefereeLine.new( referees: val[1] )
2128
+ @tree << RefereeLine.new( referees: val[1] )
2127
2129
 
2128
2130
  result
2129
2131
  end
@@ -2169,7 +2171,7 @@ module_eval(<<'.,.,', 'parser.y', 1038)
2169
2171
 
2170
2172
  module_eval(<<'.,.,', 'parser.y', 1043)
2171
2173
  def _reduce_198(val, _values, result)
2172
- @tree << PenaltiesLine.new( penalties: val[1] )
2174
+ @tree << PenaltiesLine.new( penalties: val[1] )
2173
2175
 
2174
2176
  result
2175
2177
  end
@@ -2218,7 +2220,7 @@ module_eval(<<'.,.,', 'parser.y', 1062)
2218
2220
 
2219
2221
  module_eval(<<'.,.,', 'parser.y', 1068)
2220
2222
  def _reduce_207(val, _values, result)
2221
- result = Penalty.new( name: val[0] )
2223
+ result = Penalty.new( name: val[0] )
2222
2224
 
2223
2225
  result
2224
2226
  end
@@ -2227,7 +2229,7 @@ module_eval(<<'.,.,', 'parser.y', 1068)
2227
2229
  module_eval(<<'.,.,', 'parser.y', 1072)
2228
2230
  def _reduce_208(val, _values, result)
2229
2231
  result = Penalty.new( name: val[0],
2230
- note: val[1] )
2232
+ note: val[1] )
2231
2233
 
2232
2234
  result
2233
2235
  end
@@ -2235,7 +2237,7 @@ module_eval(<<'.,.,', 'parser.y', 1072)
2235
2237
 
2236
2238
  module_eval(<<'.,.,', 'parser.y', 1079)
2237
2239
  def _reduce_209(val, _values, result)
2238
- @tree << CardsLine.new( type: 'Y', bookings: val[1] )
2240
+ @tree << CardsLine.new( type: 'Y', bookings: val[1] )
2239
2241
 
2240
2242
  result
2241
2243
  end
@@ -2243,7 +2245,7 @@ module_eval(<<'.,.,', 'parser.y', 1079)
2243
2245
 
2244
2246
  module_eval(<<'.,.,', 'parser.y', 1083)
2245
2247
  def _reduce_210(val, _values, result)
2246
- @tree << CardsLine.new( type: 'R', bookings: val[1] )
2248
+ @tree << CardsLine.new( type: 'R', bookings: val[1] )
2247
2249
 
2248
2250
  result
2249
2251
  end
@@ -2286,8 +2288,8 @@ module_eval(<<'.,.,', 'parser.y', 1101)
2286
2288
  module_eval(<<'.,.,', 'parser.y', 1109)
2287
2289
  def _reduce_218(val, _values, result)
2288
2290
  kwargs = { team: val[0],
2289
- lineup: val[1] }.merge( val[2] )
2290
- @tree << LineupLine.new( **kwargs )
2291
+ lineup: val[1] }.merge( val[2] )
2292
+ @tree << LineupLine.new( **kwargs )
2291
2293
 
2292
2294
  result
2293
2295
  end
@@ -2408,7 +2410,7 @@ module_eval(<<'.,.,', 'parser.y', 1177)
2408
2410
  def _reduce_235(val, _values, result)
2409
2411
  kwargs = {}.merge( val[1] ).merge( val[3] )
2410
2412
  sub = Sub.new( sub: Lineup.new( **kwargs ),
2411
- minute: Minute.new(val[2][1])
2413
+ minute: Minute.new(val[2][1])
2412
2414
  )
2413
2415
  result = { sub: sub }
2414
2416
 
@@ -2428,7 +2430,7 @@ module_eval(<<'.,.,', 'parser.y', 1185)
2428
2430
  module_eval(<<'.,.,', 'parser.y', 1192)
2429
2431
  def _reduce_237(val, _values, result)
2430
2432
  sub = Sub.new( sub: val[2],
2431
- minute: Minute.new(val[1][1])
2433
+ minute: Minute.new(val[1][1])
2432
2434
  )
2433
2435
  result = { sub: sub }
2434
2436
 
@@ -0,0 +1,379 @@
1
+
2
+ # frozen_string_literal: true
3
+ #--
4
+ # Copyright (c) 1999-2006 Minero Aoki
5
+ #
6
+ # This program is free software.
7
+ # You can distribute/modify this program under the same terms of ruby.
8
+ #
9
+ # As a special exception, when this code is copied by Racc
10
+ # into a Racc output file, you may use that output file
11
+ # without restriction.
12
+ #++
13
+
14
+
15
+ module Racc
16
+ class ParseError < StandardError; end
17
+ end
18
+ unless defined?(::ParseError)
19
+ ParseError = Racc::ParseError # :nodoc:
20
+ end
21
+
22
+
23
+
24
+ module Racc
25
+ VERSION = '1.8.1'
26
+ Version = VERSION
27
+
28
+
29
+ class Parser
30
+ def _racc_setup
31
+ @yydebug = false unless self.class::Racc_debug_parser
32
+ @yydebug = false unless defined?(@yydebug)
33
+ if @yydebug
34
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
35
+ @racc_debug_out ||= $stderr
36
+ end
37
+ arg = self.class::Racc_arg
38
+ arg[13] = true if arg.size < 14
39
+ arg
40
+ end
41
+
42
+ def _racc_init_sysvars
43
+ @racc_state = [0]
44
+ @racc_tstack = []
45
+ @racc_vstack = []
46
+
47
+ @racc_t = nil
48
+ @racc_val = nil
49
+
50
+ @racc_read_next = true
51
+
52
+ @racc_user_yyerror = false
53
+ @racc_error_status = 0
54
+ end
55
+
56
+ # The entry point of the parser. This method is used with #next_token.
57
+ # If Racc wants to get token (and its value), calls next_token.
58
+ #
59
+ # Example:
60
+ # def parse
61
+ # @q = [[1,1],
62
+ # [2,2],
63
+ # [3,3],
64
+ # [false, '$']]
65
+ # do_parse
66
+ # end
67
+ #
68
+ # def next_token
69
+ # @q.shift
70
+ # end
71
+ def do_parse
72
+ _racc_do_parse_rb(_racc_setup(), false)
73
+ end
74
+
75
+ # The method to fetch next token.
76
+ # If you use #do_parse method, you must implement #next_token.
77
+ #
78
+ # The format of return value is [TOKEN_SYMBOL, VALUE].
79
+ # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
80
+ # for 'IDENT'. ";" (String) for ';'.
81
+ #
82
+ # The final symbol (End of file) must be false.
83
+ def next_token
84
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
85
+ end
86
+
87
+ def _racc_do_parse_rb(arg, in_debug)
88
+ action_table, action_check, action_default, action_pointer,
89
+ _, _, _, _,
90
+ _, _, token_table, * = arg
91
+
92
+ _racc_init_sysvars
93
+ tok = act = i = nil
94
+
95
+ catch(:racc_end_parse) {
96
+ while true
97
+ if i = action_pointer[@racc_state[-1]]
98
+ if @racc_read_next
99
+ if @racc_t != 0 # not EOF
100
+ tok, @racc_val = next_token()
101
+ unless tok # EOF
102
+ @racc_t = 0
103
+ else
104
+ @racc_t = (token_table[tok] or 1) # error token
105
+ end
106
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
107
+ @racc_read_next = false
108
+ end
109
+ end
110
+ i += @racc_t
111
+ unless i >= 0 and
112
+ act = action_table[i] and
113
+ action_check[i] == @racc_state[-1]
114
+ act = action_default[@racc_state[-1]]
115
+ end
116
+ else
117
+ act = action_default[@racc_state[-1]]
118
+ end
119
+ while act = _racc_evalact(act, arg)
120
+ ;
121
+ end
122
+ end
123
+ }
124
+ end
125
+
126
+
127
+
128
+ ###
129
+ ### common
130
+ ###
131
+
132
+ def _racc_evalact(act, arg)
133
+ action_table, action_check, _, action_pointer,
134
+ _, _, _, _,
135
+ _, _, _, shift_n,
136
+ reduce_n, * = arg
137
+ nerr = 0 # tmp
138
+
139
+ if act > 0 and act < shift_n
140
+ #
141
+ # shift
142
+ #
143
+ if @racc_error_status > 0
144
+ @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
145
+ end
146
+ @racc_vstack.push @racc_val
147
+ @racc_state.push act
148
+ @racc_read_next = true
149
+ if @yydebug
150
+ @racc_tstack.push @racc_t
151
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
152
+ end
153
+
154
+ elsif act < 0 and act > -reduce_n
155
+ #
156
+ # reduce
157
+ #
158
+ code = catch(:racc_jump) {
159
+ @racc_state.push _racc_do_reduce(arg, act)
160
+ false
161
+ }
162
+ if code
163
+ case code
164
+ when 1 # yyerror
165
+ @racc_user_yyerror = true # user_yyerror
166
+ return -reduce_n
167
+ when 2 # yyaccept
168
+ return shift_n
169
+ else
170
+ raise '[Racc Bug] unknown jump code'
171
+ end
172
+ end
173
+
174
+ elsif act == shift_n
175
+ #
176
+ # accept
177
+ #
178
+ racc_accept if @yydebug
179
+ throw :racc_end_parse, @racc_vstack[0]
180
+
181
+ elsif act == -reduce_n
182
+ #
183
+ # error
184
+ #
185
+ case @racc_error_status
186
+ when 0
187
+ unless arg[21] # user_yyerror
188
+ nerr += 1
189
+ on_error @racc_t, @racc_val, @racc_vstack
190
+ end
191
+ when 3
192
+ if @racc_t == 0 # is $
193
+ # We're at EOF, and another error occurred immediately after
194
+ # attempting auto-recovery
195
+ throw :racc_end_parse, nil
196
+ end
197
+ @racc_read_next = true
198
+ end
199
+ @racc_user_yyerror = false
200
+ @racc_error_status = 3
201
+ while true
202
+ if i = action_pointer[@racc_state[-1]]
203
+ i += 1 # error token
204
+ if i >= 0 and
205
+ (act = action_table[i]) and
206
+ action_check[i] == @racc_state[-1]
207
+ break
208
+ end
209
+ end
210
+ throw :racc_end_parse, nil if @racc_state.size <= 1
211
+ @racc_state.pop
212
+ @racc_vstack.pop
213
+ if @yydebug
214
+ @racc_tstack.pop
215
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
216
+ end
217
+ end
218
+ return act
219
+
220
+ else
221
+ raise "[Racc Bug] unknown action #{act.inspect}"
222
+ end
223
+
224
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
225
+
226
+ nil
227
+ end
228
+
229
+ def _racc_do_reduce(arg, act)
230
+ _, _, _, _,
231
+ goto_table, goto_check, goto_default, goto_pointer,
232
+ nt_base, reduce_table, _, _,
233
+ _, use_result, * = arg
234
+
235
+ state = @racc_state
236
+ vstack = @racc_vstack
237
+ tstack = @racc_tstack
238
+
239
+ i = act * -3
240
+ len = reduce_table[i]
241
+ reduce_to = reduce_table[i+1]
242
+ method_id = reduce_table[i+2]
243
+ void_array = []
244
+
245
+ tmp_t = tstack[-len, len] if @yydebug
246
+ tmp_v = vstack[-len, len]
247
+ tstack[-len, len] = void_array if @yydebug
248
+ vstack[-len, len] = void_array
249
+ state[-len, len] = void_array
250
+
251
+ # tstack must be updated AFTER method call
252
+ if use_result
253
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
254
+ else
255
+ vstack.push __send__(method_id, tmp_v, vstack)
256
+ end
257
+ tstack.push reduce_to
258
+
259
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
260
+
261
+ k1 = reduce_to - nt_base
262
+ if i = goto_pointer[k1]
263
+ i += state[-1]
264
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
265
+ return curstate
266
+ end
267
+ end
268
+ goto_default[k1]
269
+ end
270
+
271
+ # This method is called when a parse error is found.
272
+ #
273
+ # ERROR_TOKEN_ID is an internal ID of token which caused error.
274
+ # You can get string representation of this ID by calling
275
+ # #token_to_str.
276
+ #
277
+ # ERROR_VALUE is a value of error token.
278
+ #
279
+ # value_stack is a stack of symbol values.
280
+ # DO NOT MODIFY this object.
281
+ #
282
+ # This method raises ParseError by default.
283
+ #
284
+ # If this method returns, parsers enter "error recovering mode".
285
+ def on_error(t, val, vstack)
286
+ raise ParseError, sprintf("parse error on value %s (%s)",
287
+ val.inspect, token_to_str(t) || '?')
288
+ end
289
+
290
+ # Enter error recovering mode.
291
+ # This method does not call #on_error.
292
+ def yyerror
293
+ throw :racc_jump, 1
294
+ end
295
+
296
+ # Exit parser.
297
+ # Return value is +Symbol_Value_Stack[0]+.
298
+ def yyaccept
299
+ throw :racc_jump, 2
300
+ end
301
+
302
+ # Leave error recovering mode.
303
+ def yyerrok
304
+ @racc_error_status = 0
305
+ end
306
+
307
+ # For debugging output
308
+ def racc_read_token(t, tok, val)
309
+ @racc_debug_out.print 'read '
310
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
311
+ @racc_debug_out.puts val.inspect
312
+ @racc_debug_out.puts
313
+ end
314
+
315
+ def racc_shift(tok, tstack, vstack)
316
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
317
+ racc_print_stacks tstack, vstack
318
+ @racc_debug_out.puts
319
+ end
320
+
321
+ def racc_reduce(toks, sim, tstack, vstack)
322
+ out = @racc_debug_out
323
+ out.print 'reduce '
324
+ if toks.empty?
325
+ out.print ' <none>'
326
+ else
327
+ toks.each {|t| out.print ' ', racc_token2str(t) }
328
+ end
329
+ out.puts " --> #{racc_token2str(sim)}"
330
+ racc_print_stacks tstack, vstack
331
+ @racc_debug_out.puts
332
+ end
333
+
334
+ def racc_accept
335
+ @racc_debug_out.puts 'accept'
336
+ @racc_debug_out.puts
337
+ end
338
+
339
+ def racc_e_pop(state, tstack, vstack)
340
+ @racc_debug_out.puts 'error recovering mode: pop token'
341
+ racc_print_states state
342
+ racc_print_stacks tstack, vstack
343
+ @racc_debug_out.puts
344
+ end
345
+
346
+ def racc_next_state(curstate, state)
347
+ @racc_debug_out.puts "goto #{curstate}"
348
+ racc_print_states state
349
+ @racc_debug_out.puts
350
+ end
351
+
352
+ def racc_print_stacks(t, v)
353
+ out = @racc_debug_out
354
+ out.print ' ['
355
+ t.each_index do |i|
356
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
357
+ end
358
+ out.puts ' ]'
359
+ end
360
+
361
+ def racc_print_states(s)
362
+ out = @racc_debug_out
363
+ out.print ' ['
364
+ s.each {|st| out.print ' ', st }
365
+ out.puts ' ]'
366
+ end
367
+
368
+ def racc_token2str(tok)
369
+ self.class::Racc_token_to_s_table[tok] or
370
+ raise "[Racc Bug] can't convert token #{tok} to string"
371
+ end
372
+
373
+ # Convert internal ID of token symbol to the string.
374
+ def token_to_str(t)
375
+ self.class::Racc_token_to_s_table[t]
376
+ end
377
+
378
+ end
379
+ end
@@ -4,7 +4,7 @@ module SportDb
4
4
  module Parser
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 7
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -49,6 +49,10 @@ require_relative 'parser/lexer'
49
49
  require_relative 'parser/lexer_tty' ## teletype (tty) mode
50
50
 
51
51
 
52
+ ## note - use "embeded" racc parser runtime
53
+ ## MUST uncomment require 'racc/parser' in generated parser!!!
54
+ require_relative 'parser/parser_runtime'
55
+
52
56
  require_relative 'parser/parser' ## auto-generated by racc (from parser.y)
53
57
  require_relative 'parser/racc_parser'
54
58
  require_relative 'parser/racc_tree'
@@ -76,7 +80,7 @@ class Parser
76
80
  # "default" lexer & parser (wraps RaccMatchParser)
77
81
 
78
82
  def tokenize_with_errors( lines, debug: false )
79
- lexer = Lexer.new( lines )
83
+ lexer = Lexer.new( lines )
80
84
  tokens, errors = lexer.tokenize_with_errors
81
85
  [tokens, errors]
82
86
  end
@@ -107,4 +111,3 @@ end # module SportDb
107
111
 
108
112
 
109
113
  puts SportDb::Module::Parser.banner # say hello
110
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.1
27
- - !ruby/object:Gem::Dependency
28
- name: racc
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rdoc
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +77,7 @@ files:
91
77
  - lib/sportdb/parser/lexer_buffer.rb
92
78
  - lib/sportdb/parser/lexer_tty.rb
93
79
  - lib/sportdb/parser/parser.rb
80
+ - lib/sportdb/parser/parser_runtime.rb
94
81
  - lib/sportdb/parser/racc_parser.rb
95
82
  - lib/sportdb/parser/racc_tree.rb
96
83
  - lib/sportdb/parser/token-date.rb