Class: Dhaka::GrammarSymbol

Inherits:
Object
  • Object
show all
Defined in:
lib/grammar/grammar_symbol.rb

Overview

Each grammar symbol is uniquely identified by a string name. The name of a symbol can be anything and need not correspond to its character representation. For example, an ampersand in the character stream could be tokenized as a symbol with a name ‘whatever’. In general, it’s best to choose symbol names that are descriptive.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ GrammarSymbol

Returns a new instance of GrammarSymbol.



10
11
12
# File 'lib/grammar/grammar_symbol.rb', line 10

def initialize(name)
  @name = name
end

Instance Attribute Details

#associativityObject

Returns the value of attribute associativity.



8
9
10
# File 'lib/grammar/grammar_symbol.rb', line 8

def associativity
  @associativity
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/grammar/grammar_symbol.rb', line 7

def name
  @name
end

#non_terminalObject

Returns the value of attribute non_terminal.



8
9
10
# File 'lib/grammar/grammar_symbol.rb', line 8

def non_terminal
  @non_terminal
end

#nullableObject

Returns the value of attribute nullable.



8
9
10
# File 'lib/grammar/grammar_symbol.rb', line 8

def nullable
  @nullable
end

#precedenceObject

Returns the value of attribute precedence.



8
9
10
# File 'lib/grammar/grammar_symbol.rb', line 8

def precedence
  @precedence
end

Instance Method Details

#<=>(other) ⇒ Object



22
23
24
# File 'lib/grammar/grammar_symbol.rb', line 22

def <=> other
  name <=> other.name
end

#terminalObject



14
15
16
# File 'lib/grammar/grammar_symbol.rb', line 14

def terminal
  !non_terminal
end

#to_sObject

:nodoc:



18
19
20
# File 'lib/grammar/grammar_symbol.rb', line 18

def to_s #:nodoc:
  name.dup
end