Class: PackratParser::Success
- Inherits:
-
Object
- Object
- PackratParser::Success
- Defined in:
- lib/packrat_parser/result.rb
Overview
The result of running a parser at some position in the input.
Success carries the parsed value and pos, the index of the next
unconsumed character. Failure carries the pos where parsing failed and
a human-readable message.
Instance Attribute Summary collapse
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, pos) ⇒ Success
constructor
A new instance of Success.
- #success? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(value, pos) ⇒ Success
Returns a new instance of Success.
10 11 12 13 |
# File 'lib/packrat_parser/result.rb', line 10 def initialize(value, pos) @value = value @pos = pos end |
Instance Attribute Details
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
8 9 10 |
# File 'lib/packrat_parser/result.rb', line 8 def pos @pos end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/packrat_parser/result.rb', line 8 def value @value end |
Instance Method Details
#success? ⇒ Boolean
15 16 17 |
# File 'lib/packrat_parser/result.rb', line 15 def success? true end |
#to_s ⇒ Object Also known as: inspect
19 20 21 |
# File 'lib/packrat_parser/result.rb', line 19 def to_s "Success(#{@value.inspect} @#{@pos})" end |