class Peggy::Production

Matcher of a grammar production. The one and only child defines the production.

Attributes

<<[RW]

The production definition.

child[RW]

The production definition.

Public Class Methods

new(name=nil, child=nil) click to toggle source

Init the name and child.

Calls superclass method Peggy::Reference::new
# File lib/parse/builder.rb, line 262
def initialize name=nil, child=nil
  super name
  @child = child
end

Public Instance Methods

match(parser, index) click to toggle source

Match the production one time. If it matches the end index is returned. If not, NO_MATCH is returned.

# File lib/parse/builder.rb, line 272
def match parser, index
  raise "production name not set" unless name
  raise "production child not set" unless child
  report @child.match(parser, index)
end
to_s() click to toggle source

Convert element to String.

# File lib/parse/builder.rb, line 279
def to_s
  "#{name}: #{child}"
end