Class: Dendroid::Syntax::GrmSymbol

Inherits:
Object
  • Object
show all
Defined in:
lib/dendroid/syntax/grm_symbol.rb

Overview

Abstract class for grammar symbols. A grammar symbol is an element that appears in grammar rules.

Direct Known Subclasses

NonTerminal, Terminal

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbolName) ⇒ GrmSymbol

Constructor. aSymbolName [String] The name of the grammar symbol.



13
14
15
# File 'lib/dendroid/syntax/grm_symbol.rb', line 13

def initialize(symbolName)
  @name = valid_name(symbolName)
end

Instance Attribute Details

#nameString (readonly)



9
10
11
# File 'lib/dendroid/syntax/grm_symbol.rb', line 9

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean

Equality testing (based on symbol name)



25
26
27
# File 'lib/dendroid/syntax/grm_symbol.rb', line 25

def ==(other)
  name == other.name
end

#to_sString

The String representation of the grammar symbol



19
20
21
# File 'lib/dendroid/syntax/grm_symbol.rb', line 19

def to_s
  name.to_s
end