fbtxt-lexer 0.0.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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Manifest.txt +47 -0
  4. data/README.md +18 -0
  5. data/Rakefile +30 -0
  6. data/lib/fbtxt/lexer/debuggable.rb +58 -0
  7. data/lib/fbtxt/lexer/lexer-logger.rb +20 -0
  8. data/lib/fbtxt/lexer/lexer-on_goal.rb +167 -0
  9. data/lib/fbtxt/lexer/lexer-on_group_def.rb +31 -0
  10. data/lib/fbtxt/lexer/lexer-on_prop_cards.rb +61 -0
  11. data/lib/fbtxt/lexer/lexer-on_prop_lineup.rb +82 -0
  12. data/lib/fbtxt/lexer/lexer-on_prop_misc.rb +108 -0
  13. data/lib/fbtxt/lexer/lexer-on_prop_penalties.rb +44 -0
  14. data/lib/fbtxt/lexer/lexer-on_round_def.rb +37 -0
  15. data/lib/fbtxt/lexer/lexer-on_top.rb +133 -0
  16. data/lib/fbtxt/lexer/lexer-prep_doc.rb +131 -0
  17. data/lib/fbtxt/lexer/lexer-prep_line.rb +63 -0
  18. data/lib/fbtxt/lexer/lexer-props.rb +66 -0
  19. data/lib/fbtxt/lexer/lexer-tokenize_line.rb +381 -0
  20. data/lib/fbtxt/lexer/lexer-tokenize_norm.rb +93 -0
  21. data/lib/fbtxt/lexer/lexer.rb +192 -0
  22. data/lib/fbtxt/lexer/lexer_buffer.rb +68 -0
  23. data/lib/fbtxt/lexer/lexer_context.rb +70 -0
  24. data/lib/fbtxt/lexer/lexer_token.rb +127 -0
  25. data/lib/fbtxt/lexer/token-date--helpers.rb +130 -0
  26. data/lib/fbtxt/lexer/token-date--names.rb +108 -0
  27. data/lib/fbtxt/lexer/token-date.rb +200 -0
  28. data/lib/fbtxt/lexer/token-date_duration.rb +171 -0
  29. data/lib/fbtxt/lexer/token-geo.rb +173 -0
  30. data/lib/fbtxt/lexer/token-goals--helpers.rb +114 -0
  31. data/lib/fbtxt/lexer/token-goals.rb +306 -0
  32. data/lib/fbtxt/lexer/token-group.rb +29 -0
  33. data/lib/fbtxt/lexer/token-note.rb +40 -0
  34. data/lib/fbtxt/lexer/token-prop.rb +334 -0
  35. data/lib/fbtxt/lexer/token-prop_name.rb +83 -0
  36. data/lib/fbtxt/lexer/token-round.rb +88 -0
  37. data/lib/fbtxt/lexer/token-score--helpers.rb +189 -0
  38. data/lib/fbtxt/lexer/token-score.rb +60 -0
  39. data/lib/fbtxt/lexer/token-score_full.rb +331 -0
  40. data/lib/fbtxt/lexer/token-score_fuller.rb +434 -0
  41. data/lib/fbtxt/lexer/token-score_legs.rb +59 -0
  42. data/lib/fbtxt/lexer/token-status.rb +192 -0
  43. data/lib/fbtxt/lexer/token-status_inline.rb +112 -0
  44. data/lib/fbtxt/lexer/token-text.rb +221 -0
  45. data/lib/fbtxt/lexer/token-time.rb +144 -0
  46. data/lib/fbtxt/lexer/token.rb +224 -0
  47. data/lib/fbtxt/lexer/version.rb +24 -0
  48. data/lib/fbtxt/lexer.rb +118 -0
  49. metadata +142 -0
