fbtxt-parser 0.9.0 → 0.9.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 +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Manifest.txt +0 -37
  4. data/README.md +4 -8
  5. data/Rakefile +2 -1
  6. data/lib/fbtxt/parser/parse_tree-match.rb +3 -1
  7. data/lib/fbtxt/parser/parse_tree-props.rb +39 -10
  8. data/lib/fbtxt/parser/parser-top.rb +0 -9
  9. data/lib/fbtxt/parser/parser.rb +879 -843
  10. data/lib/fbtxt/parser/version.rb +1 -1
  11. data/lib/fbtxt/parser.rb +14 -82
  12. metadata +18 -41
  13. data/lib/fbtxt/parser/debuggable.rb +0 -53
  14. data/lib/fbtxt/parser/lexer-logger.rb +0 -20
  15. data/lib/fbtxt/parser/lexer-on_goal.rb +0 -167
  16. data/lib/fbtxt/parser/lexer-on_group_def.rb +0 -31
  17. data/lib/fbtxt/parser/lexer-on_prop_lineup.rb +0 -79
  18. data/lib/fbtxt/parser/lexer-on_prop_misc.rb +0 -123
  19. data/lib/fbtxt/parser/lexer-on_prop_penalties.rb +0 -40
  20. data/lib/fbtxt/parser/lexer-on_round_def.rb +0 -37
  21. data/lib/fbtxt/parser/lexer-on_top.rb +0 -133
  22. data/lib/fbtxt/parser/lexer-prep_doc.rb +0 -131
  23. data/lib/fbtxt/parser/lexer-prep_line.rb +0 -63
  24. data/lib/fbtxt/parser/lexer-tokenize.rb +0 -468
  25. data/lib/fbtxt/parser/lexer.rb +0 -231
  26. data/lib/fbtxt/parser/lexer_buffer.rb +0 -68
  27. data/lib/fbtxt/parser/lexer_token.rb +0 -126
  28. data/lib/fbtxt/parser/token-date--helpers.rb +0 -130
  29. data/lib/fbtxt/parser/token-date--names.rb +0 -108
  30. data/lib/fbtxt/parser/token-date.rb +0 -200
  31. data/lib/fbtxt/parser/token-date_duration.rb +0 -171
  32. data/lib/fbtxt/parser/token-geo.rb +0 -134
  33. data/lib/fbtxt/parser/token-goals--helpers.rb +0 -114
  34. data/lib/fbtxt/parser/token-goals.rb +0 -306
  35. data/lib/fbtxt/parser/token-group.rb +0 -29
  36. data/lib/fbtxt/parser/token-note.rb +0 -40
  37. data/lib/fbtxt/parser/token-prop.rb +0 -309
  38. data/lib/fbtxt/parser/token-prop_name.rb +0 -83
  39. data/lib/fbtxt/parser/token-round.rb +0 -88
  40. data/lib/fbtxt/parser/token-score--helpers.rb +0 -189
  41. data/lib/fbtxt/parser/token-score.rb +0 -60
  42. data/lib/fbtxt/parser/token-score_full.rb +0 -331
  43. data/lib/fbtxt/parser/token-score_fuller.rb +0 -434
  44. data/lib/fbtxt/parser/token-score_legs.rb +0 -59
  45. data/lib/fbtxt/parser/token-status.rb +0 -192
  46. data/lib/fbtxt/parser/token-status_inline.rb +0 -112
  47. data/lib/fbtxt/parser/token-text.rb +0 -221
  48. data/lib/fbtxt/parser/token-time.rb +0 -144
  49. data/lib/fbtxt/parser/token.rb +0 -224
@@ -4,7 +4,7 @@ module Fbtxt
4
4
  module Parser
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 9
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
data/lib/fbtxt/parser.rb CHANGED
@@ -1,83 +1,13 @@
1
- require 'cocos'
2
-
3
1
 
2
+ ####
3
+ # quick hack - always auto-add latest lexer if present for now
4
+ $LOAD_PATH.unshift( '../lexer/lib' )
5
+ require 'fbtxt/lexer'
4
6
 
5
7
 
6
8
  require_relative 'parser/version'
7
9
 
8
10
 
