Class: Rley::Notation::SymbolNode

Inherits:
ASTNode
  • Object
show all
Defined in:
lib/rley/notation/symbol_node.rb

Overview

A syntax node for a grammar symbol occurring in rhs of a rule

Instance Attribute Summary collapse

Attributes inherited from ASTNode

#annotation, #position, #repetition

Instance Method Summary collapse

Methods inherited from ASTNode

#done!

Constructor Details

#initialize(aPosition, aName, theRepetition = nil) ⇒ SymbolNode

Returns a new instance of SymbolNode.

Parameters:

  • aPosition (Rley::Lexical::Position)

    Position of the entry in the input stream.

  • aName (String)

    name of grammar symbol

  • theRepetition (Symbol) (defaults to: nil)

    indicates how many times the symbol can be repeated



15
16
17
18
19
# File 'lib/rley/notation/symbol_node.rb', line 15

def initialize(aPosition, aName, theRepetition = nil)
  super(aPosition)
  @name = aName
  self.repetition = theRepetition if theRepetition
end

Instance Attribute Details

#nameString (readonly)

Returns name of grammar symbol.

Returns:

  • (String)

    name of grammar symbol



10
11
12
# File 'lib/rley/notation/symbol_node.rb', line 10

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

Abstract method (must be overriden in subclasses). Part of the 'visitee' role in Visitor design pattern.

Parameters:

  • _visitor (LoxxyTreeVisitor)

    the visitor



24
25
26
# File 'lib/rley/notation/symbol_node.rb', line 24

def accept(visitor)
  visitor.visit_symbol_node(self)
end