Class: Rley::Syntax::NonTerminal

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

Overview

A non-terminal symbol (sometimes called a syntactic variable) represents a composition of terminal or non-terminal symbols

Instance Attribute Summary collapse

Attributes inherited from GrmSymbol

#name

Instance Method Summary collapse

Methods inherited from GrmSymbol

#terminal?, #to_s

Constructor Details

#initialize(aName) ⇒ NonTerminal

Constructor.

Parameters:

  • aName (String)

    The name of the grammar symbol.



12
13
14
# File 'lib/rley/syntax/non_terminal.rb', line 12

def initialize(aName)
  super(aName)
end

Instance Attribute Details

#nullable=(value) ⇒ Object (writeonly)

Sets the attribute nullable

Parameters:

  • value

    the value to set the attribute nullable to.



8
9
10
# File 'lib/rley/syntax/non_terminal.rb', line 8

def nullable=(value)
  @nullable = value
end

Instance Method Details

#nullable?false/true

the empty string. As non-terminal symbol is nullable when it can can match to zero input token. The "nullability" of a non-terminal can practically be determined once all the production rules of the grammar are specified.

Returns:

  • (false/true)

    Return true if the symbol derives



21
22
23
# File 'lib/rley/syntax/non_terminal.rb', line 21

def nullable?()
  return @nullable
end