Class: Peggy::Reference
Overview
Match another production in the grammar.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the production to lookup and match.
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Reference
constructor
Init the name.
-
#match(parser, index) ⇒ Object
Match the entire production from the parser grammar.
-
#to_s ⇒ Object
Convert element to String.
Methods inherited from Element
Constructor Details
#initialize(name = nil) ⇒ Reference
Init the name
232 233 234 |
# File 'lib/parse/builder.rb', line 232 def initialize name=nil self.name = name end |
Instance Attribute Details
#name ⇒ Object
The name of the production to lookup and match.
229 230 231 |
# File 'lib/parse/builder.rb', line 229 def name @name end |
Instance Method Details
#match(parser, index) ⇒ Object
Match the entire production from the parser grammar. If it matches the end index is returned. If not, NO_MATCH is returned.
243 244 245 246 |
# File 'lib/parse/builder.rb', line 243 def match parser, index raise "reference name not set" unless name parser.match? name, index end |
#to_s ⇒ Object
Convert element to String.
249 250 251 |
# File 'lib/parse/builder.rb', line 249 def to_s @name end |