Class: Dendroid::Syntax::Terminal
- 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
Instance Method Summary collapse
-
#initialize(symbolName) ⇒ Terminal
constructor
Constructor.
-
#nullable? ⇒ FalseClass
Predicate method to check whether the symbol derives (matches) the empty string.
-
#productive? ⇒ TrueClass
Predicate method to check whether the symbol always matches a non-empty sequence of terminal symbols.
-
#terminal? ⇒ TrueClass
Predicate method to check whether the symbol is a terminal symbol.
Methods inherited from GrmSymbol
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.
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.
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.
19 20 21 |
# File 'lib/dendroid/syntax/terminal.rb', line 19 def terminal? true end |