@@ -0,0 +1,306 @@
1
+ module Fbtxt
2
+ class Lexer
3
+
4
+
5
+ ######################################################
6
+ ## goal mode
7
+ ## note - must be enclosed in ()!!!
8
+ ##
9
+ ## todo - add () in basics - why? why not?
10
+
11
+
12
+
13
+
14
+ ## note - assume lines starting with opening ( are goal lines!!!!
15
+ ## note - use \A (instead of ^) - \A strictly matches the start of the string.
16
+ ##
17
+ ## note - check for negative lookahead
18
+ ## to exclude ord (numbers) e.g. (1), (42), etc.!!!
19
+ ##
20
+ ## todo/fix -- exclude (a), (h), (n) - TEAM_AWAY, TEAM_HOME, TEAM_NEUTRAL tokens!!
21
+
22
+ START_GOAL_LINE_RE = %r{
23
+ \A
24
+ [ ]* ## ignore leading spaces (if any)
25
+ \(
26
+
27
+ # check NEGATIVE lookahead
28
+ (?!
29
+ ## exclude (a), (h), (n)
30
+ ## TEAM_AWAY, TEAM_HOME, TEAM_NEUTRAL
31
+ (?: a|h|n )
32
+ \)
33
+ )
34
+
35
+ }xi
36
+
37
+
38
+
39
+ #############
40
+ ## check for goal compat(ility) "legacy" line
41
+ ## e.g.
42
+ ## (6' Puskás 0-1, 9' Czibor 0-2, 11' Morlock 1-2, 18' Rahn 2-2,
43
+ ## 84' Rahn 3-2)
44
+ ## (6 Puskás 0-1, 9 Czibor 0-2, 11 Morlock 1-2, 18 Rahn 2-2,
45
+ ## 84 Rahn 3-2)
46
+
47
+
48
+ START_GOAL_LINE_COMPAT_RE = %r{
49
+ \A
50
+ [ ]* ## ignore leading spaces (if any)
51
+ \(
52
+
53
+ ## (i) check NEGATIVE lookahead
54
+ ## exclude score e.g. 1-1 etc.
55
+ (?! [ ]* \b \d-\d \b)
56
+
57
+ ## (ii) check POSITIVE lookahead
58
+ (?= [ ]*
59
+ \d{1,3}
60
+ '? ## optional minute marker
61
+ (?: \+
62
+ \d{1,2}
63
+ '? ## optional minute marker
64
+ )?
65
+ )
66
+ }xi
67
+
68
+
69
+
70
+ ###
71
+ ## check for goal line (alternate syntax)
72
+ ## (1-0 Player, 1-1 Player, ...)
73
+ # must start-off OR yes, include score
74
+ ##
75
+ ## note - allow "centered" style e.g.
76
+ ## ( Player 44' (p) 1-0
77
+ ## 1-1 Player 64' )
78
+ START_GOAL_LINE_ALT_RE = %r{
79
+ \A
80
+ [ ]* ## ignore leading spaces (if any)
81
+ \(
82
+
83
+ # check POSITIVE lookahead
84
+ (?= .*? ## note - non-greedy
85
+ \b \d-\d \b ## score e.g. 0-1
86
+ )
87
+ }xi
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ ###
96
+ # note - alternate goal separator dash (-) MUST have leading and trailing space!!!
97
+ # e.g. (Metzger 83 - Krämer 29, 88, Cichy 33, Rahn 37)
98
+ # e.g. (Metzger - Krämer (2), Cichy, Rahn)
99
+ # (Brunnenmeier 17 - Gerwien 74)
100
+ # (Brunnenmeier - Gerwien)
101
+ # that is, NOT allowed
102
+ # e.g. (Metzger 83-Krämer 29, 88, Cichy 33, Rahn 37)
103
+ # (Brunnenmeier 17-Gerwien 74)
104
+ # (Brunnenmeier-Gerwien)
105
+ #
106
+ # note - allow split by - e.g.
107
+ # Frankfurt 4-2 Schalke (Kreß 45, Solz 55, Trimhold 58, Huberts 73 p -
108
+ # Berz 7, Herrmann 74)
109
+
110
+
111
+ GOAL_SEP_ALT_RE = %r{
112
+ (?<goal_sep_alt>
113
+ (?<=[ ]) ## positive lookbehind - space required
114
+ -
115
+ (?=[ ]|\z) ## positive lookahead - speace required
116
+ )}x
117
+
118
+
119
+ ## e.g. (2)
120
+ ## (2/p), (2/pen.), (3/2p), (3/ 2 pen.)
121
+ ## -or- (2,1pen), (3, 2 pens)
122
+ ##
123
+ ## (p), (pen.) (2 pen.), (2p)
124
+ ## (og), (o.g.),
125
+ ## (2og), (2 o.g.), (2ogs)
126
+ #
127
+ ##
128
+
129
+ GOAL_COUNT_RE = %r{
130
+ (?<goal_count>
131
+ \(
132
+ (?:
133
+ ## opt penalties
134
+ (?<pen>
135
+ (?: (?<pen_value> \d{1,2}) [ ]? )?
136
+ (?:pens|pen\.?|p)
137
+ )
138
+ |
139
+ ## opt own goals (og)
140
+ (?<og>
141
+ (?: (?<og_value> \d{1,2}) [ ]? )?
142
+ (?:ogs?|o\.g\.|o)
143
+ )
144
+ |
145
+ ## opt fallback - classic count/number
146
+ (?: (?<value> [1-9])
147
+ ## check for option penalties
148
+ (?<pen>
149
+ [,/] [ ]*
150
+ (?: (?<pen_value> \d{1,2}) [ ]? )?
151
+ (?:pens|pen\.?|p)
152
+ )?
153
+ )
154
+ )
155
+ \)
156
+ )}ix
157
+
158
+
159
+
160
+
161
+ ##
162
+ ## note - inline \b check in MINUTE_RE excludes
163
+ ## 85pen or 90+4pen or 38p
164
+ ## (possible and NOT excluded in GOAL_MINUTE_RE !!!)
165
+ ##
166
+ ## minute with optional stoppage (offset)
167
+
168
+ MINUTE_RE = %r{
169
+ (?<minute>
170
+ \b
171
+ (?<value>\d{1,3}) ## constrain numbers to 0 to 999!!!
172
+ \b
173
+ '? ## optional minute marker
174
+
175
+ (?: \+ (?<value2>\d{1,2})
176
+ \b
177
+ '? ## optional minute marker
178
+ )?
179
+ )
180
+ }ix
181
+
182
+
183
+
184
+ ##
185
+ ## keep separate? or add simply inside GOAL_MINUTE_RE - why? why not?
186
+ ## fix-fix-fix - move into GOAL_MINUTE_RE !!!
187
+
188
+ GOAL_MINUTE_NA_RE = %r{
189
+ (?<goal_minute_na>
190
+
191
+ # positive lookbehind
192
+ (?<=[ ,;])
193
+
194
+ (?<value> \?{1,2})
195
+ '? ## optional minute marker
196
+ ## note - add goal minute qualifiers here inline!!!
197
+ (?:
198
+ (?: [ ]? (?<og> (?: \((?:og|o\.g\.|o)\)) ## allow (og)
199
+ |
200
+ (?: (?:og|o\.g\.|o)) ## allow plain og
201
+ )
202
+ )
203
+ |
204
+ (?: [ ]? (?<pen> (?: \((?:pen\.?|p)\)) ## allow ()
205
+ |
206
+ (?: (?:pen\.?|p))
207
+ )
208
+ )
209
+ |
210
+ ## add experimental header qualifier
211
+ (?: [ ]? (?<hdr> \( (?:hdr\.?|h ) \) | (?: hdr\.?|h ) ))
212
+ |
213
+ ## add experimental free kick qualifier
214
+ (?: [ ]? (?<fk> \( (?:fk\.?|f ) \) | (?: fk\.?|f) ))
215
+ )?
216
+
217
+ ## note - check positive lookahead
218
+ (?=[ ,;)]|$)
219
+ )
220
+ }ix
221
+
222
+
223
+ ## goal types
224
+ # (pen.) or (pen) or (p.) or (p)
225
+ ## (o.g.) or (og)
226
+ ## todo/check - keep case-insensitive
227
+ ## or allow OG or P or PEN or
228
+ ## only lower case - why? why not?
229
+ ##
230
+ ## add (gg) for golden goal - why? why not?
231
+ ## add (sg) for silver goal - why? why not??
232
+
233
+ GOAL_MINUTE_RE = %r{
234
+ (?<goal_minute>
235
+ \b
236
+ (?<value>\d{1,3}) ## constrain numbers to 0 to 999!!!
237
+ '? ## optional minute marker
238
+
239
+ (?: \+ (?<value2>\d{1,2})
240
+ '? ## optional minute marker
241
+ )?
242
+
243
+ ## note - add goal minute qualifiers here inline!!!
244
+ (?:
245
+ (?: [ ]? (?<og> (?: \((?:og|o\.g\.|o)\)) ## allow (og)
246
+ |
247
+ (?: (?:og|o\.g\.|o)) ## allow plain og
248
+ )
249
+ )
250
+ |
251
+ (?: [ ]? (?<pen> (?: \((?:pen\.?|p)\)) ## allow ()
252
+ |
253
+ (?: (?:pen\.?|p))
254
+ )
255
+ )
256
+ |
257
+ ## add experimental header qualifier
258
+ (?: [ ]? (?<hdr> \( (?:hdr\.?|h ) \) | (?: hdr\.?|h ) ))
259
+ |
260
+ ## add experimental free kick qualifier
261
+ (?: [ ]? (?<fk> \( (?:fk\.?|f ) \) | (?: fk\.?|f) ))
262
+ )?
263
+
264
+ ## add experimental seconds
265
+ ## e.g. (95 secs) or (95sec) etc.
266
+ (?: [ ]* \(
267
+ (?<secs>\d{1,3})
268
+ [ ]?secs?
269
+ \)
270
+ )?
271
+ )
272
+
273
+ ## note - check positive lookahead
274
+ (?=[ ,;)]|$)
275
+ }ix
276
+
277
+
278
+
279
+
280
+
281
+ ###
282
+ ## more regex for goal alt
283
+
284
+
285
+ GOAL_TYPE_RE = %r{
286
+ (?<goal_type>
287
+ \(
288
+ (?:
289
+ (?<og> og|o\.g\.|o )
290
+ |
291
+ (?<pen> pen\.?|p )
292
+ |
293
+ ## add experimental header qualifier
294
+ (?<hdr> hdr\.?|h )
295
+ |
296
+ ## add experimental free kick qualifier
297
+ (?<fk> fk\.?|f )
298
+ )
299
+ \)
300
+ )}xi
301
+
302
+
303
+
304
+
305
+ end # class Lexer
306
+ end # module Fbtxt
@@ -0,0 +1,29 @@
1
+ module Fbtxt
2
+ class Lexer
3
+
4
+
5
+ ###
6
+ # check for start of group def line e.g.
7
+ # Group A | ...
8
+ # Group 1 : ....
9
+ # Group A2 | ....
10
+ ## note - use \A (instead of ^) - \A strictly matches the start of the string.
11
+
12
+ START_WITH_GROUP_DEF_LINE_RE = %r{
13
+ \A
14
+ [ ]* ## ignore leading spaces (if any)
15
+ (?<group_def>
16
+ Group
17
+ [ ]
18
+ [a-z0-9]+ ## todo/check - allow dot (.) too e.g. 1.A etc.- why? why not?
19
+ )
20
+ ### positive lookahead MUST be : OR |
21
+ (?= [ ]*
22
+ [:|]
23
+ [ ]) ## note: requires space for now after [:|] - keep - why? why not?
24
+ }ix
25
+
26
+
27
+
28
+ end # class Lexer
29
+ end # module Fbtxt
@@ -0,0 +1,40 @@
1
+ module Fbtxt
2
+ class Lexer
3
+
4
+
5
+ ### fix - use (?<text>) - text capture for inner text!!
6
+ ## use (?<note> for complete match as a convention!! )
7
+ NOTE_RE = %r{
8
+ \[
9
+ (?<note>
10
+ [^\[\]\#]*? ## note - non-greedy/lazy operator
11
+ ## exclude comments inside note block - why? why not?
12
+ )
13
+ \]
14
+ }xi
15
+
16
+
17
+ ####
18
+ ## fix - change NOTE_RE to MATCH_NOTE_RE !!!!
19
+ ## and change NOTA_BENE_RE to NOTE_RE !!!
20
+
21
+
22
+
23
+ ## check for "literal" (multi-line) note blocks
24
+ ## eg. nb: or note:
25
+ ## space required after double colon - why? why not?
26
+ ##
27
+ ## note - use \A (instead of ^) - \A strictly matches the start of the string.
28
+ NOTA_BENE_RE = %r{ \A
29
+ [ ]* ## ignore leading spaces (if any)
30
+ (?: nb | note) [ ]* : [ ]+
31
+ (?<nota_bene>
32
+ .+? ## use non-greedy
33
+ )
34
+ [ ]* ## ignore trailing spaces (if any)
35
+ \z
36
+ }xi
37
+
38
+
39
+ end # class Lexer
40
+ end # module Fbtxt
@@ -0,0 +1,334 @@
1
+ ###
2
+ ## team prop mode e.g.
3
+ ##
4
+ ##
5
+ ## Fri Jun 14 21:00 @ München Fußball Arena, München
6
+ ## Germany v Scotland 5-1 (3-0)
7
+ ## (Wirtz 10' Musiala 19' Havertz 45+1' (pen.) Füllkrug 68' Can 90+3'; Rüdiger 87' (o.g.))
8
+ ##
9
+ ## Germany: Neuer - Kimmich, Rüdiger, Tah [Y], Mittelstädt - Andrich [Y] (Groß 46'),
10
+ ## Kroos (Can 80') - Musiala (Müller 74'), Gündogan, Wirtz (Sane 63') -
11
+ ## Havertz (Füllkrug 63')
12
+ ## Scotland: Gunn - Porteous [R 44'], Hendry, Tierney (McKenna 78') - Ralston [Y],
13
+ ## McTominay, McGregor (Gilmour 67'), Robertson - Christie (Shankland 82'),
14
+ ## Adams (Hanley 46'), McGinn (McLean 67')
15
+
16
+
17
+ module Fbtxt
18
+ class Lexer
19
+
20
+
21
+ ##############
22
+ # add support for props/ attributes e.g.
23
+ #
24
+ # Germany: Neuer - Kimmich, Rüdiger, Tah [Y], Mittelstädt - Andrich [Y] (46' Groß),
25
+ # Kroos (80' Can) - Musiala (74' Müller), Gündogan,
26
+ # Wirtz (63' Sane) - Havertz (63' Füllkrug)
27
+ # Scotland: Gunn - Porteous [R 44'], Hendry, Tierney (78' McKenna) - Ralston [Y],
28
+ # McTominay, McGregor (67' Gilmour), Robertson - Christie (82' Shankland),
29
+ # Adams (46' Hanley), McGinn (67' McLean)
30
+ #
31
+ ## note: colon (:) MUST be followed by one (or more) spaces
32
+ ## make sure mon feb 12 18:10 will not match
33
+ ## allow 1. FC Köln etc.
34
+ ## Mainz 05:
35
+ ## limit to 30 chars max
36
+ ## only allow chars incl. intl but (NOT ()[]/;)
37
+ ##
38
+ ##
39
+ ## note - use special \G - Matches first matching position !!!!
40
+ ## check for \G like backreference of regex tokens/parts if possible/available in ruby?
41
+
42
+
43
+
44
+ ## (i) starting w/ letters
45
+ ## note - incl./allows digits (0-9)
46
+ ## e.g. a1, a2000, etc.
47
+ ##
48
+ ## note - added back optional trailing dot (.) for abbrev. word !!!
49
+ PROP_KEY_WORD_ = %r{
50
+ \p{L}
51
+ [\p{L}\d]*
52
+ \.?
53
+ }ix
54
+
55
+ ## note - incl. optional dot or numsign e.g. 1. or 1°
56
+ PROP_KEY_NUM_ = %r{
57
+ \d+
58
+ [.°]?
59
+ }ix
60
+
61
+ ## e.g. 1A, 1FC etc.
62
+ ## note - no trailing dot (.) for now - check if any cases exist in real world
63
+ PROP_KEY_NUMALPHA_ = %r{
64
+ \d+
65
+ \p{L}
66
+ [\p{L}\d]*
67
+ }ix
68
+
69
+
70
+
71
+
72
+
73
+ START_WITH_PROP_KEY_RE = %r{
74
+ \A ## note - MUST start line; leading spaces optional (eat-up)
75
+ (?<prop_key>
76
+ [ ]* ## optional leading spaces
77
+ (?<key>
78
+ (?:
79
+ ## (i) starting w/ letters
80
+ #{PROP_KEY_WORD_}
81
+
82
+ ## (ii) starting w/ number
83
+ ## e.g. 1fc, 1a,
84
+ | #{PROP_KEY_NUMALPHA_}
85
+ ## followed by optional dot) and
86
+ ## optional space
87
+ ## MUST be follow by letter (a to z)!!!!
88
+ ## eg. 1[ fc], 1.[ fc], 1.[fc], etc.
89
+ | #{PROP_KEY_NUM_} (?= [ ]? \p{L})
90
+ )
91
+ (?:
92
+ ## connectors - note - no dot (.), must match with abbrev word or num!!
93
+ (?: ## (i) single space or WITHOUT surrounding spaces!! - slash (/), dash (-)
94
+ ## e.g. do NOT match one - two or one / two
95
+ ## only one-two or one/two
96
+
97
+ [ /-]
98
+
99
+ ## (ii) surrounded by leading or trailing optional space
100
+ ## c & a, etc.
101
+ ## d'ivoire, d' ivoire
102
+ ## borusia 'gladbach etc.
103
+ ## exclude space ' space - why? why not? (or ignore for now)
104
+ ##
105
+ ## check for quotes ('') - not realy supported here
106
+ ## e.g. leading or trailing ' will NOT match
107
+
108
+ | [ ]? & [ ]?
109
+ | [ ]? '
110
+ | ' [ ]?
111
+
112
+ #### (iii)
113
+ ## note - special "hack" to connect WITHOUT space
114
+ ## for Union 1.FC and SKN St.Pölten or St.Pölten
115
+ ## connects 1.FC => NUM+WORD
116
+ ## 1°Mayo => NUM+WORD
117
+ ## St.Pölten => ABBREV+WORD
118
+ ##
119
+ ## note - match WITHOUT (space) connector
120
+ ## 1.FC (Union 1.FC Stein)
121
+ ## [WORD: "Union"], [NUM: "1."], [WORD: "FC"]
122
+ ## St.Pölten (SKN St.Pölten)
123
+ ## [WORD: "SKN"], [ABBREV: "St."], [WORD: "Pölten"]
124
+ | (?<= [.°] )
125
+ (?= \p{L})
126
+ )
127
+ (?:
128
+ #{PROP_KEY_NUMALPHA_}
129
+ | #{PROP_KEY_NUM_}
130
+ | #{PROP_KEY_WORD_}
131
+ )
132
+ )*
133
+ ) ## close <key> capture
134
+ [ ]*? ## slurp trailing spaces
135
+ :
136
+
137
+ ## positive lookahead (must be followed by space!!)
138
+ ## or allow end-of-line too
139
+ (?= [ ]+|$)
140
+ ) ## close <prop_key> capture
141
+ }ix
142
+
143
+
144
+
145
+ #####
146
+ # (tactics) formation - possible with two numbers (e.g. 5-5 ?? or 8-2)
147
+ ## e.g (4-3-3) or (433)
148
+ ## (4-1-4-1) or (4141)
149
+ ## etc.
150
+
151
+ FORMATION_RE = %r{
152
+ (?<formation>
153
+ \(
154
+ (?<value>
155
+ (?: [1-9] (?: -[1-9]){1,5} )
156
+ | (?: [1-9]{2,6})
157
+ )
158
+ \)
159
+ )
160
+ }x
161
+
162
+
163
+
164
+
165
+ ################
166
+ ## todo/check - use token for card short cuts?
167
+ ## if m[:name] == 'Y'
168
+ ## [:YELLOW_CARD, m[:name]]
169
+ ## elsif m[:name] == 'R'
170
+ ## [:RED_CARD, m[:name]]
171
+ ## - [Y], [R], [Y/R] Yellow-Red Card
172
+ ## check if minutes possible inside [Y 46']
173
+ ## add [c] for captain too
174
+
175
+
176
+ ## [c] or [C] for marking player as captain
177
+ ## support [y ] too - or require Y - why? why not?
178
+ INLINE_CAPTAIN = %r{ (?<inline_captain>
179
+ \[ [cC] \]
180
+ )}x
181
+
182
+ INLINE_YELLOW = %r{ (?<inline_yellow>
183
+ \[ [yY]
184
+ ## optional minute
185
+ (?: [ ]+
186
+ (?<minute> \d{1,3})
187
+ '?
188
+ (?:
189
+ \+
190
+ (?<offset>\d{1,2})
191
+ '?
192
+ )?
193
+ )?
194
+ \]
195
+ )}x
196
+
197
+ INLINE_RED = %r{ (?<inline_red>
198
+ \[ [rR]
199
+ ## optional minute
200
+ (?: [ ]+
201
+ (?<minute> \d{1,3})
202
+ '?
203
+ (?:
204
+ \+
205
+ (?<offset>\d{1,2})
206
+ '?
207
+ )?
208
+ )?
209
+ \]
210
+ )}x
211
+
212
+ ##
213
+ ## note make slash (/) optionals
214
+ ## e.g. y/r,yr or Y/R,YR
215
+
216
+ INLINE_YELLOW_RED = %r{ (?<inline_yellow_red>
217
+ \[ (?: y/?r | Y/?R)
218
+ ## optional minute
219
+ (?: [ ]+
220
+ (?<minute> \d{1,3})
221
+ '?
222
+ (?:
223
+ \+
224
+ (?<offset>\d{1,2})
225
+ '?
226
+ )?
227
+ )?
228
+ \]
229
+ )}x
230
+
231
+
232
+
233
+
234
+ ### simple prop key for inline use e.g.
235
+ ### Coach: or Trainer: or ... add more here later
236
+
237
+ PROP_KEY_INLINE_RE = %r{
238
+ \b
239
+ (?<prop_key> ## note: use prop_key (NOT prop_key_inline or such)
240
+ (?<key>
241
+ \p{L}+
242
+ )
243
+ ## note - NO spaces allowed for key for now!!!
244
+ :
245
+ ## possitive lookahead (must be followed by space!!)
246
+ (?=[ ]+)
247
+ )
248
+ }ix
249
+
250
+
251
+
252
+ ## note allow underscore inline e.g.
253
+ ## 5_000
254
+ ## discuss/check - allow space inline (e.g. 5 000) - why? why not?
255
+
256
+ PROP_NUM_RE = %r{
257
+ \b
258
+ (?<num>
259
+ (?<value> [0-9]+
260
+ (?: _ [0-9]+)*
261
+ )
262
+ )
263
+ \b
264
+ }x
265
+
266
+
267
+ ### todo/fix - allow more chars in enclosed name - why? why not?
268
+ ## e.g. (') - Cote D'Ivore etc.
269
+ ## change to PAREN_NAME or PARENTHESIS or such - why? why not?
270
+ ENCLOSED_NAME_RE = %r{
271
+ (?<enclosed_name>
272
+ \(
273
+ (?<name>
274
+ \p{L}+
275
+ (?:
276
+ [ ]
277
+ \p{L}+
278
+ )*
279
+ )
280
+ \)
281
+ )
282
+ }ix
283
+
284
+
285
+
286
+
287
+ ###
288
+ ## e.g. -; ... or
289
+ ## None - ... or
290
+ CARDS_NONE_LEFT_RE = %r{ (?<cards_none_left>
291
+ ## (i) w/ semicolon (;)
292
+ (?: (?: - | \bnone)
293
+ [ ]* ;
294
+ )
295
+ ## (ii) w/ dash (-)
296
+ | (?: (?: ∅ | \bnone)
297
+ [ ]+ - ## space REQUIRED
298
+ (?=[ ]|\z) ## positive lookahead - speace required
299
+ )
300
+ )}ix
301
+
302
+ ## e.g ... ;-
303
+ ## or ... ; None
304
+ CARDS_NONE_RIGHT_RE = %r{ (?<cards_none_right>
305
+ ## (i) w/ semicolon (;)
306
+ (?: ; [ ]*
307
+ (?: - | none\b)
308
+ )
309
+ ## (ii) w/ dash (-)
310
+ | (?:
311
+ (?<=[ ]) ## positive lookbehind - space required
312
+ - [ ]+ ## space REQUIRED
313
+ (?: ∅ | none\b)
314
+ )
315
+ )}ix
316
+
317
+
318
+ CARDS_SEP_ALT_RE = %r{(?<cards_sep_alt>
319
+ (?<=[ ]) ## positive lookbehind - space required
320
+ -
321
+ (?=[ ]|\z) ## positive lookahead - speace required
322
+ )}x
323
+
324
+ PENALTIES_SEP_ALT_RE = %r{(?<penalties_sep_alt>
325
+ (?<=[ ]) ## positive lookbehind - space required
326
+ -
327
+ (?=[ ]|\z) ## positive lookahead - speace required
328
+ )}x
329
+
330
+
331
+
332
+
333
+ end # class Lexer
334
+ end # module Fbtxt