Class: Peggy::Reference

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

Overview

Match another production in the grammar.

Direct Known Subclasses

Production

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

build, #report

Constructor Details

#initialize(name = nil) ⇒ Reference

Init the name



164
165
166
# File 'lib/builder.rb', line 164

def initialize name=nil
  self.name = name
end

Instance Attribute Details

#nameObject

The name of the production to lookup and match.



161
162
163
# File 'lib/builder.rb', line 161

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.



175
176
177
178
# File 'lib/builder.rb', line 175

def match parser, index
  raise "reference name not set" unless name
  parser.match? name, index
end

#to_sObject



180
181
182
# File 'lib/builder.rb', line 180

def to_s
  name
end