Class: Rley::Notation::ASTNode

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

Overview

Abstract class. Instances of its subclasses represent nodes of an abstract syntax tree that is the product of the parse of an input text.

Direct Known Subclasses

SequenceNode, SymbolNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aPosition) ⇒ ASTNode

Returns a new instance of ASTNode.

Parameters:



19
20
21
22
23
# File 'lib/rley/notation/ast_node.rb', line 19

def initialize(aPosition)
  @position = aPosition
  @repetition = :exactly_one
  @annotation = {}
end

Instance Attribute Details

#annotationHash

Returns:

  • (Hash)


16
17
18
# File 'lib/rley/notation/ast_node.rb', line 16

def annotation
  @annotation
end

#positionRley::Lexical::Position (readonly)

Returns Position of the entry in the input stream.

Returns:



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

def position
  @position
end

#repetitionSymbol

Returns:

  • (Symbol)


13
14
15
# File 'lib/rley/notation/ast_node.rb', line 13

def repetition
  @repetition
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

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/rley/notation/ast_node.rb', line 39

def accept(_visitor)
  raise NotImplementedError
end

#done!Object

Notification that the parsing has successfully completed



32
33
34
# File 'lib/rley/notation/ast_node.rb', line 32

def done!
  # Default: do nothing ...
end