Class: PEG::OneOrMore
- Inherits:
-
Sequence
- Object
- ValueObject
- Rule
- Sequence
- PEG::OneOrMore
- Defined in:
- lib/peg.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.range ⇒ Object
Returns the value of attribute range.
Attributes inherited from Rule
Instance Method Summary collapse
Methods inherited from Sequence
Methods inherited from Rule
#initialize, #inspect, #name, #parse, #result
Methods inherited from ValueObject
Constructor Details
This class inherits a constructor from PEG::Rule
Class Attribute Details
.range ⇒ Object
Returns the value of attribute range.
126 127 128 |
# File 'lib/peg.rb', line 126 def range @range end |
Instance Method Details
#match(text) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/peg.rb', line 129 def match(text) text_ = String.new(text) len = 0 children = [] loop do node = @children[0].match(text_) break if not node children << node break if node.text == '' text_ = text_.slice node.text.length..text_.length len += node.text.length end in_range = self.class.range.include?(children.length) in_range ? result(text.slice(0...len), children) : nil end |