Fridrich Strba 2024-09-21 11:06:41 +00:00 committed by Git OBS Bridge
commit 00126829d1
11 changed files with 60742 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

3
3.5.3.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a0892bcf164573d539b930e57a87ea45333141863a0dd3a49e5d8c919c8a58ab
size 6752328

4
_multibuild Normal file
View File

@ -0,0 +1,4 @@
<multibuild>
<package>bootstrap</package>
<package>runtime</package>
</multibuild>

60219
antlr3-generated_sources.patch Normal file

File diff suppressed because it is too large Load Diff

63
antlr3-java8-fix.patch Normal file
View File

@ -0,0 +1,63 @@
From 33f662c60e6e7b703e197854d2478a8747f044f0 Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Tue, 17 Jun 2014 19:36:24 +0200
Subject: [PATCH] java8 fix
Signed-off-by: Michael Simacek <msimacek@redhat.com>
---
tool/src/main/java/org/antlr/codegen/CodeGenerator.java | 2 +-
tool/src/main/java/org/antlr/tool/Grammar.java | 4 ++--
tool/src/main/java/org/antlr/tool/Strip.java | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tool/src/main/java/org/antlr/codegen/CodeGenerator.java b/tool/src/main/java/org/antlr/codegen/CodeGenerator.java
index b279bd5..566e33c 100644
--- a/tool/src/main/java/org/antlr/codegen/CodeGenerator.java
+++ b/tool/src/main/java/org/antlr/codegen/CodeGenerator.java
@@ -1087,7 +1087,7 @@ public class CodeGenerator {
catch (Exception tse) {
ErrorManager.internalError("can't parse template action",tse);
}
- GrammarAST rewriteTree = parseResult.getTree();
+ GrammarAST rewriteTree = (GrammarAST)parseResult.getTree();
// then translate via codegen.g
CodeGenTreeWalker gen = new CodeGenTreeWalker(new CommonTreeNodeStream(rewriteTree));
diff --git a/tool/src/main/java/org/antlr/tool/Grammar.java b/tool/src/main/java/org/antlr/tool/Grammar.java
index 667ebb2..4ca4328 100644
--- a/tool/src/main/java/org/antlr/tool/Grammar.java
+++ b/tool/src/main/java/org/antlr/tool/Grammar.java
@@ -706,7 +706,7 @@ public class Grammar {
}
}
- setGrammarTree(result.getTree());
+ setGrammarTree((GrammarAST)result.getTree());
//if ( grammarTree!=null ) System.out.println("grammar tree: "+grammarTree.toStringTree());
@@ -927,7 +927,7 @@ public class Grammar {
parser.setGrammarType(this.type);
try {
ANTLRParser.rule_return result = parser.rule();
- return result.getTree();
+ return (GrammarAST)result.getTree();
}
catch (Exception e) {
ErrorManager.error(ErrorManager.MSG_ERROR_CREATING_ARTIFICIAL_RULE,
diff --git a/tool/src/main/java/org/antlr/tool/Strip.java b/tool/src/main/java/org/antlr/tool/Strip.java
index f411090..ddda4ed 100644
--- a/tool/src/main/java/org/antlr/tool/Strip.java
+++ b/tool/src/main/java/org/antlr/tool/Strip.java
@@ -64,7 +64,7 @@ public class Strip {
tokens = new TokenRewriteStream(lex);
ANTLRv3Parser g = new ANTLRv3Parser(tokens);
ANTLRv3Parser.grammarDef_return r = g.grammarDef();
- CommonTree t = r.getTree();
+ CommonTree t = (CommonTree)r.getTree();
if (tree_option) System.out.println(t.toStringTree());
rewrite(g.getTreeAdaptor(),t,g.getTokenNames());
}
--
2.7.4

View File

@ -0,0 +1,25 @@
Index: runtime/Java/pom.xml
===================================================================
--- runtime/Java/pom.xml.orig
+++ runtime/Java/pom.xml
@@ -81,6 +81,20 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId><artifactId>maven-bundle-plugin</artifactId>
+ <executions><execution><id>bundle-manifest</id><phase>process-classes</phase><goals><goal>manifest</goal></goals></execution></executions>
+ <configuration>
+ <manifestLocation>${project.build.directory}/osgi</manifestLocation>
+ <instructions><Bundle-SymbolicName>org.antlr.runtime</Bundle-SymbolicName><Import-Package>!org.antlr.stringtemplate,*</Import-Package></instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive><manifestFile>${project.build.directory}/osgi/MANIFEST.MF</manifestFile></archive>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>

70
antlr3.changes Normal file
View File

@ -0,0 +1,70 @@
-------------------------------------------------------------------
Sat Sep 21 11:04:46 UTC 2024 - Fridrich Strba <fstrba@suse.com>
- Modified patch:
* reproducible-order.patch
+ some more instances where the sorting (sorted containers)
are needed
* antlr3-generated_sources.patch
+ regenerate in cycle to correspond to the changes in the
reproducible-order.patch
-------------------------------------------------------------------
Tue Feb 20 10:54:40 UTC 2024 - Dominique Leuenberger <dimstar@opensuse.org>
- Use %patch -P N instead of deprecated %patchN.
-------------------------------------------------------------------
Mon Sep 25 09:21:59 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- Remove dependency on maven2
-------------------------------------------------------------------
Fri Sep 15 16:02:58 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- Added patches:
* reproducible-order.patch
+ ensure reproducible elements order by sorting
* reproducible-timestamp.patch
+ support SOURCE_DATE_EPOCH for generatedTimestamp
- Modified patch:
* antlr3-generated_sources.patch
+ regenerate in cycle with stringtemplate4 to correspond to
the reproducible build changes
-------------------------------------------------------------------
Fri Sep 15 08:19:19 UTC 2023 - Bernhard Wiedemann <bwiedemann@suse.com>
- Override build date (boo#1047218)"
-------------------------------------------------------------------
Fri Mar 17 06:55:33 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- No need to use enforcer plugin in controlled environment
-------------------------------------------------------------------
Fri Nov 18 21:43:50 UTC 2022 - Pedro Monreal <pmonreal@suse.com>
- Update to 3.5.3:
* change source compatibility to 1.8 and enable github workflows
* Change Wiki URLs to theantlrguy.atlassian.net in README.txt
* Bazel support
* Modify patches:
- Rebase osgi-manifest.patch and rename to antlr3-osgi-manifest.patch
- Rename 0001-java8-fix.patch to antlr3-java8-fix.patch
-------------------------------------------------------------------
Mon Mar 21 14:54:29 UTC 2022 - Fridrich Strba <fstrba@suse.com>
- Build with source and target levels 8
-------------------------------------------------------------------
Sun Nov 24 11:36:43 UTC 2019 - Fridrich Strba <fstrba@suse.com>
- Specify maven.compiler.release to fix build with jdk9+ and newer
maven-javadoc-plugin
-------------------------------------------------------------------
Thu Sep 12 07:57:47 UTC 2019 - Fridrich Strba <fstrba@suse.com>
- Initial packaging of antlr3 3.5.2 as multibuild package

251
antlr3.spec Normal file
View File

@ -0,0 +1,251 @@
#
# spec file for package antlr3
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%global antlr_version 3.5.3
%global c_runtime_version 3.4
%global javascript_runtime_version 3.1
%if "%{flavor}" == "bootstrap"
%bcond_without bootstrap
%else
%bcond_with bootstrap
%endif
%if "%{flavor}" == "runtime"
%bcond_without runtime
%else
%bcond_with runtime
%endif
Version: %{antlr_version}
Release: 0
URL: https://www.antlr3.org/
Source0: https://github.com/antlr/antlr3/archive/%{antlr_version}.tar.gz
Patch0: antlr3-java8-fix.patch
# Generate OSGi metadata
Patch1: antlr3-osgi-manifest.patch
Patch2: reproducible-order.patch
Patch3: reproducible-timestamp.patch
Patch100: antlr3-generated_sources.patch
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
BuildRequires: maven-local
BuildRequires: unzip
BuildRequires: mvn(antlr:antlr)
BuildRequires: mvn(org.antlr:stringtemplate)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.sonatype.oss:oss-parent:pom:)
BuildArch: noarch
%if %{with runtime}
Name: antlr3-java
Summary: Java run-time support for ANTLR-generated parsers
License: BSD-3-Clause
Group: Development/Libraries/Java
%description
Java run-time support for ANTLR-generated parsers
%else
Summary: ANother Tool for Language Recognition
License: BSD-3-Clause
Group: Development/Libraries/Java
BuildRequires: unzip
BuildRequires: mvn(org.antlr:ST4)
BuildRequires: mvn(org.antlr:antlr-runtime)
BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin)
BuildRequires: mvn(org.apache.maven:maven-plugin-api)
BuildRequires: mvn(org.codehaus.plexus:plexus-compiler-api)
BuildRequires: mvn(xerces:dom3-xml-apis)
%if %{with bootstrap}
Name: antlr3-bootstrap
BuildRequires: xz
#!BuildRequires: stringtemplate4-bootstrap
%else
Name: antlr3
BuildRequires: ant
BuildRequires: antlr
BuildRequires: mvn(org.antlr:antlr)
BuildRequires: mvn(org.antlr:antlr3-maven-plugin)
#!BuildRequires: stringtemplate4
#!BuildRequires: antlr3-bootstrap-tool
%endif
%description
ANother Tool for Language Recognition, is a language tool
that provides a framework for constructing recognizers,
interpreters, compilers, and translators from grammatical
descriptions containing actions in a variety of target languages.
%package tool
Summary: ANother Tool for Language Recognition
Group: Development/Libraries/Java
# Explicit requires for javapackages-tools since antlr3-script
# uses /usr/share/java-utils/java-functions
Requires: javapackages-tools
Requires: mvn(org.antlr:antlr-runtime) = %{antlr_version}
%if %{without bootstrap}
Conflicts: antlr3-bootstrap-tool
Provides: antlr3-bootstrap-tool
%endif
%description tool
ANother Tool for Language Recognition, is a language tool
that provides a framework for constructing recognizers,
interpreters, compilers, and translators from grammatical
descriptions containing actions in a variety of target languages.
%endif
%if %{without boostrap}
%package javadoc
Summary: API documentation for %{name}
Group: Documentation/HTML
BuildArch: noarch
%description javadoc
%{summary}.
%endif
%prep
%setup -q -n antlr3-%{antlr_version}
%if %{with bootstrap}
%patch -P 100
%pom_remove_plugin :antlr3-maven-plugin tool
%endif
sed -i "s,\${buildNumber},`date -u -d@${SOURCE_DATE_EPOCH:-$(date +%%s)}`," tool/src/main/resources/org/antlr/antlr.properties
%patch -P 0 -p1
%patch -P 1
%patch -P 2 -p1
%patch -P 3 -p1
# remove pre-built artifacts
find -type f -a -name *.jar -delete
find -type f -a -name *.class -delete
%pom_disable_module antlr3-maven-archetype
%pom_disable_module gunit
%pom_disable_module gunit-maven-plugin
%pom_disable_module antlr-complete
%if %{with runtime}
%pom_disable_module tool
%pom_disable_module antlr3-maven-plugin
%else
%pom_disable_module runtime/Java
%endif
%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin -r :maven-javadoc-plugin
%pom_remove_plugin :maven-enforcer-plugin
# compile for target 1.8
sed -i 's/jsr14/1.8/' antlr3-maven-archetype/src/main/resources/archetype-resources/pom.xml \
antlr3-maven-plugin/pom.xml \
gunit/pom.xml \
gunit-maven-plugin/pom.xml \
pom.xml \
runtime/Java/pom.xml \
tool/pom.xml
# workarounds bug in filtering (Mark invalid)
%pom_xpath_remove pom:resource/pom:filtering
%{mvn_package} :antlr-master __noinstall
%if %{without runtime}
%{mvn_package} : tool
%endif
%{mvn_file} :antlr antlr3
%{mvn_file} :antlr-runtime antlr3-runtime
%{mvn_file} :antlr-maven-plugin antlr3-maven-plugin
%build
%{mvn_build} -f \
%if %{with bootstrap}
-j \
%endif
-- \
%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 9}%{!?pkg_vcmp:0}
-Dmaven.compiler.release=8 \
%endif
-Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \
-Dsource=8
%if %{without runtime} && %{without bootstrap}
# build ant task
pushd antlr-ant/main/antlr3-task/
export CLASSPATH=$(build-classpath ant)
javac -encoding ISO-8859-1 -source 8 -target 8 antlr3-src/org/apache/tools/ant/antlr/ANTLR3.java
jar cvf ant-antlr3.jar \
-C antlr3-src org/apache/tools/ant/antlr/antlib.xml \
-C antlr3-src org/apache/tools/ant/antlr/ANTLR3.class
popd
%endif
%install
%mvn_install
%if %{without bootstrap}
%fdupes -s %{buildroot}%{_javadocdir}
%endif
%if %{without runtime}
mkdir -p %{buildroot}/%{_mandir}
mkdir -p %{buildroot}/%{_datadir}/antlr
%if %{without bootstrap}
# install ant task
install -m 644 antlr-ant/main/antlr3-task/ant-antlr3.jar -D %{buildroot}%{_javadir}/ant/ant-antlr3.jar
mkdir -p %{buildroot}%{_sysconfdir}/ant.d
cat > %{buildroot}%{_sysconfdir}/ant.d/ant-antlr3 << EOF
ant/ant-antlr3 antlr3
EOF
%endif
# install wrapper script
%jpackage_script org.antlr.Tool '' '' 'stringtemplate4/ST4.jar:antlr3.jar:antlr3-runtime.jar' antlr3 true
%files tool -f .mfiles-tool
%license tool/{LICENSE.txt,CHANGES.txt}
%doc README.txt
%{_bindir}/antlr3
%if %{without bootstrap}
%{_javadir}/ant/ant-antlr3.jar
%config(noreplace) %{_sysconfdir}/ant.d/ant-antlr3
%endif
%else
%files -f .mfiles
%license tool/LICENSE.txt
%endif
%if %{without bootstrap}
%files javadoc -f .mfiles-javadoc
%license tool/LICENSE.txt
%endif
%changelog

71
reproducible-order.patch Normal file
View File

@ -0,0 +1,71 @@
--- antlr3-3.5.3/tool/src/main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g 2024-09-21 12:35:02.440474037 +0200
+++ antlr3-3.5.3/tool/src/main/antlr3/org/antlr/grammar/v3/CodeGenTreeWalker.g 2024-09-21 12:52:37.133715512 +0200
@@ -53,9 +53,10 @@
import org.antlr.tool.*;
import org.antlr.codegen.*;
-import java.util.HashSet;
+import java.util.TreeSet;
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;
@@ -73,7 +74,7 @@
protected ST currentBlockST = null;
protected boolean currentAltHasASTRewrite = false;
protected int rewriteTreeNestingLevel = 0;
-protected HashSet<Object> rewriteRuleRefs = null;
+protected TreeSet<Object> rewriteRuleRefs = null;
public String getCurrentRuleName() {
return currentRuleName;
@@ -284,6 +285,7 @@
}
labels.add( label );
}
+ Collections.sort(labels); // ensure reproducible order
return labels;
}
@@ -1202,18 +1204,18 @@
$code.add("rewriteBlockLevel", OUTER_REWRITE_NESTING_LEVEL);
$code.add("referencedElementsDeep",
getTokenTypesAsTargetLabels($start.rewriteRefsDeep));
- Set<String> tokenLabels =
- grammar.getLabels($start.rewriteRefsDeep, Grammar.TOKEN_LABEL);
- Set<String> tokenListLabels =
- grammar.getLabels($start.rewriteRefsDeep, Grammar.TOKEN_LIST_LABEL);
- Set<String> ruleLabels =
- grammar.getLabels($start.rewriteRefsDeep, Grammar.RULE_LABEL);
- Set<String> ruleListLabels =
- grammar.getLabels($start.rewriteRefsDeep, Grammar.RULE_LIST_LABEL);
- Set<String> wildcardLabels =
- grammar.getLabels($start.rewriteRefsDeep, Grammar.WILDCARD_TREE_LABEL);
- Set<String> wildcardListLabels =
- grammar.getLabels($start.rewriteRefsDeep, Grammar.WILDCARD_TREE_LIST_LABEL);
+ TreeSet<String> tokenLabels =
+ new TreeSet<String>(grammar.getLabels($start.rewriteRefsDeep, Grammar.TOKEN_LABEL));
+ TreeSet<String> tokenListLabels =
+ new TreeSet<String>(grammar.getLabels($start.rewriteRefsDeep, Grammar.TOKEN_LIST_LABEL));
+ TreeSet<String> ruleLabels =
+ new TreeSet<String>(grammar.getLabels($start.rewriteRefsDeep, Grammar.RULE_LABEL));
+ TreeSet<String> ruleListLabels =
+ new TreeSet<String>(grammar.getLabels($start.rewriteRefsDeep, Grammar.RULE_LIST_LABEL));
+ TreeSet<String> wildcardLabels =
+ new TreeSet<String>(grammar.getLabels($start.rewriteRefsDeep, Grammar.WILDCARD_TREE_LABEL));
+ TreeSet<String> wildcardListLabels =
+ new TreeSet<String>(grammar.getLabels($start.rewriteRefsDeep, Grammar.WILDCARD_TREE_LIST_LABEL));
// just in case they ref $r for "previous value", make a stream
// from retval.tree
ST retvalST = templates.getInstanceOf("prevRuleRootRef");
@@ -1236,7 +1238,7 @@
}
: ^( REWRITES
(
- {rewriteRuleRefs = new HashSet<Object>();}
+ {rewriteRuleRefs = new TreeSet<Object>();}
^( r=REWRITE (pred=SEMPRED)? alt=rewrite_alternative)
{
rewriteBlockNestingLevel = OUTER_REWRITE_NESTING_LEVEL;

View File

@ -0,0 +1,12 @@
--- antlr3-3.5.3/tool/src/main/java/org/antlr/Tool.java 2023-09-15 17:54:38.044172037 +0200
+++ antlr3-3.5.3/tool/src/main/java/org/antlr/Tool.java 2023-09-15 17:54:49.090915002 +0200
@@ -1052,6 +1052,9 @@
*/
public static String getCurrentTimeStamp() {
GregorianCalendar calendar = new java.util.GregorianCalendar();
+ if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+ calendar.setTimeInMillis(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
+ }
int y = calendar.get(Calendar.YEAR);
int m = calendar.get(Calendar.MONTH) + 1; // zero-based for months
int d = calendar.get(Calendar.DAY_OF_MONTH);