Sha256: fd869cc77e5c31b62b633da79d8d97d342ef8444a56888b23377e71102b9caa7

Contents?: true

Size: 970 Bytes

Versions: 4

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

require_relative 'ast_node'

module Rley
  module Notation
    # A syntax node for a grammar symbol occurring in rhs of a rule
    class SymbolNode < ASTNode
      # @return [String] name of grammar symbol
      attr_reader :name

      # @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
      # @param aName [String] name of grammar symbol
      # @param theRepetition [Symbol] indicates how many times the symbol can be repeated
      def initialize(aPosition, aName, theRepetition = nil)
        super(aPosition)
        @name = aName
        self.repetition = theRepetition if theRepetition
      end

      # Abstract method (must be overriden in subclasses).
      # Part of the 'visitee' role in Visitor design pattern.
      # @param _visitor [LoxxyTreeVisitor] the visitor
      def accept(visitor)
        visitor.visit_symbol_node(self)
      end
    end # class
  end # module
end # module

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rley-0.8.06 lib/rley/notation/symbol_node.rb
rley-0.8.05 lib/rley/notation/symbol_node.rb
rley-0.8.03 lib/rley/notation/symbol_node.rb
rley-0.8.02 lib/rley/notation/symbol_node.rb