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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +0 -37
- data/README.md +4 -8
- data/Rakefile +2 -1
- data/lib/fbtxt/parser/parse_tree-match.rb +3 -1
- data/lib/fbtxt/parser/parse_tree-props.rb +39 -10
- data/lib/fbtxt/parser/parser-top.rb +0 -9
- data/lib/fbtxt/parser/parser.rb +879 -843
- data/lib/fbtxt/parser/version.rb +1 -1
- data/lib/fbtxt/parser.rb +14 -82
- metadata +18 -41
- data/lib/fbtxt/parser/debuggable.rb +0 -53
- data/lib/fbtxt/parser/lexer-logger.rb +0 -20
- data/lib/fbtxt/parser/lexer-on_goal.rb +0 -167
- data/lib/fbtxt/parser/lexer-on_group_def.rb +0 -31
- data/lib/fbtxt/parser/lexer-on_prop_lineup.rb +0 -79
- data/lib/fbtxt/parser/lexer-on_prop_misc.rb +0 -123
- data/lib/fbtxt/parser/lexer-on_prop_penalties.rb +0 -40
- data/lib/fbtxt/parser/lexer-on_round_def.rb +0 -37
- data/lib/fbtxt/parser/lexer-on_top.rb +0 -133
- data/lib/fbtxt/parser/lexer-prep_doc.rb +0 -131
- data/lib/fbtxt/parser/lexer-prep_line.rb +0 -63
- data/lib/fbtxt/parser/lexer-tokenize.rb +0 -468
- data/lib/fbtxt/parser/lexer.rb +0 -231
- data/lib/fbtxt/parser/lexer_buffer.rb +0 -68
- data/lib/fbtxt/parser/lexer_token.rb +0 -126
- data/lib/fbtxt/parser/token-date--helpers.rb +0 -130
- data/lib/fbtxt/parser/token-date--names.rb +0 -108
- data/lib/fbtxt/parser/token-date.rb +0 -200
- data/lib/fbtxt/parser/token-date_duration.rb +0 -171
- data/lib/fbtxt/parser/token-geo.rb +0 -134
- data/lib/fbtxt/parser/token-goals--helpers.rb +0 -114
- data/lib/fbtxt/parser/token-goals.rb +0 -306
- data/lib/fbtxt/parser/token-group.rb +0 -29
- data/lib/fbtxt/parser/token-note.rb +0 -40
- data/lib/fbtxt/parser/token-prop.rb +0 -309
- data/lib/fbtxt/parser/token-prop_name.rb +0 -83
- data/lib/fbtxt/parser/token-round.rb +0 -88
- data/lib/fbtxt/parser/token-score--helpers.rb +0 -189
- data/lib/fbtxt/parser/token-score.rb +0 -60
- data/lib/fbtxt/parser/token-score_full.rb +0 -331
- data/lib/fbtxt/parser/token-score_fuller.rb +0 -434
- data/lib/fbtxt/parser/token-score_legs.rb +0 -59
- data/lib/fbtxt/parser/token-status.rb +0 -192
- data/lib/fbtxt/parser/token-status_inline.rb +0 -112
- data/lib/fbtxt/parser/token-text.rb +0 -221
- data/lib/fbtxt/parser/token-time.rb +0 -144
- data/lib/fbtxt/parser/token.rb +0 -224
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9d91912300cd9b915825e9ea868e173c83734639a33a400c602b4ed92e818599
|
|
4
|
+
data.tar.gz: 8186a48db3890066f1092822fd89d1c965608b0876ddb8e60f6184736deeb894
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6203a05140096ef31c0722673821571c37ef77fc192588bdc9690e33567a8a5e78b13f5b8166b8cbaa5ca1bc11e65284c5db46c42e2d2a27618a8624ce7b253e
|
|
7
|
+
data.tar.gz: 3191de551cf71adb298a6395af353496c9c2aabf2a91fa0c1473f177c55ea4ae9e4d2d4e2485dfb4e0186c526c8e1e26ca0740b52a9f5a077df287e90407c627
|
data/CHANGELOG.md
CHANGED
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
|
|
2
|
-
|
|
1
|
+
# fbtxt-parser - football.txt match parser
|
|
3
2
|
|
|
4
3
|
## Usage
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
``` ruby
|
|
8
|
-
result = Fbtxt.
|
|
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
|
|
17
|
+
note - for porcelain / higher-level apis see `Fbtxt::Document`,
|
|
18
|
+
for low-level lexer see `Fbtxt::Lexer`.
|
data/Rakefile
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|