Sha256: cf1f669d9f6f6a14c1c980a2d13e2b61f8dad7eff5c436ee4a624dabc723f38e

Contents?: true

Size: 1.09 KB

Versions: 17

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require_relative 'grm_symbol'

module Dendroid
  module Syntax
    # A terminal symbol is an elementary symbol of the language defined by the grammar.
    # More specifically, it represents a class of 'words'(or a token) of the language.
    class Terminal < GrmSymbol
      # Constructor.
      # aSymbolName [String] The name of the grammar symbol.
      def initialize(symbolName)
        super(symbolName)
        freeze
      end

      # Predicate method to check whether the symbol is a terminal symbol.
      # @return [TrueClass]
      def terminal?
        true
      end

      # Predicate method to check whether the symbol derives (matches)
      # the empty string. As a terminal symbol corresponds to an input token,
      # it is by definition non-nullable.
      # @return [FalseClass]
      def nullable?
        false
      end

      # Predicate method to check whether the symbol always matches
      # a non-empty sequence of terminal symbols.
      # @return [TrueClass]
      def productive?
        true
      end
    end # class
  end # module
end # module

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dendroid-0.2.04 lib/dendroid/syntax/terminal.rb
dendroid-0.2.03 lib/dendroid/syntax/terminal.rb
dendroid-0.2.02 lib/dendroid/syntax/terminal.rb
dendroid-0.2.01 lib/dendroid/syntax/terminal.rb
dendroid-0.2.00 lib/dendroid/syntax/terminal.rb
dendroid-0.1.00 lib/dendroid/syntax/terminal.rb
dendroid-0.0.12 lib/dendroid/syntax/terminal.rb
dendroid-0.0.11 lib/dendroid/syntax/terminal.rb
dendroid-0.0.10 lib/dendroid/syntax/terminal.rb
dendroid-0.0.9 lib/dendroid/syntax/terminal.rb
dendroid-0.0.8 lib/dendroid/syntax/terminal.rb
dendroid-0.0.7 lib/dendroid/syntax/terminal.rb
dendroid-0.0.6 lib/dendroid/syntax/terminal.rb
dendroid-0.0.5 lib/dendroid/syntax/terminal.rb
dendroid-0.0.4 lib/dendroid/syntax/terminal.rb
dendroid-0.0.3 lib/dendroid/syntax/terminal.rb
dendroid-0.0.2 lib/dendroid/syntax/terminal.rb