Class: Lrama::State::ResolvedConflict
- Inherits:
-
Struct
- Object
- Struct
- Lrama::State::ResolvedConflict
- Defined in:
- lib/lrama/state/resolved_conflict.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
6 7 8 |
# File 'lib/lrama/state/resolved_conflict.rb', line 6 def reduce @reduce end |
#same_prec ⇒ Object
Returns the value of attribute same_prec
6 7 8 |
# File 'lib/lrama/state/resolved_conflict.rb', line 6 def same_prec @same_prec end |
#symbol ⇒ Object
Returns the value of attribute symbol
6 7 8 |
# File 'lib/lrama/state/resolved_conflict.rb', line 6 def symbol @symbol end |
#which ⇒ Object
Returns the value of attribute which
6 7 8 |
# File 'lib/lrama/state/resolved_conflict.rb', line 6 def which @which end |
Instance Method Details
#report_message ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lrama/state/resolved_conflict.rb', line 7 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 |