Class: Peggy::Positive
- Defined in:
- lib/builder.rb,
lib/Copy of builder.rb
Overview
An element which tries its single child but does not advance the index if found. If not found, however, it returns NO_MATCH. Used for a positive semantic predicate.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#child ⇒ Object
The single child.
Instance Method Summary collapse
-
#match(parser, index) ⇒ Object
Matches the child once.
Methods inherited from Element
Instance Attribute Details
#child ⇒ Object
The single child
134 135 136 |
# File 'lib/builder.rb', line 134 def child @child end |
Instance Method Details
#match(parser, index) ⇒ Object
Matches the child once. If found the original index is returned. If not found NO_MATCH is returned.
141 142 143 144 145 |
# File 'lib/builder.rb', line 141 def match parser, index raise "positive element child not set" unless child found = child.match parser, index found ? index : NO_MATCH end |