9
- require_relative 'parser/debuggable' ## generic debug/logger helper
10
-
11
-
12
-
13
- ##
14
- ## add shared/most basic regexes here
15
- ## todo - use ANY_RE to token_commons or such - for shared by many?
16
- module Fbtxt
17
- class Lexer
18
-
19
- ## general catch-all (RECOMMENDED (ALWAYS) use as last entry in union)
20
- ## to avoid advance of pos match!!!
21
- ANY_RE = %r{
22
- (?<any> .)
23
- }ix
24
-
25
- SPACES_RE = %r{
26
- (?<spaces> [ ]{2,})
27
- | (?<space> [ ])
28
- }ix
29
-
30
-
31
- end # class Lexer
32
- end # module Fbtxt
33
-
34
-
35
- require_relative 'parser/token-score'
36
- require_relative 'parser/token-score_full'
37
- require_relative 'parser/token-score_fuller'
38
- require_relative 'parser/token-score_legs'
39
- require_relative 'parser/token-score--helpers'
40
-
41
- require_relative 'parser/token-time'
42
- require_relative 'parser/token-date--names'
43
- require_relative 'parser/token-date'
44
- require_relative 'parser/token-date_duration'
45
- require_relative 'parser/token-date--helpers'
46
-
47
- require_relative 'parser/token-text'
48
- require_relative 'parser/token-prop' ## team prop(erty) mode (note - must be before token)
49
- require_relative 'parser/token-prop_name' ## a.k.a token-text_ii
50
- require_relative 'parser/token-status'
51
- require_relative 'parser/token-status_inline'
52
- require_relative 'parser/token-note'
53
- require_relative 'parser/token-goals'
54
- require_relative 'parser/token-goals--helpers'
55
- require_relative 'parser/token-geo'
56
- require_relative 'parser/token-group'
57
- require_relative 'parser/token-round'
58
- require_relative 'parser/token'
59
-
60
-
61
-
62
-
63
-
64
- require_relative 'parser/lexer_buffer' ## incl. Tokens (aka TokenBuffer)
65
- require_relative 'parser/lexer_token'
66
-
67
- require_relative 'parser/lexer-prep_doc'
68
- require_relative 'parser/lexer-prep_line'
69
-
70
- require_relative 'parser/lexer-logger' ## e.g. _trace, _warn, _info, etc.
71
- require_relative 'parser/lexer-tokenize'
72
- require_relative 'parser/lexer-on_round_def'
73
- require_relative 'parser/lexer-on_group_def'
74
- require_relative 'parser/lexer-on_prop_misc'
75
- require_relative 'parser/lexer-on_prop_lineup'
76
- require_relative 'parser/lexer-on_prop_penalties'
77
- require_relative 'parser/lexer-on_goal'
78
- require_relative 'parser/lexer-on_top'
79
- require_relative 'parser/lexer'
80
-
81
11
 
82
12
  ## note - use "embeded" racc parser runtime
83
13
  ## MUST uncomment require 'racc/parser' in generated parser!!!
@@ -114,15 +44,18 @@ RaccMatchParser = Fbtxt::Parser
114
44
  ## or return a Result struct - why? why not?
115
45
 
116
46
 
117
-
118
47
  module Fbtxt
119
48
 
120
- def self.lex( txt, flatten: true ) ## returns Fbtxt::LexerResult (ok?/tokens/errors)
121
- lexer = Lexer.new( txt )
122
- ## move "wrapping" into result obj inside lexer - why? why not?
123
- tokens, errors = lexer.tokenize_with_errors( flatten: flatten )
124
- LexerResult.new( tokens, errors )
125
- end
49
+ class ParserResult
50
+ attr_reader :tree, :errors
51
+ def initialize( tree, errors=[] )
52
+ @tree, @errors = tree, errors
53
+ end
54
+
55
+ def ok?() @errors.size == 0; end
56
+ def nok?() !ok?; end
57
+ end # class ParserResult
58
+
126
59
 
127
60
  def self.parse( txt ) ## returns Fbtxt::ParserResult (ok?/tree/errors)
128
61
  parser = Parser.new( txt )
@@ -136,5 +69,4 @@ end # module Fbtxt
136
69
 
137
70
 
138
71
 
139
-
140
72
  puts Fbtxt::Module::Parser.banner # say hello
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbtxt-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.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: 2026-07-07 00:00:00.000000000 Z
11
+ date: 2026-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.1
19
+ version: 0.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.4.1
26
+ version: 0.4.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: fbtxt-lexer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rdoc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,21 +86,6 @@ files:
72
86
  - README.md
73
87
  - Rakefile
74
88
  - lib/fbtxt/parser.rb
