class Peggy::Alternatives
An element which matches any one of its children. The children are tested in order. The first to match wins.
Public Instance Methods
match(parser, index)
click to toggle source
Match any one of the children. The children are tried in order. The first to match wins. The result is the end index of the first matching child. If none match this returns NO_MATCH.
# File lib/parse/builder.rb, line 96 def match parser, index raise "no children added to alternate" unless @list each do |element| found = element.match parser, index return report(found) if found end report NO_MATCH end
to_s()
click to toggle source
Convert element to String.
# File lib/parse/builder.rb, line 106 def to_s @list.map{|el| el.to_s}.join ' | ' end