sportdb-parser 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -2
- data/Manifest.txt +1 -0
- data/lib/sportdb/parser/parser.rb +421 -232
- data/lib/sportdb/parser/token.rb +120 -207
- data/lib/sportdb/parser/tokenizer.rb +262 -0
- data/lib/sportdb/parser/version.rb +1 -1
- data/lib/sportdb/parser.rb +64 -6
- metadata +3 -2
data/lib/sportdb/parser.rb
CHANGED
@@ -22,6 +22,8 @@ require_relative 'parser/token-date'
|
|
22
22
|
require_relative 'parser/token-text'
|
23
23
|
require_relative 'parser/token-status'
|
24
24
|
require_relative 'parser/token'
|
25
|
+
require_relative 'parser/tokenizer'
|
26
|
+
|
25
27
|
require_relative 'parser/lang'
|
26
28
|
require_relative 'parser/parser'
|
27
29
|
|
@@ -61,12 +63,14 @@ class Tokenizer
|
|
61
63
|
lines = txt.split( "\n" )
|
62
64
|
lines.each_with_index do |line,i|
|
63
65
|
next if line.strip.empty? || line.strip.start_with?( '#' )
|
66
|
+
## support for inline (end-of-line) comments
|
67
|
+
line = line.sub( /#.*/, '' ).strip
|
68
|
+
|
69
|
+
puts "line >#{line}<"
|
70
|
+
tokens = parser.tokenize( line )
|
71
|
+
pp tokens
|
64
72
|
|
65
|
-
|
66
|
-
tokens = parser.tokenize( line )
|
67
|
-
pp tokens
|
68
|
-
|
69
|
-
tree << tokens
|
73
|
+
tree << tokens
|
70
74
|
end
|
71
75
|
|
72
76
|
|
@@ -141,6 +145,53 @@ end # module SportDb
|
|
141
145
|
|
142
146
|
class RaccMatchParser
|
143
147
|
|
148
|
+
|
149
|
+
LineupLine = Struct.new( :team, :lineup ) do
|
150
|
+
def pretty_print( printer )
|
151
|
+
printer.text( "<LineupLine " )
|
152
|
+
printer.text( self.team )
|
153
|
+
printer.text( " lineup=" + self.lineup.pretty_inspect )
|
154
|
+
printer.text( ">" )
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
Lineup = Struct.new( :name, :card, :sub ) do
|
159
|
+
def pretty_print( printer )
|
160
|
+
buf = String.new
|
161
|
+
buf << self.name
|
162
|
+
buf << " card=" + self.card.pretty_inspect if card
|
163
|
+
buf << " sub=" + self.sub.pretty_inspect if sub
|
164
|
+
printer.text( buf )
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
Card = Struct.new( :name, :minute ) do
|
170
|
+
def to_s
|
171
|
+
buf = String.new
|
172
|
+
buf << "#{self.name}"
|
173
|
+
buf << " #{self.minute.to_s}" if self.minute
|
174
|
+
buf
|
175
|
+
end
|
176
|
+
|
177
|
+
def pretty_print( printer )
|
178
|
+
printer.text( to_s )
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
Sub = Struct.new( :minute, :sub ) do
|
184
|
+
def pretty_print( printer )
|
185
|
+
buf = String.new
|
186
|
+
buf << "(#{self.minute.to_s} "
|
187
|
+
buf << self.sub.pretty_inspect
|
188
|
+
buf << ")"
|
189
|
+
printer.text( buf )
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
|
144
195
|
GroupDef = Struct.new( :name, :teams ) do
|
145
196
|
def pretty_print( printer )
|
146
197
|
printer.text( "<GroupDef " )
|
@@ -227,6 +278,10 @@ Goal = Struct.new( :player, :minutes ) do
|
|
227
278
|
|
228
279
|
end
|
229
280
|
|
281
|
+
|
282
|
+
##
|
283
|
+
## fix - move :og, :pen to Goal if possible - why? why not?
|
284
|
+
## or change to GoalMinute ???
|
230
285
|
Minute = Struct.new( :m, :offset, :og, :pen ) do
|
231
286
|
def to_s
|
232
287
|
buf = String.new
|
@@ -272,10 +327,13 @@ def initialize(input)
|
|
272
327
|
|
273
328
|
|
274
329
|
def on_error(*args)
|
275
|
-
puts
|
330
|
+
puts
|
331
|
+
puts "!! on parse error:"
|
276
332
|
puts "args=#{args.pretty_inspect}"
|
333
|
+
exit 1 ## exit for now - get and print more info about context etc.!!
|
277
334
|
end
|
278
335
|
|
336
|
+
|
279
337
|
=begin
|
280
338
|
on_error do |error_token_id, error_value, value_stack|
|
281
339
|
puts "Parse error on token: #{error_token_id}, value: #{error_value}"
|
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.5.
|
4
|
+
version: 0.5.1
|
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-01-
|
11
|
+
date: 2025-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocos
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/sportdb/parser/token-status.rb
|
119
119
|
- lib/sportdb/parser/token-text.rb
|
120
120
|
- lib/sportdb/parser/token.rb
|
121
|
+
- lib/sportdb/parser/tokenizer.rb
|
121
122
|
- lib/sportdb/parser/version.rb
|
122
123
|
homepage: https://github.com/sportdb/sport.db
|
123
124
|
licenses:
|