Sha256: 14078b0608dbcefcb042e19e29dd70cba8658335912d38dc9d9ebb195c733432

Contents?: true

Size: 898 Bytes

Versions: 8

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

require_relative 'grm_symbol' # Load superclass

module Rley # This module is used as a namespace
  module Syntax # This module is used as a namespace
    # A terminal symbol represents a class of words in the language
    # defined the grammar.
    class Terminal < GrmSymbol
      # Constructor.
      # @param aName [String] The name of the grammar symbol.
      def initialize(aName)
        super(aName)
        self.generative = true
      end

      # Return true iff the symbol is a terminal
      def terminal?
        return true
      end

      # @return [false] Return true if the symbol derives
      # the empty string. As terminal symbol corresponds to a input token
      # it is by definition non-nullable.
      def nullable?
        false
      end

      def to_s
        name
      end
    end # class
  end # module
end # module

# End of file

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rley-0.8.08 lib/rley/syntax/terminal.rb
rley-0.8.06 lib/rley/syntax/terminal.rb
rley-0.8.05 lib/rley/syntax/terminal.rb
rley-0.8.03 lib/rley/syntax/terminal.rb
rley-0.8.02 lib/rley/syntax/terminal.rb
rley-0.8.01 lib/rley/syntax/terminal.rb
rley-0.8.00 lib/rley/syntax/terminal.rb
rley-0.7.08 lib/rley/syntax/terminal.rb