File: 05-reproducible-parsers.patch

package info (click to toggle)
antlr3 3.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,564 kB
  • sloc: java: 92,592; xml: 942; makefile: 37; sh: 19
file content (42 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Description: Replace the HashSets with LinkedHashSets to make the generated parsers reproducible
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/tool/src/main/antlr3/org/antlr/grammar/v3/DefineGrammarItemsWalker.g
+++ b/tool/src/main/antlr3/org/antlr/grammar/v3/DefineGrammarItemsWalker.g
@@ -45,6 +45,7 @@
 package org.antlr.grammar.v3;
 import org.antlr.tool.*;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Set;
 }
 
@@ -279,7 +280,7 @@
 throwsSpec returns [HashSet<String> exceptions]
 @init
 {
-	$exceptions = new HashSet<String>();
+	$exceptions = new LinkedHashSet<String>();
 }
 	:	^('throws' (ID {$exceptions.add($ID.text);})+ )
 	;
@@ -556,7 +557,7 @@
 	if ( state.backtracking == 0 )
 	{
 		if ( grammar.buildAST() )
-			currentRewriteRule.rewriteRefsDeep = new HashSet<GrammarAST>();
+			currentRewriteRule.rewriteRefsDeep = new LinkedHashSet<GrammarAST>();
 	}
 }
 	:	^(	REWRITES
@@ -582,8 +583,8 @@
 	{
 		// don't do if guessing
 		currentRewriteBlock=$start; // pts to BLOCK node
-		currentRewriteBlock.rewriteRefsShallow = new HashSet<GrammarAST>();
-		currentRewriteBlock.rewriteRefsDeep = new HashSet<GrammarAST>();
+		currentRewriteBlock.rewriteRefsShallow = new LinkedHashSet<GrammarAST>();
+		currentRewriteBlock.rewriteRefsDeep = new LinkedHashSet<GrammarAST>();
 	}
 }
 	:   ^( BLOCK rewrite_alternative EOB )