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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +25 -7
- data/Rakefile +23 -0
- data/lib/sportdb/parser/debuggable.rb +53 -0
- data/lib/sportdb/parser/lexer-logger.rb +20 -0
- data/lib/sportdb/parser/lexer-on_goal.rb +167 -0
- data/lib/sportdb/parser/lexer-on_group_def.rb +31 -0
- data/lib/sportdb/parser/lexer-on_prop_lineup.rb +79 -0
- data/lib/sportdb/parser/lexer-on_prop_misc.rb +123 -0
- data/lib/sportdb/parser/lexer-on_prop_penalties.rb +40 -0
- data/lib/sportdb/parser/lexer-on_round_def.rb +37 -0
- data/lib/sportdb/parser/lexer-on_top.rb +133 -0
- data/lib/sportdb/parser/lexer-prep_doc.rb +131 -0
- data/lib/sportdb/parser/lexer-prep_line.rb +63 -0
- data/lib/sportdb/parser/lexer-tokenize.rb +468 -0
- data/lib/sportdb/parser/lexer.rb +122 -1376
- data/lib/sportdb/parser/lexer_buffer.rb +8 -37
- data/lib/sportdb/parser/lexer_token.rb +126 -0
- data/lib/sportdb/parser/parse_tree--core.rb +29 -0
- data/lib/sportdb/parser/parse_tree-match.rb +309 -0
- data/lib/sportdb/parser/parse_tree-props.rb +233 -0
- data/lib/sportdb/parser/parse_tree.rb +202 -0
- data/lib/sportdb/parser/parser-top.rb +102 -0
- data/lib/sportdb/parser/parser.rb +1253 -1392
- data/lib/sportdb/parser/token-date--helpers.rb +130 -0
- data/lib/sportdb/parser/token-date--names.rb +108 -0
- data/lib/sportdb/parser/token-date.rb +20 -192
- data/lib/sportdb/parser/token-date_duration.rb +8 -27
- data/lib/sportdb/parser/token-geo.rb +16 -16
- data/lib/sportdb/parser/token-goals--helpers.rb +114 -0
- data/lib/sportdb/parser/token-goals.rb +101 -255
- data/lib/sportdb/parser/token-group.rb +8 -22
- data/lib/sportdb/parser/token-prop.rb +178 -124
- data/lib/sportdb/parser/token-prop_name.rb +48 -39
- data/lib/sportdb/parser/token-round.rb +21 -35
- data/lib/sportdb/parser/token-score--helpers.rb +189 -0
- data/lib/sportdb/parser/token-score.rb +9 -393
- data/lib/sportdb/parser/token-score_full.rb +331 -0
- data/lib/sportdb/parser/token-status.rb +44 -46
- data/lib/sportdb/parser/token-status_inline.rb +112 -0
- data/lib/sportdb/parser/token-text.rb +41 -31
- data/lib/sportdb/parser/token-time.rb +29 -26
- data/lib/sportdb/parser/token.rb +90 -158
- data/lib/sportdb/parser/version.rb +2 -2
- data/lib/sportdb/parser.rb +88 -62
- metadata +27 -9
- data/lib/sportdb/parser/blocktxt.rb +0 -99
- data/lib/sportdb/parser/lexer_tty.rb +0 -111
- data/lib/sportdb/parser/racc_parser.rb +0 -88
- data/lib/sportdb/parser/racc_tree.rb +0 -557
- data/lib/sportdb/parser/token-table.rb +0 -149
- data/lib/sportdb/parser/token_helpers.rb +0 -92
- /data/lib/sportdb/parser/{parser_runtime.rb → parser-runtime.rb} +0 -0
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
module SportDb
|
|
2
|
-
class Lexer
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
=begin
|
|
6
|
-
def self._mk_is( re )
|
|
7
|
-
## add \A ... \z to regex
|
|
8
|
-
## for strict matching of beginning and end of string
|
|
9
|
-
## regex note - \z will NOT allow trailing newline(s)!!!!
|
|
10
|
-
## note - must double espace \\A,\\z in quoted string!!
|
|
11
|
-
Regexp.new( %Q< \\A
|
|
12
|
-
(?:#{re.source})
|
|
13
|
-
\\z
|
|
14
|
-
>, re.options )
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
IS_TEAM_RE = _mk_is( TEXT_RE ) ## todo/fix - rename TEXT_RE to TEAM_RE!!!
|
|
19
|
-
IS_DATE_RE = _mk_is( DATE_IIII_RE ) ## DATE_RE )
|
|
20
|
-
=end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def self._parse_team( str )
|
|
24
|
-
## note - strip - leading/trailing spaces
|
|
25
|
-
m = TEXT_RE.match( str.strip )
|
|
26
|
-
if m && m.pre_match == '' && m.post_match == ''
|
|
27
|
-
m
|
|
28
|
-
elsif m
|
|
29
|
-
## note - match BUT not anchored to start and end-of-string!!!
|
|
30
|
-
## report, error somehow??
|
|
31
|
-
nil
|
|
32
|
-
else
|
|
33
|
-
nil ## no match - return nil
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def self._parse_date( str )
|
|
39
|
-
## note - strip - leading/trailing spaces
|
|
40
|
-
m = DATE_RE.match( str.strip )
|
|
41
|
-
|
|
42
|
-
#### todo/fix/check:
|
|
43
|
-
### wrapped with \A \z NOT working with union - check later - why?
|
|
44
|
-
### use hand-coded with pre_match = "" and post_match = ""
|
|
45
|
-
|
|
46
|
-
if m && m.pre_match == '' && m.post_match == ''
|
|
47
|
-
## return hash table with captured components
|
|
48
|
-
date = {}
|
|
49
|
-
## map month names
|
|
50
|
-
## note - allow any/upcase JULY/JUL etc. thus ALWAYS downcase for lookup
|
|
51
|
-
date[:y] = m[:year].to_i(10) if m[:year]
|
|
52
|
-
## check - use y too for two-digit year or keep separate - why? why not?
|
|
53
|
-
date[:yy] = m[:yy].to_i(10) if m[:yy] ## two digit year (e.g. 25 or 78 etc.)
|
|
54
|
-
date[:m] = m[:month].to_i(10) if m[:month]
|
|
55
|
-
date[:m] = MONTH_MAP[ m[:month_name].downcase ] if m[:month_name]
|
|
56
|
-
date[:d] = m[:day].to_i(10) if m[:day]
|
|
57
|
-
date[:wday] = DAY_MAP[ m[:day_name].downcase ] if m[:day_name]
|
|
58
|
-
date
|
|
59
|
-
elsif m
|
|
60
|
-
## note - match BUT not anchored to start and end-of-string!!!
|
|
61
|
-
## report, error somehow??
|
|
62
|
-
nil
|
|
63
|
-
else
|
|
64
|
-
nil ## no match - return nil
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def self._parse_score_full( str )
|
|
70
|
-
## note - strip - leading/trailing spaces
|
|
71
|
-
m=SCORE_FULL_RE.match( str )
|
|
72
|
-
|
|
73
|
-
if m && m.pre_match == '' && m.post_match == ''
|
|
74
|
-
score = {}
|
|
75
|
-
score[:p] = [m[:p1].to_i,m[:p2].to_i] if m[:p1] && m[:p2]
|
|
76
|
-
score[:et] = [m[:et1].to_i,m[:et2].to_i] if m[:et1] && m[:et2]
|
|
77
|
-
score[:ft] = [m[:ft1].to_i,m[:ft2].to_i] if m[:ft1] && m[:ft2]
|
|
78
|
-
score[:ht] = [m[:ht1].to_i,m[:ht2].to_i] if m[:ht1] && m[:ht2]
|
|
79
|
-
## score[:agg] = [m[:agg1].to_i,m[:agg2].to_i] if m[:agg1] && m[:agg2]
|
|
80
|
-
score
|
|
81
|
-
elsif m
|
|
82
|
-
## note - match BUT not anchored to start and end-of-string!!!
|
|
83
|
-
## report, error somehow??
|
|
84
|
-
nil
|
|
85
|
-
else
|
|
86
|
-
nil ## no match - return nil
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
end # class Lexer
|
|
92
|
-
end # module SportDb
|
|
File without changes
|