Class: TRuby::ParserCombinator::TypeParser
- Inherits:
-
Object
- Object
- TRuby::ParserCombinator::TypeParser
- Includes:
- DSL
- Defined in:
- lib/t_ruby/parser_combinator.rb
Overview
Type Parser - Parse T-Ruby type expressions
Instance Method Summary collapse
-
#initialize ⇒ TypeParser
constructor
A new instance of TypeParser.
- #parse(input) ⇒ Object
Methods included from DSL
#alphanumeric, #chainl, #char, #choice, #digit, #eof, #fail, #float, #identifier, #integer, #lazy, #letter, #lexeme, #literal, #newline, #pure, #quoted_string, #regex, #satisfy, #sequence, #spaces, #spaces1, #string, #whitespace
Constructor Details
#initialize ⇒ TypeParser
Returns a new instance of TypeParser.
653 654 655 |
# File 'lib/t_ruby/parser_combinator.rb', line 653 def initialize build_parsers end |
Instance Method Details
#parse(input) ⇒ Object
657 658 659 660 661 662 663 664 |
# File 'lib/t_ruby/parser_combinator.rb', line 657 def parse(input) result = @type_expr.parse(input.strip) if result.success? { success: true, type: result.value, remaining: input[result.position..] } else { success: false, error: result.error, position: result.position } end end |