Class: Dhaka::Precedence

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dhaka/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.



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

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/dhaka/grammar/precedence.rb', line 4

def associativity
  @associativity
end

#precedence_levelObject (readonly)

Returns the value of attribute precedence_level.



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

def precedence_level
  @precedence_level
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#to_sObject



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

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