fbtxt-parser 0.9.0 → 0.9.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Manifest.txt +0 -37
  4. data/README.md +4 -8
  5. data/Rakefile +2 -1
  6. data/lib/fbtxt/parser/parse_tree-match.rb +3 -1
  7. data/lib/fbtxt/parser/parse_tree-props.rb +39 -10
  8. data/lib/fbtxt/parser/parser-top.rb +0 -9
  9. data/lib/fbtxt/parser/parser.rb +879 -843
  10. data/lib/fbtxt/parser/version.rb +1 -1
  11. data/lib/fbtxt/parser.rb +14 -82
  12. metadata +18 -41
  13. data/lib/fbtxt/parser/debuggable.rb +0 -53
  14. data/lib/fbtxt/parser/lexer-logger.rb +0 -20
  15. data/lib/fbtxt/parser/lexer-on_goal.rb +0 -167
  16. data/lib/fbtxt/parser/lexer-on_group_def.rb +0 -31
  17. data/lib/fbtxt/parser/lexer-on_prop_lineup.rb +0 -79
  18. data/lib/fbtxt/parser/lexer-on_prop_misc.rb +0 -123
  19. data/lib/fbtxt/parser/lexer-on_prop_penalties.rb +0 -40
  20. data/lib/fbtxt/parser/lexer-on_round_def.rb +0 -37
  21. data/lib/fbtxt/parser/lexer-on_top.rb +0 -133
  22. data/lib/fbtxt/parser/lexer-prep_doc.rb +0 -131
  23. data/lib/fbtxt/parser/lexer-prep_line.rb +0 -63
  24. data/lib/fbtxt/parser/lexer-tokenize.rb +0 -468
  25. data/lib/fbtxt/parser/lexer.rb +0 -231
  26. data/lib/fbtxt/parser/lexer_buffer.rb +0 -68
  27. data/lib/fbtxt/parser/lexer_token.rb +0 -126
  28. data/lib/fbtxt/parser/token-date--helpers.rb +0 -130
  29. data/lib/fbtxt/parser/token-date--names.rb +0 -108
  30. data/lib/fbtxt/parser/token-date.rb +0 -200
  31. data/lib/fbtxt/parser/token-date_duration.rb +0 -171
  32. data/lib/fbtxt/parser/token-geo.rb +0 -134
  33. data/lib/fbtxt/parser/token-goals--helpers.rb +0 -114
  34. data/lib/fbtxt/parser/token-goals.rb +0 -306
  35. data/lib/fbtxt/parser/token-group.rb +0 -29
  36. data/lib/fbtxt/parser/token-note.rb +0 -40
  37. data/lib/fbtxt/parser/token-prop.rb +0 -309
  38. data/lib/fbtxt/parser/token-prop_name.rb +0 -83
  39. data/lib/fbtxt/parser/token-round.rb +0 -88
  40. data/lib/fbtxt/parser/token-score--helpers.rb +0 -189
  41. data/lib/fbtxt/parser/token-score.rb +0 -60
  42. data/lib/fbtxt/parser/token-score_full.rb +0 -331
  43. data/lib/fbtxt/parser/token-score_fuller.rb +0 -434
  44. data/lib/fbtxt/parser/token-score_legs.rb +0 -59
  45. data/lib/fbtxt/parser/token-status.rb +0 -192
  46. data/lib/fbtxt/parser/token-status_inline.rb +0 -112
  47. data/lib/fbtxt/parser/token-text.rb +0 -221
  48. data/lib/fbtxt/parser/token-time.rb +0 -144
  49. data/lib/fbtxt/parser/token.rb +0 -224
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c2c69264e5b2d3d51bf412351b1221e65f35273a78e382e59bfeb460a762628
4
- data.tar.gz: e844cd20aa7e00cb5c2840d108bd3597efa065867ac0c2dbd7fbd0b4cfa8a9d1
3
+ metadata.gz: 9d91912300cd9b915825e9ea868e173c83734639a33a400c602b4ed92e818599
4
+ data.tar.gz: 8186a48db3890066f1092822fd89d1c965608b0876ddb8e60f6184736deeb894
5
5
  SHA512:
