lib/lrama/state/resolved_conflict.rb in lrama-0.6.9 vs lib/lrama/state/resolved_conflict.rb in lrama-0.6.10
- old
+ new
@@ -1,13 +1,15 @@
+# frozen_string_literal: true
+
module Lrama
class State
# * symbol: A symbol under discussion
# * reduce: A reduce under discussion
# * which: For which a conflict is resolved. :shift, :reduce or :error (for nonassociative)
class ResolvedConflict < Struct.new(:symbol, :reduce, :which, :same_prec, keyword_init: true)
def report_message
s = symbol.display_name
- r = reduce.rule.precedence_sym.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})"