Class: Peggy::Production

Inherits:
Reference show all
Defined in:
lib/builder.rb,
lib/Copy of builder.rb

Overview

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

Instance Attribute Summary collapse

Attributes inherited from Reference

#name

Instance Method Summary collapse

Methods inherited from Reference

#to_s

Methods inherited from Element

build, #report

Constructor Details

#initialize(name = nil, child = nil) ⇒ Production

Init the name and child.



191
192
193
194
# File 'lib/builder.rb', line 191

def initialize name=nil, child=nil
  super name
  @child = child
end

Instance Attribute Details

#childObject

The production definition.



188
189
190
# File 'lib/builder.rb', line 188

def child
  @child
end

Instance Method Details

#match(parser, index) ⇒ Object

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



201
202
203
204
205
# File 'lib/builder.rb', line 201

def match parser, index
  raise "production name not set" unless name
  raise "production child not set" unless child
  report @child.match(parser, index)
end