6
- metadata.gz: 46bc709e594ed668fb62c70bd36e96ad212584fc0d9d961d88a81220a6a0586b5c418cc8310f5f0fcba3906fce15a3d5b10837c8be876d0723496e4b23558495
7
- data.tar.gz: a30808c1b3815a9bdc74efc59e38354a42da8d6e265ed6283752df5ae6a6ebee2d56265a78d09554267ce6bf7b40091a6733d19c61ef10c3499a591de0a21df7
6
+ metadata.gz: 6203a05140096ef31c0722673821571c37ef77fc192588bdc9690e33567a8a5e78b13f5b8166b8cbaa5ca1bc11e65284c5db46c42e2d2a27618a8624ce7b253e
7
+ data.tar.gz: 3191de551cf71adb298a6395af353496c9c2aabf2a91fa0c1473f177c55ea4ae9e4d2d4e2485dfb4e0186c526c8e1e26ca0740b52a9f5a077df287e90407c627
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.9.0
1
+ ### 0.9.1
2
2
  ### 0.0.1 / 2024-07-12
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -3,21 +3,6 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  lib/fbtxt/parser.rb
6
- lib/fbtxt/parser/debuggable.rb
7
- lib/fbtxt/parser/lexer-logger.rb
8
- lib/fbtxt/parser/lexer-on_goal.rb
9
- lib/fbtxt/parser/lexer-on_group_def.rb
10
- lib/fbtxt/parser/lexer-on_prop_lineup.rb
11
- lib/fbtxt/parser/lexer-on_prop_misc.rb
12
- lib/fbtxt/parser/lexer-on_prop_penalties.rb
13
- lib/fbtxt/parser/lexer-on_round_def.rb
14
- lib/fbtxt/parser/lexer-on_top.rb
15
- lib/fbtxt/parser/lexer-prep_doc.rb
16
- lib/fbtxt/parser/lexer-prep_line.rb
17
- lib/fbtxt/parser/lexer-tokenize.rb
18
- lib/fbtxt/parser/lexer.rb
19
- lib/fbtxt/parser/lexer_buffer.rb
20
- lib/fbtxt/parser/lexer_token.rb
21
6
  lib/fbtxt/parser/parse_tree--core.rb
22
7
  lib/fbtxt/parser/parse_tree-match.rb
23
8
  lib/fbtxt/parser/parse_tree-props.rb
@@ -25,26 +10,4 @@ lib/fbtxt/parser/parse_tree.rb
25
10
  lib/fbtxt/parser/parser-runtime.rb
26
11
  lib/fbtxt/parser/parser-top.rb
27
12
  lib/fbtxt/parser/parser.rb
28
- lib/fbtxt/parser/token-date--helpers.rb
29
- lib/fbtxt/parser/token-date--names.rb
30
- lib/fbtxt/parser/token-date.rb
31
- lib/fbtxt/parser/token-date_duration.rb
32
- lib/fbtxt/parser/token-geo.rb
33
- lib/fbtxt/parser/token-goals--helpers.rb
34
- lib/fbtxt/parser/token-goals.rb
35
- lib/fbtxt/parser/token-group.rb
36
- lib/fbtxt/parser/token-note.rb
37
- lib/fbtxt/parser/token-prop.rb
38
- lib/fbtxt/parser/token-prop_name.rb
39
- lib/fbtxt/parser/token-round.rb
40
- lib/fbtxt/parser/token-score--helpers.rb
41
- lib/fbtxt/parser/token-score.rb
42
- lib/fbtxt/parser/token-score_full.rb
43
- lib/fbtxt/parser/token-score_fuller.rb
44
- lib/fbtxt/parser/token-score_legs.rb
45
- lib/fbtxt/parser/token-status.rb
46
- lib/fbtxt/parser/token-status_inline.rb
47
- lib/fbtxt/parser/token-text.rb
48
- lib/fbtxt/parser/token-time.rb
49
- lib/fbtxt/parser/token.rb
50
13
  lib/fbtxt/parser/version.rb
data/README.md CHANGED
@@ -1,22 +1,18 @@
1
- # fbtxt-parser - football.txt match parser (& tokenizer)
2
-
1
+ # fbtxt-parser - football.txt match parser
3
2
 
4
3
  ## Usage
5
4
 
6
5
 
7
6
  ``` ruby
8
- result = Fbtxt.lex( txt ) # returns Fbtxt::LexerResult w/ tokens, errors/ok?/nok?/etc.
9
- result = Fbtxt.parse( txt ) # returns Fbtxt::ParserResult w/ tree, errors/ok?/nok?/etc.
7
+ result = Fbtxt.parse( txt ) # returns Fbtxt::ParserResult w/ tree, errors/ok?/nok?/etc.
10
8
 
11
9
 
12
10
  #-or-
13
11
 
14
- lexer = Fbtxt::Lexer.new(txt)
15
- tokens, errors = lexer.tokenize_with_errors
16
-
17
12
  parser = Fbtxt::Parser.new(txt)
18
13
  tree, errors = parser.parse_with_errors
19
14
  ```
20
15
 
21
16
 
