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.

Direct Known Subclasses

Literal, VerbatimSymbol

Instance Attribute Summary

Attributes inherited from GrmSymbol

#generative, #name

Instance Method Summary collapse

Methods inherited from GrmSymbol

#generative?

Constructor Details

#initialize(aName) ⇒ Terminal

Constructor.

Parameters:

  • aName (String)

    The name of the grammar symbol.



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

def initialize(aName)
  super(aName)
  self.generative = true
end

Instance Method Details

#nullable?false

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



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

def nullable?
  false
end

#terminal?Boolean

Return true iff the symbol is a terminal

Returns:

  • (Boolean)


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

def terminal?
  return true
end

#to_sObject



30
31
32
# File 'lib/rley/syntax/terminal.rb', line 30

def to_s
  name
end