Sha256: 7770fa20b118501aa6ab1f5f14abf910e44cf0658da8e3758eec6e900dd5ad65

Contents?: true

Size: 845 Bytes

Versions: 6

Compression:

Stored size: 845 Bytes

Contents

require_relative 'parse_tree_node'  # Load superclass

module Rley # This module is used as a namespace
  module PTree # This module is used as a namespace
    class NonTerminalNode < ParseTreeNode
      # Link to the input token
      attr_reader(:children)

      def initialize(aSymbol, aRange)
        super(aSymbol, aRange)
        @children = []
      end

      # @param aChildNode [ParseTreeNode-like] a child node.
      def add_child(aChildNode)
        children << aChildNode
      end
      
      # Part of the 'visitee' role in Visitor design pattern.
      # @param aVisitor[ParseTreeVisitor] the visitor
      def accept(aVisitor)
        aVisitor.start_visit_nonterminal(self)
        aVisitor.visit_children(self)
        aVisitor.end_visit_nonterminal(self)
      end
    end # class
  end # module
end # module
# End of file

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rley-0.2.01 lib/rley/ptree/non_terminal_node.rb
rley-0.2.00 lib/rley/ptree/non_terminal_node.rb
rley-0.1.12 lib/rley/ptree/non_terminal_node.rb
rley-0.1.11 lib/rley/ptree/non_terminal_node.rb
rley-0.1.10 lib/rley/ptree/non_terminal_node.rb
rley-0.1.09 lib/rley/ptree/non_terminal_node.rb