75
- - lib/fbtxt/parser/debuggable.rb
76
- - lib/fbtxt/parser/lexer-logger.rb
77
- - lib/fbtxt/parser/lexer-on_goal.rb
78
- - lib/fbtxt/parser/lexer-on_group_def.rb
79
- - lib/fbtxt/parser/lexer-on_prop_lineup.rb
80
- - lib/fbtxt/parser/lexer-on_prop_misc.rb
81
- - lib/fbtxt/parser/lexer-on_prop_penalties.rb
82
- - lib/fbtxt/parser/lexer-on_round_def.rb
83
- - lib/fbtxt/parser/lexer-on_top.rb
84
- - lib/fbtxt/parser/lexer-prep_doc.rb
85
- - lib/fbtxt/parser/lexer-prep_line.rb
86
- - lib/fbtxt/parser/lexer-tokenize.rb
87
- - lib/fbtxt/parser/lexer.rb
88
- - lib/fbtxt/parser/lexer_buffer.rb
89
- - lib/fbtxt/parser/lexer_token.rb
90
89
  - lib/fbtxt/parser/parse_tree--core.rb
91
90
  - lib/fbtxt/parser/parse_tree-match.rb
92
91
  - lib/fbtxt/parser/parse_tree-props.rb
@@ -94,28 +93,6 @@ files:
94
93
  - lib/fbtxt/parser/parser-runtime.rb
95
94
  - lib/fbtxt/parser/parser-top.rb
96
95
  - lib/fbtxt/parser/parser.rb
97
- - lib/fbtxt/parser/token-date--helpers.rb
98
- - lib/fbtxt/parser/token-date--names.rb
99
- - lib/fbtxt/parser/token-date.rb
100
- - lib/fbtxt/parser/token-date_duration.rb
101
- - lib/fbtxt/parser/token-geo.rb
102
- - lib/fbtxt/parser/token-goals--helpers.rb
103
- - lib/fbtxt/parser/token-goals.rb
104
- - lib/fbtxt/parser/token-group.rb
105
- - lib/fbtxt/parser/token-note.rb
106
- - lib/fbtxt/parser/token-prop.rb
107
- - lib/fbtxt/parser/token-prop_name.rb
108
- - lib/fbtxt/parser/token-round.rb
109
- - lib/fbtxt/parser/token-score--helpers.rb
110
- - lib/fbtxt/parser/token-score.rb
111
- - lib/fbtxt/parser/token-score_full.rb
112
- - lib/fbtxt/parser/token-score_fuller.rb
113
- - lib/fbtxt/parser/token-score_legs.rb
114
- - lib/fbtxt/parser/token-status.rb
115
- - lib/fbtxt/parser/token-status_inline.rb
116
- - lib/fbtxt/parser/token-text.rb
117
- - lib/fbtxt/parser/token-time.rb
118
- - lib/fbtxt/parser/token.rb
119
96
  - lib/fbtxt/parser/version.rb
120
97
  homepage: https://github.com/sportdb/sport.db
121
98
  licenses:
