From: Jean Privat Date: Wed, 9 Sep 2015 09:25:49 +0000 (-0400) Subject: nitcc: remove S/R reduction after detection to avoid concurent iteration/mutation... X-Git-Tag: v0.7.8~38^2~6 X-Git-Url: http://nitlanguage.org nitcc: remove S/R reduction after detection to avoid concurent iteration/mutation issues Signed-off-by: Jean Privat --- 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`