Sha256: 10c4b2168edc1c7040a5f0702b33bbc5286e5113afd88ca2aa7f75cccef07c48

Contents?: true

Size: 942 Bytes

Versions: 12

Compression:

Stored size: 942 Bytes

Contents

# frozen_string_literal: true

require_relative 'sppf_node'

module Rley # This module is used as a namespace
  module SPPF # This module is used as a namespace
    # Abstract class. The generalization for nodes that have
    # children node(s).
    class CompositeNode < SPPFNode
      # @return [Array<SPFFNode>] Sub-nodes (children).
      attr_reader(:subnodes)

      alias children subnodes

      # Constructor
      # @param aRange [Lexical::TokenRange]
      def initialize(aRange)
        super(aRange)
        @subnodes = []
      end

      # Add a sub-node (child) to this one.
      # @param aSubnode [SPPFNode]
      def add_subnode(aSubnode)
        subnodes.unshift(aSubnode)
      end

      # @return [String] a text representation of the node.
      def inspect
        key
      end

      # @return [String]
      def key
        @key ||= to_string(0)
      end
    end # class
  end # module
end # module
# End of file

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rley-0.8.13 lib/rley/sppf/composite_node.rb
rley-0.8.11 lib/rley/sppf/composite_node.rb
rley-0.8.10 lib/rley/sppf/composite_node.rb
rley-0.8.09 lib/rley/sppf/composite_node.rb
rley-0.8.08 lib/rley/sppf/composite_node.rb
rley-0.8.06 lib/rley/sppf/composite_node.rb
rley-0.8.05 lib/rley/sppf/composite_node.rb
rley-0.8.03 lib/rley/sppf/composite_node.rb
rley-0.8.02 lib/rley/sppf/composite_node.rb
rley-0.8.01 lib/rley/sppf/composite_node.rb
rley-0.8.00 lib/rley/sppf/composite_node.rb
rley-0.7.08 lib/rley/sppf/composite_node.rb