sportdb-parser 0.6.4 → 0.6.5
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/lib/sportdb/parser/lexer.rb +59 -12
- data/lib/sportdb/parser/parser.rb +630 -461
- data/lib/sportdb/parser/racc_tree.rb +38 -3
- data/lib/sportdb/parser/token-prop.rb +40 -0
- data/lib/sportdb/parser/token.rb +8 -0
- data/lib/sportdb/parser/version.rb +1 -1
- metadata +2 -2
@@ -4,16 +4,51 @@
|
|
4
4
|
|
5
5
|
class RaccMatchParser
|
6
6
|
|
7
|
+
RefereeLine = Struct.new( :name, :country ) do
|
8
|
+
def pretty_print( printer )
|
9
|
+
printer.text( "<RefereeLine " )
|
10
|
+
printer.text( self.name )
|
11
|
+
printer.text( " (#{self.country})" ) if self.country
|
12
|
+
printer.text( ">" )
|
13
|
+
end
|
14
|
+
end
|
7
15
|
|
8
|
-
|
16
|
+
## find a better name for player (use bookings?) - note - red/yellow card for trainer possible
|
17
|
+
CardsLine = Struct.new( :type, :bookings ) do
|
18
|
+
def pretty_print( printer )
|
19
|
+
printer.text( "<CardsLine " )
|
20
|
+
printer.text( self.type )
|
21
|
+
printer.text( " bookings=" + self.bookings.pretty_inspect )
|
22
|
+
printer.text( ">" )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Booking = Struct.new( :name, :minute ) do
|
27
|
+
def to_s
|
28
|
+
buf = String.new
|
29
|
+
buf << "#{self.name}"
|
30
|
+
buf << " #{self.minute.to_s}" if self.minute
|
31
|
+
buf
|
32
|
+
end
|
33
|
+
|
34
|
+
def pretty_print( printer )
|
35
|
+
printer.text( to_s )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
LineupLine = Struct.new( :team, :lineup, :coach ) do
|
9
42
|
def pretty_print( printer )
|
10
43
|
printer.text( "<LineupLine " )
|
11
44
|
printer.text( self.team )
|
12
45
|
printer.text( " lineup=" + self.lineup.pretty_inspect )
|
46
|
+
printer.text( " coach=" + self.coach ) if self.coach
|
13
47
|
printer.text( ">" )
|
14
48
|
end
|
15
49
|
end
|
16
50
|
|
51
|
+
|
17
52
|
Lineup = Struct.new( :name, :card, :sub ) do
|
18
53
|
def pretty_print( printer )
|
19
54
|
buf = String.new
|
@@ -42,8 +77,8 @@ end
|
|
42
77
|
Sub = Struct.new( :minute, :sub ) do
|
43
78
|
def pretty_print( printer )
|
44
79
|
buf = String.new
|
45
|
-
buf << "(#{self.
|
46
|
-
buf << self.
|
80
|
+
buf << "(#{self.sub.pretty_inspect}"
|
81
|
+
buf << " #{self.minute.to_s}" if self.minute
|
47
82
|
buf << ")"
|
48
83
|
printer.text( buf )
|
49
84
|
end
|
@@ -121,6 +121,35 @@ PROP_NAME_RE = %r{
|
|
121
121
|
|
122
122
|
|
123
123
|
|
124
|
+
################
|
125
|
+
## todo/check - use token for card short cuts?
|
126
|
+
## if m[:name] == 'Y'
|
127
|
+
## [:YELLOW_CARD, m[:name]]
|
128
|
+
## elsif m[:name] == 'R'
|
129
|
+
## [:RED_CARD, m[:name]]
|
130
|
+
## - [Y], [R], [Y/R] Yellow-Red Card
|
131
|
+
## check if minutes possible inside [Y 46']
|
132
|
+
## add [c] for captain too
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
### simple prop key for inline use e.g.
|
137
|
+
### Coach: or Trainer: or ... add more here later
|
138
|
+
|
139
|
+
PROP_KEY_INLINE_RE = %r{
|
140
|
+
\b
|
141
|
+
(?<prop_key> ## note: use prop_key (NOT prop_key_inline or such)
|
142
|
+
(?<key>
|
143
|
+
\p{L}+
|
144
|
+
)
|
145
|
+
## note - NO spaces allowed for key for now!!!
|
146
|
+
:
|
147
|
+
(?=[ ]+) ## possitive lookahead (must be followed by space!!)
|
148
|
+
)
|
149
|
+
}ix
|
150
|
+
|
151
|
+
|
152
|
+
|
124
153
|
PROP_BASICS_RE = %r{
|
125
154
|
(?<spaces> [ ]{2,}) |
|
126
155
|
(?<space> [ ])
|
@@ -133,9 +162,20 @@ PROP_BASICS_RE = %r{
|
|
133
162
|
PROP_RE = Regexp.union(
|
134
163
|
PROP_BASICS_RE,
|
135
164
|
MINUTE_RE,
|
165
|
+
PROP_KEY_INLINE_RE,
|
136
166
|
PROP_NAME_RE,
|
167
|
+
## todo/fix - add ANY_RE here too!!!
|
137
168
|
)
|
138
169
|
|
170
|
+
## note - no inline keys possible
|
171
|
+
## todo/fix - use custom (limited) prop basics too
|
172
|
+
PROP_CARDS_RE = Regexp.union(
|
173
|
+
PROP_BASICS_RE,
|
174
|
+
MINUTE_RE,
|
175
|
+
PROP_NAME_RE,
|
176
|
+
## todo/fix - add ANY_RE here too!!!
|
177
|
+
)
|
178
|
+
|
139
179
|
|
140
180
|
end # class Lexer
|
141
181
|
end # module SportDb
|
data/lib/sportdb/parser/token.rb
CHANGED
@@ -171,6 +171,14 @@ GOAL_RE = Regexp.union(
|
|
171
171
|
PROP_NAME_RE, ## note - (re)use prop name for now for (player) name
|
172
172
|
)
|
173
173
|
|
174
|
+
PROP_GOAL_RE = Regexp.union(
|
175
|
+
GOAL_BASICS_RE,
|
176
|
+
MINUTE_RE,
|
177
|
+
MINUTE_NA_RE, ## note - add/allow not/available (n/a,na) minutes hack for now
|
178
|
+
GOAL_OG_RE, GOAL_PEN_RE,
|
179
|
+
SCORE_RE,
|
180
|
+
PROP_NAME_RE, ## note - (re)use prop name for now for (player) name
|
181
|
+
)
|
174
182
|
|
175
183
|
|
176
184
|
end # class Lexer
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|