Class: TRuby::ParserCombinator::Label
- Defined in:
- lib/t_ruby/parser_combinator.rb
Overview
Label for error messages
Instance Method Summary collapse
-
#initialize(parser, name) ⇒ Label
constructor
A new instance of Label.
- #parse(input, position = 0) ⇒ Object
Methods inherited from Parser
#<<, #>>, #between, #flat_map, #label, #lookahead, #many, #many1, #map, #not_followed_by, #optional, #sep_by, #sep_by1, #|
Constructor Details
#initialize(parser, name) ⇒ Label
Returns a new instance of Label.
433 434 435 436 |
# File 'lib/t_ruby/parser_combinator.rb', line 433 def initialize(parser, name) @parser = parser @name = name end |
Instance Method Details
#parse(input, position = 0) ⇒ Object
438 439 440 441 442 443 444 445 |
# File 'lib/t_ruby/parser_combinator.rb', line 438 def parse(input, position = 0) result = @parser.parse(input, position) if result.failure? ParseResult.failure("Expected #{@name}", input, position) else result end end |