22
- note - for porcelain / higher-level apis see ``Fbtxt::Document`.
17
+ note - for porcelain / higher-level apis see `Fbtxt::Document`,
18
+ for low-level lexer see `Fbtxt::Lexer`.
data/Rakefile CHANGED
@@ -21,7 +21,8 @@ Hoe.spec 'fbtxt-parser' do
21
21
  self.licenses = ['Public Domain']
22
22
 
23
23
  self.extra_deps = [
24
- ['cocos', '>= 0.4.1'],
24
+ ['cocos', '>= 0.4.2'], ## note - pulled-in by fbtxt-lexer (too)
25
+ ['fbtxt-lexer', '>= 0.0.1'],
25
26
  ]
26
27
 
27
28
  self.spec_extras = {
@@ -292,7 +292,9 @@ Minute = Struct.new( :m, :offset, :secs ) do
292
292
  def to_s
293
293
  buf = String.new
294
294
  buf << "#{m}"
295
- buf << "'"
295
+ ### note - do NOT autoadd minute quote for now
296
+ ## make it an option e.g. to_s( :quote) or such - why? why not?
297
+ ### buf << "'"
296
298
  buf << "+#{offset}" if offset
297
299
  buf << "/#{secs} secs" if secs
298
300
  buf
@@ -37,6 +37,30 @@ Referee = Struct.new( :name, :country ) do
37
37
  end # Referee
38
38
 
39
39
 
40
+ ## note - support multiple coaches
41
+ CoachLine = Struct.new( :coaches ) do
42
+ def pretty_print( q )
43
+ q.group( 4, '<CoachLine ', '>') do
44
+ q.pp( coaches )
45
+ end
46
+ end
47
+ end # CoachLine
48
+
49
+ Coach = Struct.new( :name, :country ) do
50
+ def to_s
51
+ buf = String.new
52
+ buf << name
53
+ buf << " (#{country})" if country
54
+ buf
55
+ end
56
+
57
+ def pretty_print( q )
58
+ q.text( to_s )
59
+ end
60
+ end # Coach
61
+
62
+
63
+
40
64
  AttendanceLine = Struct.new( :att ) do
41
65
  def pretty_print( q )
42
66
  q.group( 4, '<AttendanceLine ', '>') do
@@ -54,7 +78,7 @@ PenaltiesLine = Struct.new( :penalties ) do
54
78
  end
55
79
 
56
80
  def pretty_print( q )
57
- q.group( 4, '< ', '>') do
81
+ q.group( 4, '<PenaltiesLine ', '>') do
58
82
  q.pp( penalties )
59
83
  end
60
84
  end
@@ -122,7 +146,7 @@ end # Booking
122
146
 
123
147
  ##
124
148
  ## change :lineup to :lineups (e.g. requires array of lineups)
125
- LineupLine = Struct.new( :team, :lineup, :coach ) do
149
+ LineupLine = Struct.new( :team, :lineup, :formation, :coach ) do
126
150
  def as_json(*)
127
151
  h = { 'team' => team.as_json,
128
152
  'lineups' => lineup.as_json
@@ -137,14 +161,19 @@ LineupLine = Struct.new( :team, :lineup, :coach ) do
137
161
  q.text( team )
138
162
  q.text( ' ' )
139
163
 
140
- ## todo/fix - check for "flat" items - no formation
141
- ## or empty lineup (possible?)
142
- ## add formation e.g. (1-) 3-4-2-1
143
- formation = lineup.map { |item| item.size }
144
- ## note - remove first entry (assume it's 1 for goalee!)
145
- formation.shift
146
- q.text( formation.join('-'))
147
- q.text( ' ')
164
+ if formation
165
+ q.text( "(#{formation})" )
166
+ q.text( ' ')
167
+ else
168
+ ## todo/fix - check for "flat" items - no formation
169
+ ## or empty lineup (possible?)
170
+ ## add formation e.g. (1-) 3-4-2-1
171
+ autoformation = lineup.map { |item| item.size }
172
+ ## note - remove first entry (assume it's 1 for goalee!)
173
+ autoformation.shift
174
+ q.text( autoformation.join('-'))
175
+ q.text( ' ')
176
+ end
148
177
 
149
178
  q.pp( lineup )
150
179
 
@@ -2,15 +2,6 @@
2
2
 
3
3
  module Fbtxt
4
4
 
5
- class ParserResult
6
- attr_reader :tree, :errors
7
- def initialize( tree, errors=[] )
8
- @tree, @errors = tree, errors
9
- end
10
-
11
- def ok?() @errors.size == 0; end
12
- def nok?() !ok?; end
13
- end # class ParserResult
14
5
 
15
6
 
16
7
  class Parser