diff --git a/0002-conversion-timeout.patch b/0002-conversion-timeout.patch new file mode 100644 index 0000000..8bd8536 --- /dev/null +++ b/0002-conversion-timeout.patch @@ -0,0 +1,14 @@ +Description: Increase the default conversion timeout to avoid build failures when complex grammars are processed on slow architectures. +Author: Emmanuel Bourg +Forwarded: no +--- a/tool/src/main/java/org/antlr/analysis/DFA.java ++++ b/tool/src/main/java/org/antlr/analysis/DFA.java +@@ -57,7 +57,7 @@ + */ + + /** Set to 0 to not terminate early (time in ms) */ +- public static int MAX_TIME_PER_DFA_CREATION = 1*1000; ++ public static int MAX_TIME_PER_DFA_CREATION = 30*1000; + + /** How many edges can each DFA state have before a "special" state + * is created that uses IF expressions instead of a table? diff --git a/0003-fix-c-template.patch b/0003-fix-c-template.patch new file mode 100644 index 0000000..6eabc08 --- /dev/null +++ b/0003-fix-c-template.patch @@ -0,0 +1,35 @@ +Description: Fix various issues with the C template (backports of patchs proposed upstream) +Origin: backport, https://github.com/stephengaito/antlr3/commit/adc5e54 + https://github.com/stephengaito/antlr3/commit/71df80c +--- a/tool/src/main/resources/org/antlr/codegen/templates/C/C.stg ++++ b/tool/src/main/resources/org/antlr/codegen/templates/C/C.stg +@@ -2132,7 +2132,9 @@ + + LRECOVER(); + ++); ++!> + + goto ruleEx; + }<\n> +@@ -2143,7 +2145,10 @@ + EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; + EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; + ++EXCEPTION->expectingSet = NULL; ++expectingSet = &FOLLOW_set_in_; ++!> + + >> + +@@ -2510,7 +2515,7 @@ + */ + static const ANTLR3_INT32 * const dfa_transitions[] = + { +- _T}; separator=", ", wrap="\n", null="_empty"> ++ _T}; separator=", ", wrap="\n", null="NULL"> + }; + + diff --git a/0004-eof-token.patch b/0004-eof-token.patch new file mode 100644 index 0000000..2602ca6 --- /dev/null +++ b/0004-eof-token.patch @@ -0,0 +1,13 @@ +Description: Keep the Token.EOF_TOKEN field to preserve the backward compatibility +Author: Emmanuel Bourg +Forwarded: no +--- a/runtime/Java/src/main/java/org/antlr/runtime/Token.java ++++ b/runtime/Java/src/main/java/org/antlr/runtime/Token.java +@@ -38,6 +38,7 @@ + public static final int MIN_TOKEN_TYPE = UP+1; + + public static final int EOF = CharStream.EOF; ++ public static final Token EOF_TOKEN = new CommonToken(EOF); + + public static final int INVALID_TOKEN_TYPE = 0; + public static final Token INVALID_TOKEN = new CommonToken(INVALID_TOKEN_TYPE); diff --git a/0005-reproducible-parsers.patch b/0005-reproducible-parsers.patch new file mode 100644 index 0000000..a06bcaf --- /dev/null +++ b/0005-reproducible-parsers.patch @@ -0,0 +1,42 @@ +Description: Replace the HashSets with LinkedHashSets to make the generated parsers reproducible +Author: Emmanuel Bourg +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 exceptions] + @init + { +- $exceptions = new HashSet(); ++ $exceptions = new LinkedHashSet(); + } + : ^('throws' (ID {$exceptions.add($ID.text);})+ ) + ; +@@ -556,7 +557,7 @@ + if ( state.backtracking == 0 ) + { + if ( grammar.buildAST() ) +- currentRewriteRule.rewriteRefsDeep = new HashSet(); ++ currentRewriteRule.rewriteRefsDeep = new LinkedHashSet(); + } + } + : ^( REWRITES +@@ -582,8 +583,8 @@ + { + // don't do if guessing + currentRewriteBlock=$start; // pts to BLOCK node +- currentRewriteBlock.rewriteRefsShallow = new HashSet(); +- currentRewriteBlock.rewriteRefsDeep = new HashSet(); ++ currentRewriteBlock.rewriteRefsShallow = new LinkedHashSet(); ++ currentRewriteBlock.rewriteRefsDeep = new LinkedHashSet(); + } + } + : ^( BLOCK rewrite_alternative EOB ) diff --git a/antlr3.spec b/antlr3.spec index 111483c..f14bbdb 100644 --- a/antlr3.spec +++ b/antlr3.spec @@ -1,7 +1,7 @@ %global antlr_version 3.5.2 %global c_runtime_version 3.4 %global javascript_runtime_version 3.1 -%global baserelease 21 +%global baserelease 22 Summary: ANother Tool for Language Recognition Name: antlr3 @@ -18,6 +18,15 @@ Source3: http://www.antlr3.org/download/antlr-javascript-runtime-%{ja Patch0: 0001-java8-fix.patch # Generate OSGi metadata Patch1: osgi-manifest.patch +# Increase the default conversion timeout to avoid build failures when complex +# grammars are processed on slow architectures. Patch from Debian. +Patch2: 0002-conversion-timeout.patch +# Fix problems with the C template. Patch from Debian. +Patch3: 0003-fix-c-template.patch +# Keep Token.EOF_TOKEN for backwards compatibility. Patch from Debian. +Patch4: 0004-eof-token.patch +# Make parsers reproducible. Patch from Debian. +Patch5: 0005-reproducible-parsers.patch BuildRequires: maven-local BuildRequires: mvn(org.antlr:antlr) @@ -130,6 +139,10 @@ C++ runtime support for ANTLR-generated parsers. sed -i "s,\${buildNumber},`cat %{_sysconfdir}/fedora-release` `date`," tool/src/main/resources/org/antlr/antlr.properties %patch0 -p1 %patch1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 # remove pre-built artifacts find -type f -a -name *.jar -delete @@ -263,6 +276,9 @@ install -pm 644 runtime/Cpp/include/* $RPM_BUILD_ROOT/%{_includedir}/ %doc tool/LICENSE.txt %changelog +* Sat Apr 27 2019 Jerry James - 1:3.5.2-22 +- Add Debian patches + * Thu Jan 31 2019 Fedora Release Engineering - 1:3.5.2-21 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild