Class: PEG::Sequence

Inherits:
Rule show all
Defined in:
lib/peg.rb

Direct Known Subclasses

And, Grammar, Not, OneOrMore, Or

Instance Attribute Summary

Attributes inherited from Rule

#children

Instance Method Summary collapse

Methods inherited from Rule

#initialize, #inspect, #name, #parse, #result

Methods inherited from ValueObject

#==

Constructor Details

This class inherits a constructor from PEG::Rule

Instance Method Details

#_inspectObject



95
96
97
# File 'lib/peg.rb', line 95

def _inspect
  @children.map(&:inspect).join(', ')
end

#match(text) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/peg.rb', line 78

def match(text)
  text_ = String.new(text)
  len = 0
  children = []
  @children.each do |child|
    node = child.match(text_)
    if node == nil
      return nil
    else
      children << node
      text_ = text_.slice node.text.length..text_.length
      len += node.text.length
    end
  end
  result(text.slice(0...len), children)
end