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 SPPFNode

#origin

Constructor Details

#initialize(aPosition) ⇒ EpsilonNode

aPosition is the position of the token in the input stream.



9
10
11
12
# File 'lib/rley/sppf/epsilon_node.rb', line 9

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

Instance Method Details

#keyObject



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

def key()
  @key ||= to_string(0)
end

#to_string(indentation) ⇒ Object

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



16
17
18
# File 'lib/rley/sppf/epsilon_node.rb', line 16

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