Class: Rley::Notation::SequenceNode

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

Overview

A syntax node for a sequence of AST nodes

Direct Known Subclasses

GroupingNode

Instance Attribute Summary collapse

Attributes inherited from ASTNode

#annotation, #position, #repetition

Instance Method Summary collapse

Methods inherited from ASTNode

#done!

Constructor Details

#initialize(aPosition, sequence, theRepetition = nil) ⇒ SequenceNode

Returns a new instance of SequenceNode.

Parameters:

  • aPosition (Rley::Lexical::Position)

    Start position.

  • sequence (Array<ASTNode>)

    sequence of AST nodes

  • theRepetition (Symbol) (defaults to: nil)

    indicates how many times the symbol can be repeated



17
18
19
20
21
22
# File 'lib/rley/notation/sequence_node.rb', line 17

def initialize(aPosition, sequence, theRepetition = nil)
  super(aPosition)
  @subnodes = sequence
  self.repetition = theRepetition if theRepetition
  @constraints = []
end

Instance Attribute Details

#constraintsObject

Returns the value of attribute constraints.



12
13
14
# File 'lib/rley/notation/sequence_node.rb', line 12

def constraints
  @constraints
end

#subnodesArray<ASTNode> (readonly)

Returns:



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

def subnodes
  @subnodes
end

Instance Method Details

#accept(visitor) ⇒ Object

Part of the 'visitee' role in Visitor design pattern.

Parameters:



30
31
32
# File 'lib/rley/notation/sequence_node.rb', line 30

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

#sizeObject



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

def size
  subnodes.size
end