Class: Rley::Syntax::NonTerminal
- 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
-
#nullable ⇒ Object
writeonly
A non-terminal symbol is nullable if it can match an empty string.
-
#undefined ⇒ Object
writeonly
A non-terminal symbol is undefined if no production rule in the grammar has that non-terminal symbol in its left-hand side.
-
#unreachable ⇒ Object
writeonly
A non-terminal symbol is unreachable if it cannot be reached (derived) from the start symbol.
Attributes inherited from GrmSymbol
Instance Method Summary collapse
-
#initialize(aName) ⇒ NonTerminal
constructor
Constructor.
-
#nullable? ⇒ false/true
the empty string.
-
#undefined? ⇒ false/true
on the left-hand side of any production rule.
-
#unreachable? ⇒ false/true
from the start symbol.
Methods inherited from GrmSymbol
#generative?, #terminal?, #to_s
Constructor Details
#initialize(aName) ⇒ NonTerminal
Constructor.
23 24 25 |
# File 'lib/rley/syntax/non_terminal.rb', line 23 def initialize(aName) super(aName) end |
Instance Attribute Details
#nullable=(value) ⇒ Object (writeonly)
A non-terminal symbol is nullable if it can match an empty string.
11 12 13 |
# File 'lib/rley/syntax/non_terminal.rb', line 11 def nullable=(value) @nullable = value end |
#undefined=(value) ⇒ Object (writeonly)
A non-terminal symbol is undefined if no production rule in the grammar has that non-terminal symbol in its left-hand side.
15 16 17 |
# File 'lib/rley/syntax/non_terminal.rb', line 15 def undefined=(value) @undefined = value end |
#unreachable=(value) ⇒ Object (writeonly)
A non-terminal symbol is unreachable if it cannot be reached (derived) from the start symbol.
19 20 21 |
# File 'lib/rley/syntax/non_terminal.rb', line 19 def unreachable=(value) @unreachable = 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.
32 33 34 |
# File 'lib/rley/syntax/non_terminal.rb', line 32 def nullable?() return @nullable end |
#undefined? ⇒ false/true
on the left-hand side of any production rule.
38 39 40 |
# File 'lib/rley/syntax/non_terminal.rb', line 38 def undefined?() return @undefined end |
#unreachable? ⇒ false/true
from the start symbol.
44 45 46 |
# File 'lib/rley/syntax/non_terminal.rb', line 44 def unreachable?() return @unreachable end |