Class: Lrama::Grammar::Precedence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#linenoObject

Returns the value of attribute lineno

Returns:

  • (Object)

    the current value of lineno



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

def lineno
  @lineno
end

#precedenceObject

Returns the value of attribute precedence

Returns:

  • (Object)

    the current value of precedence



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

def precedence
  @precedence
end

#s_valueObject

Returns the value of attribute s_value

Returns:

  • (Object)

    the current value of s_value



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

def s_value
  @s_value
end

#symbolObject

Returns the value of attribute symbol

Returns:

  • (Object)

    the current value of symbol



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

def symbol
  @symbol
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



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

def type
  @type
end

#used_by_ielrObject (readonly)

: Array



20
21
22
# File 'lib/lrama/grammar/precedence.rb', line 20

def used_by_ielr
  @used_by_ielr
end

#used_by_lalrObject (readonly)

@rbs! type type_enum = :left | :right | :nonassoc | :precedence

attr_accessor type: type_enum
attr_accessor symbol: Grammar::Symbol
attr_accessor precedence: Integer
attr_accessor s_value: String
attr_accessor lineno: Integer

def initialize: (?type: type_enum, ?symbol: Grammar::Symbol, ?precedence: Integer, ?s_value: ::String, ?lineno: Integer) -> void


19
20
21
# File 'lib/lrama/grammar/precedence.rb', line 19

def used_by_lalr
  @used_by_lalr
end

Instance Method Details

#<=>(other) ⇒ Object



23
24
25
# File 'lib/lrama/grammar/precedence.rb', line 23

def <=>(other)
  self.precedence <=> other.precedence
end

#mark_used_by_ielr(resolved_conflict) ⇒ Object



34
35
36
37
# File 'lib/lrama/grammar/precedence.rb', line 34

def mark_used_by_ielr(resolved_conflict)
  @used_by_ielr ||= [] #: Array[State::ResolvedConflict]
  @used_by_ielr << resolved_conflict
end

#mark_used_by_lalr(resolved_conflict) ⇒ Object



28
29
30
31
# File 'lib/lrama/grammar/precedence.rb', line 28

def mark_used_by_lalr(resolved_conflict)
  @used_by_lalr ||= [] #: Array[State::ResolvedConflict]
  @used_by_lalr << resolved_conflict
end

#used_by?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/lrama/grammar/precedence.rb', line 40

def used_by?
  used_by_lalr? || used_by_ielr?
end

#used_by_ielr?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/lrama/grammar/precedence.rb', line 50

def used_by_ielr?
  !@used_by_ielr.nil? && !@used_by_ielr.empty?
end

#used_by_lalr?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/lrama/grammar/precedence.rb', line 45

def used_by_lalr?
  !@used_by_lalr.nil? && !@used_by_lalr.empty?
end