sportdb-parser 0.7.1 → 0.8.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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Manifest.txt +25 -7
  4. data/Rakefile +23 -0
  5. data/lib/sportdb/parser/debuggable.rb +53 -0
  6. data/lib/sportdb/parser/lexer-logger.rb +20 -0
  7. data/lib/sportdb/parser/lexer-on_goal.rb +167 -0
  8. data/lib/sportdb/parser/lexer-on_group_def.rb +31 -0
  9. data/lib/sportdb/parser/lexer-on_prop_lineup.rb +79 -0
  10. data/lib/sportdb/parser/lexer-on_prop_misc.rb +123 -0
  11. data/lib/sportdb/parser/lexer-on_prop_penalties.rb +40 -0
  12. data/lib/sportdb/parser/lexer-on_round_def.rb +37 -0
  13. data/lib/sportdb/parser/lexer-on_top.rb +133 -0
  14. data/lib/sportdb/parser/lexer-prep_doc.rb +131 -0
  15. data/lib/sportdb/parser/lexer-prep_line.rb +63 -0
  16. data/lib/sportdb/parser/lexer-tokenize.rb +468 -0
  17. data/lib/sportdb/parser/lexer.rb +122 -1376
  18. data/lib/sportdb/parser/lexer_buffer.rb +8 -37
  19. data/lib/sportdb/parser/lexer_token.rb +126 -0
  20. data/lib/sportdb/parser/parse_tree--core.rb +29 -0
  21. data/lib/sportdb/parser/parse_tree-match.rb +309 -0
  22. data/lib/sportdb/parser/parse_tree-props.rb +233 -0
  23. data/lib/sportdb/parser/parse_tree.rb +202 -0
  24. data/lib/sportdb/parser/parser-top.rb +102 -0
  25. data/lib/sportdb/parser/parser.rb +1253 -1392
  26. data/lib/sportdb/parser/token-date--helpers.rb +130 -0
  27. data/lib/sportdb/parser/token-date--names.rb +108 -0
  28. data/lib/sportdb/parser/token-date.rb +20 -192
  29. data/lib/sportdb/parser/token-date_duration.rb +8 -27
  30. data/lib/sportdb/parser/token-geo.rb +16 -16
  31. data/lib/sportdb/parser/token-goals--helpers.rb +114 -0
  32. data/lib/sportdb/parser/token-goals.rb +101 -255
  33. data/lib/sportdb/parser/token-group.rb +8 -22
  34. data/lib/sportdb/parser/token-prop.rb +178 -124
  35. data/lib/sportdb/parser/token-prop_name.rb +48 -39
  36. data/lib/sportdb/parser/token-round.rb +21 -35
  37. data/lib/sportdb/parser/token-score--helpers.rb +189 -0
  38. data/lib/sportdb/parser/token-score.rb +9 -393
  39. data/lib/sportdb/parser/token-score_full.rb +331 -0
  40. data/lib/sportdb/parser/token-status.rb +44 -46
  41. data/lib/sportdb/parser/token-status_inline.rb +112 -0
  42. data/lib/sportdb/parser/token-text.rb +41 -31
  43. data/lib/sportdb/parser/token-time.rb +29 -26
  44. data/lib/sportdb/parser/token.rb +90 -158
  45. data/lib/sportdb/parser/version.rb +2 -2
  46. data/lib/sportdb/parser.rb +88 -62
  47. metadata +27 -9
  48. data/lib/sportdb/parser/blocktxt.rb +0 -99
  49. data/lib/sportdb/parser/lexer_tty.rb +0 -111
  50. data/lib/sportdb/parser/racc_parser.rb +0 -88
  51. data/lib/sportdb/parser/racc_tree.rb +0 -557
  52. data/lib/sportdb/parser/token-table.rb +0 -149
  53. data/lib/sportdb/parser/token_helpers.rb +0 -92
  54. /data/lib/sportdb/parser/{parser_runtime.rb → parser-runtime.rb} +0 -0
