Class: Rley::SPPF::EpsilonNode

Inherits:
LeafNode show all
Defined in:
lib/rley/sppf/epsilon_node.rb

Overview

A leaf node in a parse forest that matches an empty string from the input

Instance Attribute Summary

Attributes inherited from SPPFNode

#range

Instance Method Summary collapse

Methods inherited from LeafNode

#inspect, #key

Methods inherited from SPPFNode

#origin

Constructor Details

#initialize(aPosition) ⇒ EpsilonNode

aPosition [Integer] is the position of the token in the input stream.



11
12
13
14
# File 'lib/rley/sppf/epsilon_node.rb', line 11

def initialize(aPosition)
  range = { low: aPosition, high: aPosition }
  super(range)
end

Instance Method Details

#accept(aVisitor) ⇒ Object

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

Parameters:



25
26
27
# File 'lib/rley/sppf/epsilon_node.rb', line 25

def accept(aVisitor)
  aVisitor.visit_epsilon(self)
end

#to_string(indentation) ⇒ String

Emit a (formatted) string representation of the node. Mainly used for diagnosis/debugging purposes.

Returns:

  • (String)


19
20
21
# File 'lib/rley/sppf/epsilon_node.rb', line 19

def to_string(indentation)
  return "_#{range.to_string(indentation)}"
end