sportdb-parser 0.6.20 → 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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Manifest.txt +15 -8
  4. data/Rakefile +1 -2
  5. data/lib/sportdb/parser/blocktxt.rb +99 -0
  6. data/lib/sportdb/parser/lexer.rb +958 -395
  7. data/lib/sportdb/parser/lexer_buffer.rb +97 -0
  8. data/lib/sportdb/parser/lexer_tty.rb +111 -0
  9. data/lib/sportdb/parser/parser.rb +1772 -857
  10. data/lib/sportdb/parser/parser_runtime.rb +379 -0
  11. data/lib/sportdb/parser/racc_parser.rb +1 -1
  12. data/lib/sportdb/parser/racc_tree.rb +327 -41
  13. data/lib/sportdb/parser/token-date.rb +160 -178
  14. data/lib/sportdb/parser/token-date_duration.rb +190 -0
  15. data/lib/sportdb/parser/token-geo.rb +59 -59
  16. data/lib/sportdb/parser/token-goals.rb +460 -0
  17. data/lib/sportdb/parser/token-group.rb +43 -0
  18. data/lib/sportdb/parser/token-note.rb +40 -0
  19. data/lib/sportdb/parser/token-prop.rb +70 -54
  20. data/lib/sportdb/parser/token-prop_name.rb +74 -0
  21. data/lib/sportdb/parser/token-round.rb +102 -0
  22. data/lib/sportdb/parser/token-score.rb +323 -47
  23. data/lib/sportdb/parser/token-score_fuller.rb +435 -0
  24. data/lib/sportdb/parser/token-score_legs.rb +59 -0
  25. data/lib/sportdb/parser/token-status.rb +157 -160
  26. data/lib/sportdb/parser/token-table.rb +149 -0
  27. data/lib/sportdb/parser/token-text.rb +72 -23
  28. data/lib/sportdb/parser/token-time.rb +141 -0
  29. data/lib/sportdb/parser/token.rb +242 -105
  30. data/lib/sportdb/parser/token_helpers.rb +92 -0
  31. data/lib/sportdb/parser/version.rb +2 -2
  32. data/lib/sportdb/parser.rb +29 -4
  33. metadata +19 -32
  34. data/config/rounds_de.txt +0 -125
  35. data/config/rounds_en.txt +0 -29
  36. data/config/rounds_es.txt +0 -26
  37. data/config/rounds_misc.txt +0 -25
  38. data/config/rounds_pt.txt +0 -4
  39. data/config/zones_en.txt +0 -20
  40. data/lib/sportdb/parser/lang.rb +0 -298
  41. data/lib/sportdb/parser/token-minute.rb +0 -205
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c898ad3b9fe76d9d8a102e7e849579539b394702f1be51a60a16a4c59dc3cbbe
4
- data.tar.gz: 9c6825abfbcc8ba4b53cdf689894112048dee41b302762acf554619bf1ed2608
3
+ metadata.gz: 17e2ccd1472c3f56b5c1f4f4374e66de6b5297c67a5a0fa86206489ac560a00e
4
+ data.tar.gz: 1c6de22e1c9dda2cc2a0b75654737882b7ce4c7e9f191b61889887c844fc35b9
5
5
  SHA512:
6
- metadata.gz: 4ff371068bd1edf49804f0ea0e46efdde3b441b3afad240b33b9b822a15667f0b52c4d5d9e624b3944fc89c99ff94d3f7cc9c9014e34b328ce20377bdff3b376
7
- data.tar.gz: 6460faa48f39d95b86544532ea745cb8600f12b6ddbfc0cd61b3fa66d63d1bdc9d0bc331b4bd891ddde90e58157bfd2f120293f98430596ec9f1cb34e68a728f
6
+ metadata.gz: ac121460004ce5f4287668ea8753feee5729124a265474bfcf065775ffd099a5f867109fc16b2d8d46b6ee7a327bdc8b4c14539f22d1ef43ee285f457097eae0
7
+ data.tar.gz: 340afd868ceceeaa31532ea89251d5bfa2874f649933a18124bb4a5ba28e837c3a59284144d376f17c125ca93c12436cc473c7fda94a3b72866960fdc2c9cba8
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.6.20
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
@@ -2,24 +2,31 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- config/rounds_de.txt
6
- config/rounds_en.txt
7
- config/rounds_es.txt
8
- config/rounds_misc.txt
9
- config/rounds_pt.txt
10
- config/zones_en.txt
11
5
  lib/sportdb/parser.rb
12
- lib/sportdb/parser/lang.rb
6
+ lib/sportdb/parser/blocktxt.rb
13
7
  lib/sportdb/parser/lexer.rb
8
+ lib/sportdb/parser/lexer_buffer.rb
9
+ lib/sportdb/parser/lexer_tty.rb
14
10
  lib/sportdb/parser/parser.rb
