Class: Rley::Syntax::Terminal

Inherits:
GrmSymbol show all
Defined in:
lib/rley/syntax/terminal.rb

Overview

A terminal symbol represents a class of words in the language defined the grammar.

Instance Attribute Summary

Attributes inherited from GrmSymbol

#name

Instance Method Summary collapse

Methods inherited from GrmSymbol

#initialize

Constructor Details

This class inherits a constructor from Rley::Syntax::GrmSymbol

Instance Method Details

#generative?TrueClass

An indicator that tells whether the grammar symbol can generate a non-empty string of terminals.

Returns:

  • (TrueClass)


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

def generative?
  true
end

#nullable?false, FalseClass

the empty string. As terminal symbol corresponds to a input token it is by definition non-nullable.

Returns:

  • (false)

    Return true if the symbol derives

  • (FalseClass)


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

def nullable?
  false
end

#terminal?TrueClass

Return true iff the symbol is a terminal

Returns:

  • (TrueClass)


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

def terminal?
  true
end

#to_sString

Return a readable text representation of the instance

Returns:

  • (String)

    The symbol name



33
34
35
# File 'lib/rley/syntax/terminal.rb', line 33

def to_s
  name
end