c721198
Description: Replace the HashSets with LinkedHashSets to make the generated parsers reproducible
c721198
Author: Emmanuel Bourg <ebourg@apache.org>
c721198
Forwarded: no
c721198
--- a/tool/src/main/antlr3/org/antlr/grammar/v3/DefineGrammarItemsWalker.g
c721198
+++ b/tool/src/main/antlr3/org/antlr/grammar/v3/DefineGrammarItemsWalker.g
c721198
@@ -45,6 +45,7 @@
c721198
 package org.antlr.grammar.v3;
c721198
 import org.antlr.tool.*;
c721198
 import java.util.HashSet;
c721198
+import java.util.LinkedHashSet;
c721198
 import java.util.Set;
c721198
 }
c721198
 
c721198
@@ -279,7 +280,7 @@
c721198
 throwsSpec returns [HashSet<String> exceptions]
c721198
 @init
c721198
 {
c721198
-	$exceptions = new HashSet<String>();
c721198
+	$exceptions = new LinkedHashSet<String>();
c721198
 }
c721198
 	:	^('throws' (ID {$exceptions.add($ID.text);})+ )
c721198
 	;
c721198
@@ -556,7 +557,7 @@
c721198
 	if ( state.backtracking == 0 )
c721198
 	{
c721198
 		if ( grammar.buildAST() )
c721198
-			currentRewriteRule.rewriteRefsDeep = new HashSet<GrammarAST>();
c721198
+			currentRewriteRule.rewriteRefsDeep = new LinkedHashSet<GrammarAST>();
c721198
 	}
c721198
 }
c721198
 	:	^(	REWRITES
c721198
@@ -582,8 +583,8 @@
c721198
 	{
c721198
 		// don't do if guessing
c721198
 		currentRewriteBlock=$start; // pts to BLOCK node
c721198
-		currentRewriteBlock.rewriteRefsShallow = new HashSet<GrammarAST>();
c721198
-		currentRewriteBlock.rewriteRefsDeep = new HashSet<GrammarAST>();
c721198
+		currentRewriteBlock.rewriteRefsShallow = new LinkedHashSet<GrammarAST>();
c721198
+		currentRewriteBlock.rewriteRefsDeep = new LinkedHashSet<GrammarAST>();
c721198
 	}
c721198
 }
c721198
 	:   ^( BLOCK rewrite_alternative EOB )