Sha256: 8050946fd250cc6d3381fde93cd8ebd901c0a5d1a796eafbd37c40f0b2f62585

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

require_relative 'leaf_node'

module Rley # This module is used as a namespace
  module SPPF # This module is used as a namespace
    # A leaf node in a parse forest that matches an empty
    # string from the input
    class EpsilonNode < LeafNode
      # aPosition [Integer] is the position of the token in the input stream.
      def initialize(aPosition)
        range = { low: aPosition, high: aPosition }
        super(range)
      end

      # Emit a (formatted) string representation of the node.
      # Mainly used for diagnosis/debugging purposes.
      # @return [String]
      def to_string(indentation)
        return "_#{range.to_string(indentation)}"
      end
      
      # Part of the 'visitee' role in Visitor design pattern.
      # @param aVisitor[ParseTreeVisitor] the visitor
      def accept(aVisitor)
        aVisitor.visit_epsilon(self)
      end      
    end # class
  end # module
end # module
# End of file

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rley-0.7.07 lib/rley/sppf/epsilon_node.rb
rley-0.7.06 lib/rley/sppf/epsilon_node.rb
rley-0.7.05 lib/rley/sppf/epsilon_node.rb
rley-0.7.04 lib/rley/sppf/epsilon_node.rb