Sha256: 1e40f6a96f152580ce02b1c747172cf38f751f3e8bac4d80e48f8bc94d9e2ed5

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Rley # This module is used as a namespace
  module Syntax # This module is used as a namespace
    # Abstract class for grammar symbols.
    # A grammar symbol is an element that appears in grammar rules.
    class GrmSymbol
      # @return [String] The name of the grammar symbol
      attr_reader(:name)

      # Constructor.
      # aName [String] The name of the grammar symbol.
      def initialize(aName)
        raise 'Internal error: nil name encountered' if aName.nil?

        @name = aName.dup
        @name.freeze
      end

      # The String representation of the grammar symbol
      # @return [String]
      def to_s
        name.to_s
      end

      # @return [Boolean] true iff the symbol is a terminal
      def terminal?
        # Default implementation to override if necessary
        false
      end

      # @return [Boolean] true iff the symbol is generative.
      def generative?
        @generative
      end
    end # class
  end # module
end # module

# End of file

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rley-0.8.11 lib/rley/syntax/grm_symbol.rb
rley-0.8.10 lib/rley/syntax/grm_symbol.rb
rley-0.8.09 lib/rley/syntax/grm_symbol.rb