Class: Dendroid::Syntax::Terminal

Inherits:
GrmSymbol
  • Object
show all
Defined in:
lib/dendroid/syntax/terminal.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from GrmSymbol

#name

Instance Method Summary collapse

Methods inherited from GrmSymbol

#==, #to_s

Constructor Details

#initialize(symbolName) ⇒ Terminal

Constructor. aSymbolName [String] The name of the grammar symbol.



12
13
14
15
# File 'lib/dendroid/syntax/terminal.rb', line 12

def initialize(symbolName)
  super(symbolName)
  freeze
end

Instance Method Details

#nullable?FalseClass

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.

Returns:

  • (FalseClass)


27
28
29
# File 'lib/dendroid/syntax/terminal.rb', line 27

def nullable?
  false
end

#productive?TrueClass

Predicate method to check whether the symbol always matches a non-empty sequence of terminal symbols.

Returns:

  • (TrueClass)


34
35
36
# File 'lib/dendroid/syntax/terminal.rb', line 34

def productive?
  true
end

#terminal?TrueClass

Predicate method to check whether the symbol is a terminal symbol.

Returns:

  • (TrueClass)


19
20
21
# File 'lib/dendroid/syntax/terminal.rb', line 19

def terminal?
  true
end