From bb3c950512934066d5bb62593309281a94dee58b Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 19 May 2023 11:20:36 +0900 Subject: [PATCH] Prevent NoMethodError in generating an error message Found by trial application of Steep --- lib/lrama/grammar.rb | 6 +++--- lib/lrama/states.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/lrama/grammar.rb b/lib/lrama/grammar.rb index 8ca75cb6..1e1b5b4c 100644 --- a/lib/lrama/grammar.rb +++ b/lib/lrama/grammar.rb @@ -166,7 +166,7 @@ def translated_printer_code(tag) when ref.type == :at # @n raise "@#{ref.number} can not be used in %printer." else - raise "Unexpected. #{code}, #{ref}" + raise "Unexpected. #{self}, #{ref}" end t_code[first_column..last_column] = str @@ -205,7 +205,7 @@ def translated_user_code i = -ref.position_in_rhs + ref.number str = "(yylsp[#{i}])" else - raise "Unexpected. #{code}, #{ref}" + raise "Unexpected. #{self}, #{ref}" end t_code[first_column..last_column] = str @@ -235,7 +235,7 @@ def translated_initial_action_code when ref.type == :at # @n raise "@#{ref.number} can not be used in initial_action." else - raise "Unexpected. #{code}, #{ref}" + raise "Unexpected. #{self}, #{ref}" end t_code[first_column..last_column] = str diff --git a/lib/lrama/states.rb b/lib/lrama/states.rb index f907db30..0750e5b0 100644 --- a/lib/lrama/states.rb +++ b/lib/lrama/states.rb @@ -198,7 +198,7 @@ def transition(sym) def find_reduce_by_item!(item) reduces.find do |r| r.item == item - end || (raise "reduce is not found. #{item}, #{state}") + end || (raise "reduce is not found. #{item}") end def default_reduction_rule=(default_reduction_rule)