Class: Peggy::Reference

Inherits:
Element show all
Defined in:
lib/parse/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



232
233
234
# File 'lib/parse/builder.rb', line 232

def initialize name=nil
  self.name = name
end

Instance Attribute Details

#nameObject

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_sObject

Convert element to String.



249
250
251
# File 'lib/parse/builder.rb', line 249

def to_s
  @name
end