11
+ lib/sportdb/parser/parser_runtime.rb
15
12
  lib/sportdb/parser/racc_parser.rb
16
13
  lib/sportdb/parser/racc_tree.rb
17
14
  lib/sportdb/parser/token-date.rb
15
+ lib/sportdb/parser/token-date_duration.rb
18
16
  lib/sportdb/parser/token-geo.rb
19
- lib/sportdb/parser/token-minute.rb
17
+ lib/sportdb/parser/token-goals.rb
18
+ lib/sportdb/parser/token-group.rb
19
+ lib/sportdb/parser/token-note.rb
20
20
  lib/sportdb/parser/token-prop.rb
21
+ lib/sportdb/parser/token-prop_name.rb
22
+ lib/sportdb/parser/token-round.rb
21
23
  lib/sportdb/parser/token-score.rb
24
+ lib/sportdb/parser/token-score_fuller.rb
25
+ lib/sportdb/parser/token-score_legs.rb
22
26
  lib/sportdb/parser/token-status.rb
27
+ lib/sportdb/parser/token-table.rb
23
28
  lib/sportdb/parser/token-text.rb
29
+ lib/sportdb/parser/token-time.rb
24
30
  lib/sportdb/parser/token.rb
31
+ lib/sportdb/parser/token_helpers.rb
25
32
  lib/sportdb/parser/version.rb
data/Rakefile CHANGED
@@ -21,8 +21,7 @@ Hoe.spec 'sportdb-parser' do
21
21
  self.licenses = ['Public Domain']
22
22
 
23
23
  self.extra_deps = [
24
- ['cocos', '>= 0.4.0'],
25
- ['racc'], ## maybe inline runtime later if possible - why? why not?
24
+ ['cocos', '>= 0.4.1'],
26
25
  ]
27
26
 
28
27
  self.spec_extras = {
@@ -0,0 +1,99 @@
1
+ ###
2
+ # generic block text/txt helper
3
+
4
+ ## todo/chekc - find a better name SectTxt or ??
5
+
6
+ class BlockTxt
7
+
8
+ def self.parse( txt ) new( txt); end
9
+ def self.read( path ) parse( read_text( path )); end
10
+
11
+
12
+ def initialize( txt )
13
+ @sects = _parse( txt )
14
+ self
15
+ end
16
+
17
+ def size() @sects.size; end
18
+
19
+ def each( &blk ) @sects.each( &blk ); end
20
+ def each_with_index( &blk ) @sects.each_with_index( &blk ); end
21
+
22
+
23
+ def text
24
+ ## only get all txt1 parts joined as single all-in-one string txt
25
+ @sects.map {|sect| sect[0] }.join( "\n" )
26
+ end
27
+
28
+
29
+ def dump ## for debugging
30
+ puts "==> sects (#{@sects.size}):"
31
+ pp @sects
32
+ puts " #{@sects.size} sect(s)"
33
+ end
34
+
35
+
36
+ ##
37
+ # quick support for __END__
38
+ END_RE = %r{ ^
39
+ [ ]* __END__ [ ]*
40
+ .*?
41
+ \z ## note - until end-of-string/file !!!
42
+ }mx
43
+
44
+
45
+ ## SECT_RE (old) = %r{^
46
+ ## [ ]* --- [ ]*
47
+ ## $}x
48
+ ##
49
+ ## do NOT use --- (used in fbtxt and markdown and yaml etc.)
50
+
51
+
52
+ ## e.g. § or §§ or § § § or such
53
+ ## maybe allow :: § :: or such too or --- § --- or such
54
+ SECT_RE = %r{^
55
+ [ ]* §
56
+ ([ ]*§)*
57
+ [ ]*
58
+ $}x
59
+
60
+ ## split by " => or =====> "
61
+ ## todo/check - subsect?? find a better name? in/out or txt1/txt2
62
+ SUBSECT_RE = %r{^
63
+ [ ]*
64
+ =+ >
65
+ [ ]*
66
+ $}x
67
+
68
+
69
+
70
+ def _parse( txt )
71
+ blocks = [] ## note - holds [txt,exp] pairs
72
+
73
+ txt = txt.sub( END_RE, '' )
74
+
75
+ ## split by §
76
+ sections = txt.split( SECT_RE )
77
+
78
+ sections.each_with_index do |sect,i|
79
+ ## puts ">>> start #{i+1}"
80
+ ## pp sect
81
+ ## puts "<<< end #{i+1}"
82
+
83
+ txt1, txt2 = sect.split( SUBSECT_RE )
84
+ blocks << [txt1,txt2]
85
+ end
86
+
87
+ blocks
88
+ end
89
+
90
+
91
+
92
+ end # class BlockTxt
93
+
94
+
95
+ ###
96
+ # function-style helpers
97
+
98
+ def read_blocktxt( path ); BlockTxt.read( path ); end
99
+ def parse_blocktxt( txt ); BlockTxt.new( txt ); end