Class: Lrama::State::ResolvedConflict
- Inherits:
-
Struct
- Object
- Struct
- Lrama::State::ResolvedConflict
- Defined in:
- lib/lrama/states.rb
Overview
-
symbol: A symbol under discussion
-
reduce: A reduce under discussion
-
which: For which a conflict is resolved. :shift, :reduce or :error (for nonassociative)
Instance Attribute Summary collapse
-
#reduce ⇒ Object
Returns the value of attribute reduce.
-
#same_prec ⇒ Object
Returns the value of attribute same_prec.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#which ⇒ Object
Returns the value of attribute which.
Instance Method Summary collapse
Instance Attribute Details
#reduce ⇒ Object
Returns the value of attribute reduce
51 52 53 |
# File 'lib/lrama/states.rb', line 51 def reduce @reduce end |
#same_prec ⇒ Object
Returns the value of attribute same_prec
51 52 53 |
# File 'lib/lrama/states.rb', line 51 def same_prec @same_prec end |
#symbol ⇒ Object
Returns the value of attribute symbol
51 52 53 |
# File 'lib/lrama/states.rb', line 51 def symbol @symbol end |
#which ⇒ Object
Returns the value of attribute which
51 52 53 |
# File 'lib/lrama/states.rb', line 51 def which @which end |
Instance Method Details
#report_message ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/lrama/states.rb', line 52 def s = symbol.display_name r = reduce.rule.precedence_sym.display_name case when which == :shift && same_prec msg = "resolved as #{which} (%right #{s})" when which == :shift msg = "resolved as #{which} (#{r} < #{s})" when which == :reduce && same_prec msg = "resolved as #{which} (%left #{s})" when which == :reduce msg = "resolved as #{which} (#{s} < #{r})" when which == :error msg = "resolved as an #{which} (%nonassoc #{s})" else raise "Unknown direction. #{self}" end "Conflict between rule #{reduce.rule.id} and token #{s} #{msg}." end |