From 3790468c1be6054ee8a2e89746ad4a7fcc3d1c43 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 9 Sep 2015 05:25:49 -0400 Subject: [PATCH] nitcc: remove S/R reduction after detection to avoid concurent iteration/mutation issues Signed-off-by: Jean Privat --- contrib/nitcc/src/grammar.nit | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/nitcc/src/grammar.nit b/contrib/nitcc/src/grammar.nit index e05e447..fc10a98 100644 --- a/contrib/nitcc/src/grammar.nit +++ b/contrib/nitcc/src/grammar.nit @@ -995,6 +995,8 @@ class LRState abort end end + # Token to remove as reduction guard to solve S/R conflicts + var removed_reduces = new Array[Token] for t, a in guarded_reduce do if a.length > 1 then print "REDUCE/REDUCE Conflict on state {self.number} {self.name} for token {t}:" @@ -1031,7 +1033,7 @@ class LRState print "Automatic Dangling on state {self.number} {self.name} for token {t}:" print "\treduce: {ri}" for r in ress do print r - guarded_reduce.keys.remove(t) + removed_reduces.add t else print "SHIFT/REDUCE Conflict on state {self.number} {self.name} for token {t}:" print "\treduce: {ri}" @@ -1039,6 +1041,9 @@ class LRState end end end + for t in removed_reduces do + guarded_reduce.keys.remove(t) + end end # Return `i` and all other items of the state that expands, directly or indirectly, to `i` -- 1.7.9.5