Class: Dhaka::Precedence

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/grammar/precedence.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(precedence_level, associativity) ⇒ Precedence

Returns a new instance of Precedence.



5
6
7
8
# File 'lib/grammar/precedence.rb', line 5

def initialize(precedence_level, associativity)
  @precedence_level = precedence_level
  @associativity = associativity
end

Instance Attribute Details

#associativityObject (readonly)

Returns the value of attribute associativity.



4
5
6
# File 'lib/grammar/precedence.rb', line 4

def associativity
  @associativity
end

#precedence_levelObject (readonly)

Returns the value of attribute precedence_level.



4
5
6
# File 'lib/grammar/precedence.rb', line 4

def precedence_level
  @precedence_level
end

Instance Method Details

#<=>(other) ⇒ Object



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

def <=> other
  self.precedence_level <=> other.precedence_level
end

#to_sObject



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

def to_s
  "Precedence: #{precedence_level} Associativity: #{associativity}"
end