@@ -1,557 +0,0 @@
1
-
2
- ####
3
- # RaccMatchParser support machinery (incl. node classes/abstract syntax tree)
4
-
5
- class RaccMatchParser
6
-
7
- =begin
8
- RefereeLine = Struct.new( :name, :country ) do
9
- def pretty_print( printer )
10
- printer.text( "<RefereeLine " )
11
- printer.text( self.name )
12
- printer.text( " (#{self.country})" ) if self.country
13
- printer.text( ">" )
14
- end
15
- end
16
- =end
17
-
18
- ## support multiple referees (incl. assistant refs etc.)
19
- RefereeLine = Struct.new( :referees ) do
20
- def pretty_print( printer )
21
- printer.text( "<RefereeLine " )
22
- printer.text( self.referees.pretty_inspect )
23
- printer.text( ">" )
24
- end
25
- end
26
-
27
- Referee = Struct.new( :name, :country ) do
28
- def to_s
29
- buf = String.new
30
- buf << self.name
31
- buf << " (#{self.country})" if self.country
32
- buf
33
- end
34
-
35
- def pretty_print( printer )
36
- printer.text( to_s )
37
- end
38
- end
39
-
40
- AttendanceLine = Struct.new( :att ) do
41
- def pretty_print( printer )
42
- printer.text( "<AttendanceLine #{self.att}>" )
43
- end
44
- end
45
-
46
-
47
-
48
- PenaltiesLine = Struct.new( :penalties ) do
49
- def pretty_print( printer )
50
- printer.text( "<PenaltiesLine " )
51
- printer.text( self.penalties.pretty_inspect )
52
- printer.text( ">" )
53
- end
54
- end
55
-
56
-
57
- Penalty = Struct.new( :name, :score, :note ) do
58
- def to_s
59
- buf = String.new
60
- buf << "#{self.score[0]}-#{self.score[1]} " if self.score
61
- buf << self.name
62
- buf << " (#{self.note})" if self.note
63
- buf
64
- end
65
-
66
-
67
- def pretty_print( printer )
68
- printer.text( to_s )
69
- end
70
- end
71
-
72
-
73
-
74
-
75
- ## find a better name for player (use bookings?) - note - red/yellow card for trainer possible
76
- CardsLine = Struct.new( :type, :bookings ) do
77
- def pretty_print( printer )
78
- printer.text( "<CardsLine " )
79
- printer.text( self.type )
80
- printer.text( " bookings=" + self.bookings.pretty_inspect )
81
- printer.text( ">" )
82
- end
83
- end
84
-
85
- Booking = Struct.new( :name, :minute ) do
86
- def to_s
87
- buf = String.new
88
- buf << "#{self.name}"
89
- buf << " #{self.minute.to_s}" if self.minute
90
- buf
91
- end
92
-
93
- def pretty_print( printer )
94
- printer.text( to_s )
95
- end
96
- end
97
-
98
-
99
-
100
- LineupLine = Struct.new( :team, :lineup, :coach ) do
101
- def pretty_print( printer )
102
- printer.text( "<LineupLine " )
103
- printer.text( self.team )
104
- printer.text( " lineup=" + self.lineup.pretty_inspect )
105
- printer.text( " coach=" + self.coach ) if self.coach
106
- printer.text( ">" )
107
- end
108
- end
109
-
110
-
111
- Lineup = Struct.new( :name, :captain, :cards, :sub ) do
112
- def pretty_print( printer )
113
- buf = String.new
114
- buf << self.name
115
- buf << " [c]" if captain
116
- buf << " cards=" + self.cards.pretty_inspect if cards
117
- buf << " sub=" + self.sub.pretty_inspect if sub
118
- printer.text( buf )
119
- end
120
- end
121
-
122
-
123
- Card = Struct.new( :name, :minute ) do
124
- def to_s
125
- buf = String.new
126
- buf << "#{self.name}"
127
- buf << " #{self.minute.to_s}" if self.minute
128
- buf
129
- end
130
-
131
- def pretty_print( printer )
132
- printer.text( to_s )
133
- end
134
- end
135
-
136
-
137
- Sub = Struct.new( :minute, :sub ) do
138
- def pretty_print( printer )
139
- buf = String.new
140
- buf << "(" ## note - possibly recursive (thus, let minute go first/print first/upfront)
141
- buf << "#{self.minute.to_s} " if self.minute
142
- buf << "#{self.sub.pretty_inspect}"
143
- buf << ")"
144
- printer.text( buf )
145
- end
146
- end
147
-
148
-
149
-
150
- GroupDef = Struct.new( :name, :teams ) do
151
- def pretty_print( printer )
152
- printer.text( "<GroupDef " )
153
- printer.text( self.name )
154
- printer.text( " teams=" + self.teams.pretty_inspect )
155
- printer.text( ">" )
156
- end
157
- end
158
-
159
-
160
- RoundDef = Struct.new( :name, :date, :duration ) do
161
- def pretty_print( printer )
162
- printer.text( "<RoundDef " )
163
- printer.text( self.name )
164
- printer.text( " date=" + self.date.pretty_inspect ) if self.date
165
- printer.text( " duration=" + self.duration.pretty_inspect ) if self.duration
166
- printer.text( ">" )
167
- end
168
- end
169
-
170
- DateHeader = Struct.new( :date, :year ) do
171
- def pretty_print( printer )
172
- printer.text( "<DateHeader " )
173
- printer.text( "#{self.date.pretty_inspect}" ) if self.date
174
- printer.text( "#{self.year.pretty_inspect}" ) if self.year
175
- printer.text( ">")
176
- end
177
- end
178
-
179
- DateHeaderLegs = Struct.new( :date1, :date2 ) do
180
- def pretty_print( printer )
181
- printer.text( "<DateHeaderLegs " )
182
- printer.text( "leg1=#{self.date1.pretty_inspect}" )
183
- printer.text( " leg2=#{self.date2.pretty_inspect}" )
184
- printer.text( ">")
185
- end
186
- end
187
-
188
-
189
-
190
- RoundOutline = Struct.new( :outline, :level ) do
191
- def pretty_print( printer )
192
- printer.text( "<RoundOutline #{self.outline}, level=#{self.level}>" )
193
- end
194
- end
195
-
196
-
197
-
198
- class BlankLine
199
- def pretty_print( printer )
200
- printer.text( "<BlankLine>" )
201
- end
202
- end
203
-
204
- ## todo/check - find a better name for hruler - divider? or ??? - why? why not?
205
- class HRuler ## h(orizontal) ruler (for breaks; new scopes)
206
- def pretty_print( printer )
207
- printer.text( "<HRuler>" )
208
- end
209
- end
210
-
211
-
212
-
213
- NoteLine = Struct.new( :text ) do
214
- def pretty_print( printer )
215
- printer.text( "<NoteLine #{self.text}>" )
216
- end
217
- end
218
-
219
- NotaBene = Struct.new( :text ) do
220
- def pretty_print( printer )
221
- printer.text( "<NotaBene #{self.text}>" )
222
- end
223
- end
224
-
225
-
226
- ## todo/check - rename TableHeading to TableHeader - why? why not?
227
- TableHeading = Struct.new( :text ) do
228
- def pretty_print( printer )
229
- printer.text( "<TableHeading #{self.text}>" )
230
- end
231
- end
232
-
233
- ## todo/check - rename TableDivider to TableRule/TableRuler/TableLine - why? why not?
234
- TableDivider = Struct.new( :text ) do
235
- def pretty_print( printer )
236
- printer.text( "<TableDivider #{self.text}>" )
237
- end
238
- end
239
-
240
- TableLine = Struct.new( :text ) do
241
- def pretty_print( printer )
242
- printer.text( "<TableLine #{self.text}>" )
243
- end
244
- end
245
-
246
- TableNote = Struct.new( :text ) do
247
- def pretty_print( printer )
248
- printer.text( "<TableNote #{self.text}>" )
249
- end
250
- end
251
-
252
-
253
-
254
- ## todo/check - use a generic Heading instead of Heading1/2/3 - why? why not?
255
- Heading1 = Struct.new( :text ) do
256
- def pretty_print( printer )
257
- printer.text( "<Heading1 #{self.text}>" )
258
- end
259
- end
260
-
261
- Heading2 = Struct.new( :text ) do
262
- def pretty_print( printer )
263
- printer.text( "<Heading2 #{self.text}>" )
264
- end
265
- end
266
-
267
- Heading3 = Struct.new( :text ) do
268
- def pretty_print( printer )
269
- printer.text( "<Heading3 #{self.text}>" )
270
- end
271
- end
272
-
273
-
274
-
275
- MatchLineBye = Struct.new( :team, :note ) do
276
- def pretty_print( printer )
277
- printer.text( "<MatchLineBye " )
278
- printer.text( "#{self.team} bye")
279
- printer.text( " note=#{self.note.pretty_inspect}" ) if self.note
280
- printer.text( ">" )
281
- end
282
- end
283
-
284
- MatchLineWalkover = Struct.new( :team1, :team2, :note ) do
285
- def pretty_print( printer )
286
- printer.text( "<MatchLineWalkover " )
287
- printer.text( "#{self.team1} w/o #{self.team2}")
288
- printer.text( " note=#{self.note.pretty_inspect}" ) if self.note
289
- printer.text( ">" )
290
- end
291
- end
292
-
293
- MatchLineLegs = Struct.new( :team1, :team2,
294
- :score ) do ## change to geos - why? why not?
295
- def pretty_print( printer )
296
- printer.text( "<MatchLineLegs " )
297
- printer.text( "#{self.team1} v #{self.team2}")
298
- printer.breakable
299
-
300
- members.zip(values) do |name, value|
301
- next if [:team1, :team2].include?( name )
302
- next if value.nil?
303
-
304
- printer.text( "#{name}=#{value.pretty_inspect}" )
305
- end
306
-
307
- printer.text( ">" )
308
- end
309
- end
310
-
311
-
312
- #
313
- # note: use two status attributes for now
314
- # 1) inline_status and 2) (note_)status
315
- # for now e.g. A abd. B vs A v B [abadoned]
316
- # A 3-0 awd B vs A 3-0 B [awarded]
317
- # note - BOTH might be present at the same time
318
-
319
-
320
- MatchLine = Struct.new( :header, :tty, ## tty = TELETYPE MODE for teams and score!!
321
- :num, :date, :time, :time_local, :year,
322
- :team1, :team2,
323
- :score,
324
- :status, :status_inline, :status_note,
325
- :geo,
326
- :neutral, ## true/false - NOT -home/away - neutral ground
327
- :note,
328
- :att ) do ## change to geos - why? why not?
329
-
330
- def pretty_print( printer )
331
- printer.text( "<MatchLine " )
332
- printer.text( "#{self.team1} v #{self.team2}")
333
- printer.breakable
334
-
335
- members.zip(values) do |name, value|
336
- next if [:team1, :team2].include?( name )
337
- next if value.nil?
338
-
339
- printer.text( "#{name}=#{value.pretty_inspect}" )
340
- end
341
-
342
- printer.text( ">" )
343
- end
344
-
345
- end
346
-
347
-
348
- GoalLine = Struct.new( :goals1, :goals2 ) do
349
- def pretty_print( printer )
350
- printer.text( "<GoalLine " )
351
- printer.text( "goals1=" + self.goals1.pretty_inspect + "," )
352
- printer.breakable
353
- printer.text( "goals2=" + self.goals2.pretty_inspect + ">" )
354
- end
355
-
356
- ## def clone
357
- ## _clone = GoalLine.new( goals1: goals1.clone,
358
- ## goals2: goals2.clone )
359
- ##
360
- ## puts "[debug] clone #{self.pretty_inspect} => #{_clone.pretty_inspect}"
361
- ##
362
- ## _clone
363
- ## end
364
- end
365
-
366
-
367
- ###
368
- ## change/rename Goal to GoalScorer - why? why not?
369
-
370
- Goal = Struct.new( :player, :minutes, :count ) do
371
- def to_s
372
- buf = String.new
373
- buf << "#{self.player}"
374
- if count
375
- buf << (" " + count.pretty_inspect + ",")
376
- else
377
- if minutes.nil? || minutes.empty?
378
- ## add nothing if no minutes available/present
379
- else
380
- buf << " "
381
- buf << minutes.map { |min| min.to_s }.join(' ')
382
- end
383
- end
384
- buf
385
- end
386
-
387
- def pretty_print( printer )
388
- printer.text( to_s )
389
- end
390
-
391
- ## def clone
392
- ## puts "[debug] clone #{self.pretty_inspect}"
393
- ## Goal.new( player: player.clone,
394
- ## minutes: minutes.clone,
395
- ## count: count.clone )
396
- ## end
397
- end
398
-
399
-
400
- ## check - use a different name e.g. GoalLineScore or such - why? why not?
401
- GoalLineAlt = Struct.new( :goals ) do
402
- def pretty_print( printer )
403
- printer.text( "<GoalLineAlt " )
404
- printer.text( "goals=" + self.goals.pretty_inspect + ">" )
405
- end
406
- end
407
-
408
-
409
- ##
410
- ## score and player REQUIRED
411
- ## note - (goal) minute is optional
412
- ## if no minute goal type is optional e.g. "standalone" (p), (og), etc.
413
-
414
- GoalAlt = Struct.new( :score, :player, :minute, :goal_type ) do
415
- def to_s
416
- buf = String.new
417
- buf << "#{self.score[0]}-#{self.score[1]}"
418
- buf << " #{self.player}"
419
- buf << " #{self.minute}" if self.minute
420
- buf << " #{self.goal_type}" if self.goal_type
421
- buf
422
- end
423
-
424
- def pretty_print( printer )
425
- printer.text( to_s )
426
- end
427
- end
428
-
429
-
430
-
431
- GoalLineCompat = Struct.new( :goals ) do
432
- def pretty_print( printer )
433
- printer.text( "<GoalLineCompat " )
434
- printer.text( "goals=" + self.goals.pretty_inspect + ">" )
435
- end
436
- end
437
-
438
- ##
439
- ## minute and player REQUIRED
440
- ## note - score (e.g. 1-1) is optional
441
- ## goal type is optional e.g. "standalone" (p), (og), etc.
442
-
443
- GoalCompat = Struct.new( :score, :player, :minute, :goal_type ) do
444
- def to_s
445
- buf = String.new
446
- buf << "#{self.minute}"
447
- buf << " #{self.player}"
448
- buf << " #{self.goal_type}" if self.goal_type
449
- buf << " #{self.score[0]}-#{self.score[1]}" if self.score
450
- buf
451
- end
452
-
453
- def pretty_print( printer )
454
- printer.text( to_s )
455
- end
456
- end
457
-
458
-
459
-
460
- ## FIX/FIX/FIX
461
- ## split into Minute and
462
- ## GoalMinute (Minute+GoalType)
463
- ##
464
- ## fix - move :og, :pen to Goal if possible - why? why not?
465
- ## or change to GoalMinute ???
466
- ##
467
- ## fix!!! split into GoalMinute and Minute
468
- ## goal_minute incl. :og, :pen, :freekick, :header,
469
- ## seconds etc.
470
- ##
471
- ## GoalMinute = Minute + GoalType !!!
472
-
473
- GoalMinute = Struct.new( :m, :offset, :secs,
474
- :og, :pen, :header, :freekick,
475
- ) do
476
- def to_s
477
- buf = String.new
478
- buf << "#{self.m}"
479
- buf << "'"
480
- buf << "+#{self.offset}" if self.offset
481
- buf << " (og)" if self.og
482
- buf << " (pen)" if self.pen
483
- buf << " (f)" if self.freekick
484
- buf << " (h)" if self.header
485
- buf << " (#{self.secs} secs)" if self.secs
486
- buf
487
- end
488
-
489
- def pretty_print( printer )
490
- printer.text( to_s )
491
- end
492
-
493
- ### quick hack:
494
- ### split struct into Minute+GoalType structs
495
- def to_minute
496
- Minute.new( m: self.m,
497
- offset: self.offset,
498
- secs: self.secs )
499
- end
500
-
501
- def to_goal_type
502
- if self.og || self.pen || self.header || self.freekick
503
- GoalType.new( og: self.og,
504
- pen: self.pen,
505
- header: self.header,
506
- freekick: self.freekick )
507
- else
508
- nil ## note - return nil; if no goal type present!!
509
- end
510
- end
511
-
512
- ## def clone
513
- ## puts "[debug] clone #{self.pretty_inspect}"
514
- ## GoalMinute.new( m: m.clone,
515
- ## offset: offset.clone,
516
- ## secs: secs.clone,
517
- ## og: og.clone,
518
- ## pen: pen.clone,
519
- ## header: header.clone,
520
- ## freekick: freekick.clone )
521
- ##
522
- ## end
523
- end
524
-
525
-
526
- GoalType = Struct.new( :og, :pen, :header, :freekick ) do
527
- def to_s
528
- buf = String.new
529
- buf << "(og)" if self.og
530
- buf << "(pen)" if self.pen
531
- buf << "(f)" if self.freekick
532
- buf << "(h)" if self.header
533
- buf
534
- end
535
-
536
- def pretty_print( printer )
537
- printer.text( to_s )
538
- end
539
- end
540
-
541
-
542
- Minute = Struct.new( :m, :offset, :secs ) do
543
- def to_s
544
- buf = String.new
545
- buf << "#{self.m}"
546
- buf << "'"
547
- buf << "+#{self.offset}" if self.offset
548
- buf << "/#{self.secs} secs" if self.secs
549
- buf
550
- end
551
-
552
- def pretty_print( printer )
553
- printer.text( to_s )
554
- end
555
- end
556
-
557
- end # class RaccMatchParser
@@ -1,149 +0,0 @@
1
- module SportDb
2
- class Lexer
3
-
4
-
5
- ###
6
- ## check for
7
- ## table (standing) lines
8
- ##
9
- ## e.g.
10
- ##
11
- ## Pld W D L GF-GA Pts | d d d d-d d
12
- ## Pld GF-GA Pts | d d-d d
13
- ## Pld Pts W D L GF-GA | d d d d d d-d
14
- ##
15
- ## Pld = matches played
16
- ## GF-GA = goal for, goal against
17
-
18
-
19
- ## Pld W D L GF-GA Pts | d d d d-d d
20
- ##
21
- ## 1.BRAZIL 3 2 1 0 7- 2 7
22
- ## 2.MEXICO 3 2 1 0 4- 1 7
23
- ## 3.Croatia 3 1 0 2 6- 6 3
24
- ## 4.Cameroon 3 0 0 3 1- 9 0
25
-
26
- ## add more headings?? e.g.
27
- ## Final Table:
28
- ##
29
-
30
-
31
- TABLE_HEADING_I_RE = %r{
32
- \A
33
- [ ]* ## ignore leading spaces (if any)
34
- (?<table_heading>
35
- \b
36
- P(?:ld)? [ ]+
37
- W [ ]+
38
- D [ ]+
39
- L [ ]+
40
- Gls [ ]+
41
- Pts
42
- \b
43
- )
44
- [ ]* ## ignore trailing spaces (if any)
45
- \z
46
- }xi
47
-
48
-
49
- ##
50
- ## "solid"-style
51
- ## -----------------------------------------------------
52
- ## "dashed"-style ??
53
- ## - - - - - - - - - - - - - - - - - - - - - - - - - - -
54
-
55
-
56
- TABLE_DIVIDER_RE = %r{
57
- \A
58
- [ ]* ## ignore leading spaces (if any)
59
- (?<table_divider>
60
- (?: --- ## note - require three dashes minimum (---)
61
- [-]*
62
- )
63
- |
64
- (?: - [ ]+ - [ ]+ - ## note - require three dashes minimum (- - -)
65
- (?: [ ]+ -)* ## todo/check - restrict spaces to 2 or 3 or such - why? why not?
66
- )
67
- )
68
- [ ]* ## ignore trailing spaces (if any)
69
- \z
70
- }xi
71
-
72
-
73
- ####
74
- ## 1.SOLOMON I. 1 1 0 0 3- 1 3
75
- ## 2.TAHITI 1 0 0 1 1- 3 0
76
- ## -.Cook Islands withdrew after first match (annulled) due to Covid-19 outbreak in squad
77
- ## -.Vanuatu withdrew before playing any matches due to Covid-19 outbreak in squad -->
78
- ##
79
- ## note - starting with -. is a table note!!!
80
-
81
-
82
- TABLE_NOTE_RE = %r{
83
- \A
84
- [ ]* ## ignore leading spaces (if any)
85
- -\.
86
- [ ]*
87
- (?<table_note>
88
- .+? ## note - use non-greedy
89
- )
90
- [ ]* ## ignore trailing spaces (if any)
91
- \z
92
- }xi
93
-
94
- TABLE_I_RE = %r{
95
- (?<table>\b
96
- \d{1,2} [ ]+ # Pld
97
- \d{1,2} [ ]+ # W
98
- \d{1,2} [ ]+ # D
99
- \d{1,2} [ ]+ # L
100
- (?: \d{1,3} - [ ]* \d{1,3} [ ]+ ) # GF-GA
101
- \d{1,3} # Pts
102
- \b
103
- )}xi
104
-
105
- ## Pld Pts W D L GF-GA | d d d d d d-d
106
- ##
107
- ## 1. ARG^ 3 6 3 0 0 10-4
108
- ## 2. CHI 3 4 2 0 1 5-3
109
- ## 3. FRA 3 2 1 0 2 4-3
110
- ## 4. MEX 3 0 0 0 3 4-13
111
-
112
- TABLE_II_RE = %r{
113
- (?<table>\b
114
- \d{1,2} [ ]+ # Pld
115
- \d{1,3} [ ]+ # Pts
116
- \d{1,2} [ ]+ # W
117
- \d{1,2} [ ]+ # D
118
- \d{1,2} [ ]+ # L
119
- (?: \d{1,3} - [ ]* \d{1,3}) # GF-GA
120
- \b
121
- )}xi
122
-
123
-
124
-
125
- #############################################
126
- # map tables
127
- # note: order matters; first come-first matched/served
128
-
129
- ## possible start lines for a table
130
- ## excludes NOTE
131
- ## and RULER (e.g. --- or) or such in the future
132
- TABLE_RE = Regexp.union(
133
- TABLE_HEADING_I_RE,
134
- TABLE_I_RE,
135
- TABLE_II_RE,
136
- )
137
-
138
- ## all possible continuation for a table
139
- ## excludes HEADING
140
- TABLE_MORE_RE = Regexp.union(
141
- TABLE_NOTE_RE,
142
- TABLE_DIVIDER_RE,
143
- TABLE_I_RE,
144
- TABLE_II_RE,
145
- )
146
-
147
-
148
- end # class Lexer
149
- end # module SportDb