Class: Aurum::Grammar::SyntaxRules::Precedence

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/aurum/grammar/syntax_rules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#associativityObject

Returns the value of attribute associativity

Returns:

  • (Object)

    the current value of associativity



46
47
48
# File 'lib/aurum/grammar/syntax_rules.rb', line 46

def associativity
  @associativity
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



46
47
48
# File 'lib/aurum/grammar/syntax_rules.rb', line 46

def level
  @level
end

Instance Method Details

#<=>(other) ⇒ Object



49
50
51
52
53
54
# File 'lib/aurum/grammar/syntax_rules.rb', line 49

def <=> other
  return level <=> other.level unless level == other.level
  return 1 if associativity == :left_associative
  return -1 if associativity == :right_associative
  #TODO non_associative
end