@@ -1,53 +0,0 @@
1
- ###
2
- ## debugg(able) mix-in helper
3
- ## used for lexer & parser
4
-
5
- module Debuggable
6
- def self.included(base)
7
- base.extend(ClassMethods)
8
- end
9
-
10
- module ClassMethods
11
- def debug=(value)
12
- raise ArgumentError, "true|false required for debug flag; got #{value}" unless value.is_a?(TrueClass) || value.is_a?(FalseClass)
13
- @debug=value;
14
- end
15
- def debug() @debug || false; end ## note - default to false
16
-
17
- def debug?() @debug == true; end
18
- end
19
-
20
-
21
- ########
22
- ## InstanceMethods
23
- def debug?() self.class.debug?; end
24
-
25
- ##
26
- ## todo/check - allow/support multiple msg args - why? why not?
27
-
28
- ## note - use trace for debug for now - why? why not?
29
- def _trace( *args ) __log__( :DEBUG, *args ); end
30
-
31
- def _info( *args ) __log__( :INFO, *args ); end
32
- def _warn( *args) __log__( :WARN, *args ); end
33
- def _error( *args ) __log__( :ERROR, *args ); end
34
-
35
-
36
-
37
- private
38
- def __log__( level, *args ) ## :DEBUG, :INFO, :WARN, :ERROR, :FATAL etc.
39
-
40
- if level == :DEBUG && !debug?
41
- ## print nothing
42
- else
43
- msg = args.map do |arg|
44
- arg.to_str
45
- end.join(' | ')
46
-
47
- fout = level == :WARN || level == :ERROR || level == :FATAL ? STDERR : STDOUT
48
-
49
- ## todo/check/fix - add/use/check for "local" logger
50
- fout.puts "#{level} [#{self.class.name}] -- #{msg}"
51
- end
52
- end
53
- end # module Debuggable
@@ -1,20 +0,0 @@
1
-
2
- module Fbtxt
3
- class Lexer
4
-
5
-
6
- def log( msg )
7
- ## append msg to ./logs.txt
8
- ## use ./errors.txt - why? why not?
9
- ##
10
- ## change to ./logs_lexer.txt or such - why? why not?
11
- ## auto-add/prepend [Lexer] and timestamp!!! to msg - why? why not?
12
- File.open( './logs.txt', 'a:utf-8' ) do |f|
13
- f.write( "[Lexer] " + msg )
14
- f.write( "\n" )
15
- end
16
- end
17
-
18
-
19
- end # class Lexer
20
- end # module Fbtxt
@@ -1,167 +0,0 @@
1
- module Fbtxt
2
- class Lexer
3
-
4
-
5
-
6
-
7
- GOAL_RE = Regexp.union(
8
- SPACES_RE,
9
- GOAL_MINUTE_RE,
10
- GOAL_MINUTE_NA_RE,
11
- GOAL_COUNT_RE,
12
- PROP_NAME_RE, ## note - (re)use prop name for now for (player) name
13
- GOAL_SEP_ALT_RE, ## note - add dash (-) with (required) spaces
14
- / (?<sym> [;,)]) /x
15
- ## todo/fix - add ANY_RE !!!!
16
- )
17
-
18
-
19
- def _on_goal( m, ctx: )
20
-
21
- if m[:space] || m[:spaces]
22
- nil ## skip space(s)
23
- elsif m[:goal_sep_alt]
24
- # was: [:GOAL_SEP_ALT, "<|GOAL_SEP_ALT|>" ] ## e.g. dash (-) WITH leading & trailing space required
25
- Token.new( :GOAL_SEP_ALT, m[:goal_sep_alt],
26
- lineno: ctx.lineno, offset: m.offset(:goal_sep_alt))
27
- elsif m[:prop_name] ## note - change prop_name to player
28
- Token.new( :PLAYER, m[:name],
29
- lineno: ctx.lineno, offset: m.offset(:name))
30
- elsif m[:goal_minute]
31
- Token.new( :GOAL_MINUTE, m[:goal_minute],
32
- lineno: ctx.lineno, offset: m.offset(:goal_minute),
33
- value: _build_goal_minute( m ))
34
- elsif m[:goal_minute_na]
35
- ## note - (re)use GOAL_MINUTE token; no extra GOAL_MINUTE_NA or such - why? why not?
36
- ## make sure to handle 'm' => nil upstream!!!
37
- ## change to 999 or -1 or such - why? why not?
38
- Token.new( :GOAL_MINUTE, m[:goal_minute_na],
39
- lineno: ctx.lineno, offset: m.offset(:goal_minute_na),
40
- value: _build_goal_minute_na( m ))
41
- elsif m[:goal_count]
42
- Token.new( :GOAL_COUNT, m[:goal_count],
43
- lineno: ctx.lineno, offset: m.offset(:goal_count),
44
- value: _build_goal_count( m ))
45
- elsif m[:sym]
46
- case m[:sym]
47
- when ')' ## leave goal mode!!
48
- _trace( "LEAVE GOAL_RE MODE" )
49
- @re = RE
50
- ## note - use/return GOAL_END token - change to GOAL_END_PAREN(THESIS)
51
- ## or GOAL_PAREN_CLOSE/END ???
52
- ## fix - use ) too - why? why not?
53
- ## was: [:GOALS_END, '<|GOALS_END|>']
54
- Token.virtual( :GOALS_END, lineno: ctx.lineno )
55
- else
56
- Token.literal( m[:sym], lineno: ctx.lineno, offset: m.offset(:sym))
57
- end
58
- else
59
- ctx.warn_on_else( m, mode: 'GOAL' )
60
- nil
61
- end
62
- end
63
-
64
-
65
-
66
-
67
- GOAL_ALT_RE = Regexp.union(
68
- SPACES_RE,
69
- SCORE_RE, ## e.g. 1-0, 0-1, etc.
70
- GOAL_MINUTE_RE,
71
- GOAL_TYPE_RE,
72
- PROP_NAME_RE, ## note - (re)use prop name for now for (player) name
73
- / (?<sym> [,)]) /x ## note - no semicolon (;)
74
- ## todo/fix - add ANY_RE !!!!
75
- )
76
-
77
- def _on_goal_alt( m, ctx: )
78
-
79
- if m[:space] || m[:spaces]
80
- nil ## skip space(s)
81
- elsif m[:prop_name] ## note - change prop_name to player
82
- Token.new(:PLAYER, m[:name],
83
- lineno: ctx.lineno, offset: m.offset(:name))
84
- elsif m[:goal_minute]
85
- Token.new( :GOAL_MINUTE, m[:goal_minute],
86
- lineno: ctx.lineno, offset: m.offset(:goal_minute),
87
- value: _build_goal_minute( m ))
88
- elsif m[:goal_type]
89
- Token.new( :GOAL_TYPE,m[:goal_type],
90
- lineno: ctx.lineno, offset: m.offset(:goal_type),
91
- value: _build_goal_type( m ))
92
- elsif m[:score]
93
- Token.new( :SCORE, m[:score],
94
- lineno: ctx.lineno, offset: m.offset(:score),
95
- value: _build_score( m ))
96
- elsif m[:sym]
97
- case m[:sym]
98
- when ')' ## leave goal mode!!
99
- _trace( "LEAVE GOAL_ALT_RE MODE" )
100
- @re = RE
101
- ## note - use/return GOAL_END token - change to GOAL_END_PAREN(THESIS)
102
- ## or GOAL_PAREN_CLOSE/END ???
103
- ## [:GOALS_END, '<|GOALS_END|>']
104
- Token.virtual( :GOALS_END, lineno: ctx.lineno )
105
- else
106
- Token.literal( m[:sym], lineno: ctx.lineno, offset: m.offset(:sym))
107
- end
108
- else
109
- ctx.warn_on_else( m, mode: 'GOAL_ALT' )
110
- nil
111
- end
112
- end
113
-
114
-
115
-
116
- GOAL_COMPAT_RE = Regexp.union(
117
- SPACES_RE,
118
- SCORE_RE, ## e.g. 1-0, 0-1, etc.
119
- MINUTE_RE, ## note - matches minute e.g. 92, 7, 7' 7+3, etc.
120
- GOAL_TYPE_RE,
121
- PROP_NAME_RE, ## note - (re)use prop name for now for (player) name
122
- / (?<sym> [,)]) /x ## note - no semicolon (;)
123
- ## todo/fix - add ANY_RE !!!!
124
- )
125
-
126
-
127
- def _on_goal_compat( m, ctx: ) ## note - m is MatchData object
128
-
129
- if m[:space] || m[:spaces]
130
- nil ## skip space(s)
131
- elsif m[:prop_name] ## note - change prop_name to player
132
- Token.new(:PLAYER, m[:name],
133
- lineno: ctx.lineno, offset: m.offset(:name))
134
- elsif m[:minute]
135
- Token.new(:MINUTE, m[:minute],
136
- lineno: ctx.lineno, offset: m.offset(:minute),
137
- value: _build_minute( m ))
138
- elsif m[:goal_type]
139
- Token.new( :GOAL_TYPE,m[:goal_type],
140
- lineno: ctx.lineno, offset: m.offset(:goal_type),
141
- value: _build_goal_type( m ))
142
-
143
- elsif m[:score]
144
- Token.new( :SCORE, m[:score],
145
- lineno: ctx.lineno, offset: m.offset(:score),
146
- value: _build_score( m ))
147
- elsif m[:sym]
148
- case m[:sym]
149
- when ')' ## leave goal mode!!
150
- _trace( "LEAVE GOAL_COMPAT_RE MODE" )
151
- @re = RE
152
- ## note - use/return GOAL_END token - change to GOAL_END_PAREN(THESIS)
153
- ## or GOAL_PAREN_CLOSE/END ???
154
- ## [:GOALS_END, '<|GOALS_END|>']
155
- Token.virtual( :GOALS_END, lineno: ctx.lineno )
156
- else
157
- Token.literal( m[:sym], lineno: ctx.lineno, offset: m.offset(:sym))
158
- end
159
- else
160
- ctx.warn_on_else( m, mode: 'GOAL_COMPAT' )
161
- nil
162
- end
163
- end
164
-
165
-
166
- end ## class Lexer
167
- end ## module Fbtxt
@@ -1,31 +0,0 @@
1
- module Fbtxt
2
- class Lexer
3
-
4
-
5
-
6
- ### note - add comma (,) as optional separator
7
- GROUP_DEF_RE = Regexp.union( SPACES_RE,
8
- TEXT_RE,
9
- / (?<sym> [:|,] ) /x,
10
- ANY_RE,
11
- )
12
-
13
-
14
- def _on_group_def( m, ctx: ) ## note - m is MatchData object
15
-
16
- if m[:spaces] || m[:space]
17
- nil ## skip spaces
18
- elsif m[:text]
19
- Token.new(:TEAM, m[:text],
20
- lineno: ctx.lineno, offset: m.offset(:text))
21
- elsif m[:sym]
22
- Token.literal( m[:sym], lineno: ctx.lineno, offset: m.offset(:sym))
23
- else
24
- ctx.warn_on_else( m, mode: 'GROUP_DEF' )
25
- nil
26
- end
27
- end
28
-
29
-
30
- end ## class Lexer
31
- end ## module Fbtxt
@@ -1,79 +0,0 @@
1
- module Fbtxt
2
- class Lexer
3
-
4
-
5
-
6
- PROP_LINEUP_RE = Regexp.union(
7
- SPACES_RE,
8
- MINUTE_RE, ## e.g. 44 or 44' or 45+1 or 45+1' etc.
9
-
10
- INLINE_CAPTAIN, ## e.g. [c]
11
- INLINE_YELLOW, ## e.g. [Y] or [Y 44] or [Y 44'] or [Y 45+1']
12
- INLINE_YELLOW_RED, ## e.g. [Y/R] or [Y/R 78]
13
- INLINE_RED, ## e.g. [R] or [R 42] or [R 42']
14
-
15
- PROP_KEY_INLINE_RE,
16
- PROP_NAME_RE,
17
- / (?<sym> [;,()\[\]-]) /x
18
- ## todo/fix - add ANY_RE here too!!!
19
- )
20
-
21
-
22
- def _on_prop_lineup( m, ctx: ) ## note - m is MatchData object
23
-
24
- if m[:space] || m[:spaces]
25
- nil ## skip space(s)
26
- elsif m[:prop_key] ## check for inline prop keys
27
- key = m[:key]
28
- ## supported for now coach/trainer (add manager?)
29
- if ['coach',
30
- 'trainer'].include?( key.downcase )
31
- ## use PROP_COACH or COACH_KEY or such - why? why not?
32
- Token.new(:COACH, m[:key],
33
- lineno: ctx.lineno, offset: m.offset(:key))
34
- else
35
- ## report error - for unknown (inline) prop key in lineup
36
- nil
37
- end
38
- elsif m[:inline_captain]
39
- Token.new(:INLINE_CAPTAIN, m[:inline_captain],
40
- lineno: ctx.lineno, offset: m.offset(:inline_captain))
41
- elsif m[:inline_yellow]
42
- card = {}
43
- card[:m] = m[:minute].to_i(10) if m[:minute]
44
- card[:offset] = m[:offset].to_i(10) if m[:offset]
45
- Token.new(:INLINE_YELLOW, m[:inline_yellow],
46
- lineno: ctx.lineno, offset: m.offset(:inline_yellow),
47
- value: card)
48
- elsif m[:inline_red]
49
- card = {}
50
- card[:m] = m[:minute].to_i(10) if m[:minute]
51
- card[:offset] = m[:offset].to_i(10) if m[:offset]
52
- Token.new(:INLINE_RED, m[:inline_red],
53
- lineno: ctx.lineno, offset: m.offset(:inline_red),
54
- value: card)
55
- elsif m[:inline_yellow_red]
56
- card = {}
57
- card[:m] = m[:minute].to_i(10) if m[:minute]
58
- card[:offset] = m[:offset].to_i(10) if m[:offset]
59
- Token.new(:INLINE_YELLOW_RED, m[:inline_yellow_red],
60
- lineno: ctx.lineno, offset: m.offset(:inline_yellow_red),
61
- value: card)
62
- elsif m[:prop_name]
63
- Token.new(:PROP_NAME, m[:name],
64
- lineno: ctx.lineno, offset: m.offset(:prop_name))
65
- elsif m[:minute]
66
- Token.new(:MINUTE, m[:minute],
67
- lineno: ctx.lineno, offset: m.offset(:minute),
68
- value: _build_minute( m ))
69
- elsif m[:sym]
70
- Token.literal( m[:sym], lineno: ctx.lineno, offset: m.offset(:sym))
71
- else
72
- ctx.warn_on_else( m, mode: 'PROP_LINEUP' )
73
- nil
74
- end
75
- end
76
-
77
-
78
- end ## class Lexer
79
- end ## module Fbtxt