Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ANTLR3 produce Reproducible output #209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tool/src/main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import org.antlr.codegen.*;
import java.util.HashSet;
import java.util.Set;
import java.util.Collection;
import java.util.Collections;
import org.antlr.runtime.BitSet;
import org.antlr.runtime.DFA;
import org.stringtemplate.v4.ST;
Expand Down Expand Up @@ -284,6 +285,7 @@ protected final List<String> getTokenTypesAsTargetLabels(Collection<GrammarAST>
}
labels.add( label );
}
Collections.sort(labels); // ensure reproducible order
return labels;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>
package<if(actions.(actionScope).package)> <actions.(actionScope).package><endif> {
<actions.(actionScope).header>
<@imports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ leadIn(type) ::=
* This <type> file was generated by $ANTLR version <ANTLRVersion>
*
* - From the grammar source file : <fileName>
* - On : <generatedTimestamp>
<if(LEXER)>
* - for the lexer : <name>Lexer
<endif>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ outputFile( LEXER,PARSER,TREE_PARSER, actionScope, actions,
// \</auto-generated>
//------------------------------------------------------------------------------

// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>

<if(trace)>
#define ANTLR_TRACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ outputFile( LEXER,PARSER,TREE_PARSER, actionScope, actions,
// \</auto-generated>
//------------------------------------------------------------------------------

// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>

// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 219
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ leadIn(type) ::=
* This <type> file was generated by $ANTLR version <ANTLRVersion>
*
* - From the grammar source file : <fileName>
* - On : <generatedTimestamp>
<if(LEXER)>
* - for the lexer : <name>Lexer
<endif>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ unit <name>;

{$HINTS OFF}

// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>

<actions.(actionScope).header>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>
<actions.(actionScope).header>

<@imports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>
<actions.(actionScope).header>

<@imports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ leadIn(type) ::=
* This <type> file was generated by $ANTLR version <ANTLRVersion>
*
* - From the grammar source file : <fileName>
* - On : <generatedTimestamp>
<if(LEXER)>
* - for the lexer : <name>Lexer
<endif>
Expand Down Expand Up @@ -120,7 +119,7 @@ outputFile( LEXER,
<<
<leadIn("OBJC source")>
*/
// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>

<! <if(actions.(actionScope).header)>
/* =============================================================================
Expand Down Expand Up @@ -190,7 +189,7 @@ headerFile( LEXER,
literals
) ::=
<<
// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>

<@imports>
<actions.(actionScope).preincludes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
# $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
# $ANTLR <ANTLRVersion> <fileName>
<actions.(actionScope).header>

<@imports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
# $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
# $ANTLR <ANTLRVersion> <fileName>

<@imports>
import sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
# $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
# $ANTLR <ANTLRVersion> <fileName>

<@imports>
import sys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ outputFile(LEXER, PARSER, TREE_PARSER, actionScope, actions, docComment, recogni
# Generated using ANTLR version: <ANTLRVersion>
# Ruby runtime library version: <runtimeLibraryVersion()>
# Input grammar file: <fileName>
# Generated at: <generatedTimestamp>
#

# ~~~\> start load path setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ outputFile(LEXER,PARSER,TREE_PARSER, actionScope, actions,
fileName, ANTLRVersion, generatedTimestamp, trace,
scopes, superClass, literals) ::=
<<
// $ANTLR <ANTLRVersion> <fileName> <generatedTimestamp>
// $ANTLR <ANTLRVersion> <fileName>
<actions.(actionScope).header>

<@imports>
Expand Down