Class: Peggy::Production
- 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
-
#child ⇒ Object
The production definition.
Attributes inherited from Reference
Instance Method Summary collapse
-
#initialize(name = nil, child = nil) ⇒ Production
constructor
Init the name and child.
-
#match(parser, index) ⇒ Object
Match the production one time.
Methods inherited from Reference
Methods inherited from Element
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
#child ⇒ Object
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 |