Class: L43Rmap::Parsing::RgxParser
- Inherits:
-
Object
- Object
- L43Rmap::Parsing::RgxParser
- Defined in:
- lib/l43_rmap/parsing/rgx_parser.rb
Constant Summary collapse
- BadRgx =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#blk ⇒ Object
readonly
Returns the value of attribute blk.
-
#only_group ⇒ Object
readonly
Returns the value of attribute only_group.
-
#rgx ⇒ Object
readonly
Returns the value of attribute rgx.
Instance Method Summary collapse
Instance Attribute Details
#blk ⇒ Object (readonly)
Returns the value of attribute blk.
14 15 16 |
# File 'lib/l43_rmap/parsing/rgx_parser.rb', line 14 def blk @blk end |
#only_group ⇒ Object (readonly)
Returns the value of attribute only_group.
14 15 16 |
# File 'lib/l43_rmap/parsing/rgx_parser.rb', line 14 def only_group @only_group end |
#rgx ⇒ Object (readonly)
Returns the value of attribute rgx.
14 15 16 |
# File 'lib/l43_rmap/parsing/rgx_parser.rb', line 14 def rgx @rgx end |
Instance Method Details
#parse(input) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/l43_rmap/parsing/rgx_parser.rb', line 16 def parse(input) match = rgx.match(input.current) # p(rgx:, input:, match:) if ENV['DEBUG'] # p(match:) if match case match in nil nil in [m] ParseState.new(ast: postprocess(m), input: advance(input, m, m)) in [m, a] ParseState.new(ast: postprocess(a), input: advance(input, a, m)) in [_, *rest] raise BadRgx, "too many captures; max = 1, had #{rest.count}" end end |