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.



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

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

Instance Attribute Details

#nameString (readonly)

Returns The name of the grammar symbol.

Returns:

  • (String)

    The name of the grammar symbol



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

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean

Equality testing (based on symbol names)

Returns:

  • (Boolean)


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

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

#to_sString

The String representation of the grammar symbol

Returns:

  • (String)


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

def to_s
  name.to_s
end