sportdb-parser 0.6.20 → 0.7.0

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Manifest.txt +14 -8
  4. data/Rakefile +1 -1
  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 +1768 -855
  10. data/lib/sportdb/parser/racc_parser.rb +1 -1
  11. data/lib/sportdb/parser/racc_tree.rb +327 -41
  12. data/lib/sportdb/parser/token-date.rb +160 -178
  13. data/lib/sportdb/parser/token-date_duration.rb +190 -0
  14. data/lib/sportdb/parser/token-geo.rb +59 -59
  15. data/lib/sportdb/parser/token-goals.rb +460 -0
  16. data/lib/sportdb/parser/token-group.rb +43 -0
  17. data/lib/sportdb/parser/token-note.rb +40 -0
  18. data/lib/sportdb/parser/token-prop.rb +70 -54
  19. data/lib/sportdb/parser/token-prop_name.rb +74 -0
  20. data/lib/sportdb/parser/token-round.rb +102 -0
  21. data/lib/sportdb/parser/token-score.rb +323 -47
  22. data/lib/sportdb/parser/token-score_fuller.rb +435 -0
  23. data/lib/sportdb/parser/token-score_legs.rb +59 -0
  24. data/lib/sportdb/parser/token-status.rb +157 -160
  25. data/lib/sportdb/parser/token-table.rb +149 -0
  26. data/lib/sportdb/parser/token-text.rb +72 -23
  27. data/lib/sportdb/parser/token-time.rb +141 -0
  28. data/lib/sportdb/parser/token.rb +242 -105
  29. data/lib/sportdb/parser/token_helpers.rb +92 -0
  30. data/lib/sportdb/parser/version.rb +2 -2
  31. data/lib/sportdb/parser.rb +24 -2
  32. metadata +18 -18
  33. data/config/rounds_de.txt +0 -125
  34. data/config/rounds_en.txt +0 -29
  35. data/config/rounds_es.txt +0 -26
  36. data/config/rounds_misc.txt +0 -25
  37. data/config/rounds_pt.txt +0 -4
  38. data/config/zones_en.txt +0 -20
  39. data/lib/sportdb/parser/lang.rb +0 -298
  40. 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: f227e5b41ea4ddd20904f5a582756eca266ce645d4a0c0c520b0297b996fbd80
4
+ data.tar.gz: 0e61ae4e7c8057825d41cf3e17baddd14f6413d19457ef390ff89d222b186e2d
5
5
  SHA512:
6
- metadata.gz: 4ff371068bd1edf49804f0ea0e46efdde3b441b3afad240b33b9b822a15667f0b52c4d5d9e624b3944fc89c99ff94d3f7cc9c9014e34b328ce20377bdff3b376
7
- data.tar.gz: 6460faa48f39d95b86544532ea745cb8600f12b6ddbfc0cd61b3fa66d63d1bdc9d0bc331b4bd891ddde90e58157bfd2f120293f98430596ec9f1cb34e68a728f
6
+ metadata.gz: e52ba0276a0e9d656b051dc23ad9237d76fa0b6f699627cfcc0d7b55ac87b990ac267065139e73d5bf4abc446a6d87dc0362c7f65d0c9134610f47f71a524d3e
7
+ data.tar.gz: 57b9b5a2218054ce8a7f698def21e931c90bc1737bfc364fa8e21c948f4bdc6090eff86c633f24f41687c25a30dce15483dfda63a7f175ddd019a8b908a6cac4
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.6.20
1
+ ### 0.7.0
2
2
  ### 0.0.1 / 2024-07-12
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -2,24 +2,30 @@ 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
15
11
  lib/sportdb/parser/racc_parser.rb
16
12
  lib/sportdb/parser/racc_tree.rb
17
13
  lib/sportdb/parser/token-date.rb
14
+ lib/sportdb/parser/token-date_duration.rb
18
15
  lib/sportdb/parser/token-geo.rb
19
- lib/sportdb/parser/token-minute.rb
16
+ lib/sportdb/parser/token-goals.rb
17
+ lib/sportdb/parser/token-group.rb
18
+ lib/sportdb/parser/token-note.rb
20
19
  lib/sportdb/parser/token-prop.rb
20
+ lib/sportdb/parser/token-prop_name.rb
21
+ lib/sportdb/parser/token-round.rb
21
22
  lib/sportdb/parser/token-score.rb
23
+ lib/sportdb/parser/token-score_fuller.rb
24
+ lib/sportdb/parser/token-score_legs.rb
22
25
  lib/sportdb/parser/token-status.rb
26
+ lib/sportdb/parser/token-table.rb
23
27
  lib/sportdb/parser/token-text.rb
28
+ lib/sportdb/parser/token-time.rb
24
29
  lib/sportdb/parser/token.rb
30
+ lib/sportdb/parser/token_helpers.rb
25
31
  lib/sportdb/parser/version.rb
data/Rakefile CHANGED
@@ -21,7 +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'],
24
+ ['cocos', '>= 0.4.1'],
25
25
  ['racc'], ## maybe inline runtime later if possible - why? why not?
26
26
  ]
27
27
 
@@ -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