From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uIbbIVWuZl8bNwAA0tVLHw (envelope-from ) for ; Sun, 20 Sep 2020 01:20:21 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mDjzHVWuZl9hfQAA1q6Kng (envelope-from ) for ; Sun, 20 Sep 2020 01:20:21 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CCE2F940215 for ; Sun, 20 Sep 2020 01:20:20 +0000 (UTC) Received: from localhost ([::1]:59556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJo1b-0000gB-H6 for larch@yhetil.org; Sat, 19 Sep 2020 21:20:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJo1K-0000fu-45 for guix-patches@gnu.org; Sat, 19 Sep 2020 21:20:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJo1J-0002Cq-Q4 for guix-patches@gnu.org; Sat, 19 Sep 2020 21:20:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kJo1J-0007KQ-Kj for guix-patches@gnu.org; Sat, 19 Sep 2020 21:20:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43525] [PATCH] gnu: Add antlr4. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 20 Sep 2020 01:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43525 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43525@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160056474728103 (code B ref -1); Sun, 20 Sep 2020 01:20:01 +0000 Received: (at submit) by debbugs.gnu.org; 20 Sep 2020 01:19:07 +0000 Received: from localhost ([127.0.0.1]:48446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJo0N-0007JA-QW for submit@debbugs.gnu.org; Sat, 19 Sep 2020 21:19:07 -0400 Received: from lists.gnu.org ([209.51.188.17]:52844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJo0I-0007Ii-D3 for submit@debbugs.gnu.org; Sat, 19 Sep 2020 21:19:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJo0H-0008UP-Tt for guix-patches@gnu.org; Sat, 19 Sep 2020 21:18:58 -0400 Received: from lepiller.eu ([2a00:5884:8208::1]:39642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJo0C-00027m-VA for guix-patches@gnu.org; Sat, 19 Sep 2020 21:18:57 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 868fa4e5 for ; Sun, 20 Sep 2020 01:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=qlm fOL+6zSZzoFARAf2MprF2ne6KkOHz7x3U7vDnbQc=; b=HuKbSF2hLeCki1sM/BJ OpRrAoNhCbxyZpAWbeKYNTRQemF3e4DCFcIW7WdnecjXEvK5yVA8TuDjY9ZM7BeN kReA5RGYjO9i4fnAyAJjw3giaDwP6z0beXuIjPVSsaLU6RjuXSy73qZIKLPd1Dzo u6DeYLpm54LpP9T75p/9VL/VkQ8xr/ULLcI45V+0tj47s/De1WE2RL+Dre70KQq9 lpeH4X12T5fso6BNDLVvx8YruwAxlO0IN8jbZd/LQdfB+MjfN/U51cLjQ5HmmpS/ G/bc/+JFLPRNUVZFqrkq4u9WiWwpWwmnCb513z8lisZmt4J5jVyTok0XXdXVlv4f KRQ== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 966d320c (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Sun, 20 Sep 2020 01:18:47 +0000 (UTC) Date: Sun, 20 Sep 2020 03:18:17 +0200 From: Julien Lepiller Message-ID: <20200920031817.1ff59225@tachikoma.lepiller.eu> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/EmZOkhwA+ErLU23qyQ6n4_D" Received-SPF: pass client-ip=2a00:5884:8208::1; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -2.3 (--) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=lepiller.eu header.s=dkim header.b=HuKbSF2h; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: lTuhsmJARL87 --MP_/EmZOkhwA+ErLU23qyQ6n4_D Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Guix! I tried to update groovy to its latest version today, so here's a patch series that adds ANTLR 4 instead :p (it's a build dependency for the newest version of groovy). --MP_/EmZOkhwA+ErLU23qyQ6n4_D Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-gnu-Add-java-treelayout.patch >From e9fa7e24a17870f3d3fc29742a85b7c699fbffdd Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sun, 20 Sep 2020 03:01:09 +0200 Subject: [PATCH 1/3] gnu: Add java-treelayout. * gnu/packages/java.scm (java-treelayout): New variable. --- gnu/packages/java.scm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index 1ef2ab3584..e05cc6b28c 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -8146,6 +8146,37 @@ import org.antlr.grammar.v2.ANTLRTreePrinter;")) (propagated-inputs `(("stringtemplate" ,java-stringtemplate-3))))) +(define-public java-treelayout + (package + (name "java-treelayout") + (version "1.0.3") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/abego/treelayout") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "18my8ql9b1y0n0zrvkih7xfhf3dpgfhyfifvkcfhmwcvw3divxak")))) + (build-system ant-build-system) + (arguments + `(#:jar-name (string-append ,name "-" ,version ".jar") + #:source-dir "org.abego.treelayout/src/main/java" + #:test-dir "org.abego.treelayout/src/test")) + (inputs + `(("java-junit" ,java-junit))) + (native-inputs + `(("java-hamcrest-core" ,java-hamcrest-core))) + (home-page "http://treelayout.sourceforge.net") + (synopsis "Tree Layout Algorithm in Java") + (description "TreeLayout creates tree layouts for arbitrary trees. It is +not restricted to a specific output or format, but can be used for any kind of +two dimensional diagram. Examples are Swing based components, SVG files, etc. +This is possible because TreeLayout separates the layout of a tree from the +actual rendering.") + (license license:bsd-3))) + (define-public java-commons-cli-1.2 ;; This is a bootstrap dependency for Maven2. (package -- 2.28.0 --MP_/EmZOkhwA+ErLU23qyQ6n4_D Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-gnu-Add-java-antlr4-runtime.patch >From 5d2fb32320f99ce733adaac0ee7381ae953f38bb Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sun, 20 Sep 2020 03:06:48 +0200 Subject: [PATCH 2/3] gnu: Add java-antlr4-runtime. * gnu/packages/java.scm (java-antlr4-runtime): New variable. * gnu/packages/patches/java-antlr4-Add-standalone-generator.patch: New file. * gnu/packages/patches/java-antlr4-fix-code-too-large.java: New file. * gnu/local.mk (dist_patch_DATA): Add them. --- gnu/local.mk | 2 + gnu/packages/java.scm | 34 +++++++ ...java-antlr4-Add-standalone-generator.patch | 52 +++++++++++ .../java-antlr4-fix-code-too-large.java | 90 +++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 gnu/packages/patches/java-antlr4-Add-standalone-generator.patch create mode 100644 gnu/packages/patches/java-antlr4-fix-code-too-large.java diff --git a/gnu/local.mk b/gnu/local.mk index 1a1a6488f9..dc9f07ba97 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1158,6 +1158,8 @@ dist_patch_DATA = \ %D%/packages/patches/jacal-fix-texinfo.patch \ %D%/packages/patches/jamvm-2.0.0-disable-branch-patching.patch \ %D%/packages/patches/jamvm-arm.patch \ + %D%/packages/patches/java-antlr4-Add-standalone-generator.patch \ + %D%/packages/patches/java-antlr4-fix-code-too-large.java \ %D%/packages/patches/java-apache-ivy-port-to-latest-bouncycastle.patch \ %D%/packages/patches/java-commons-collections-fix-java8.patch \ %D%/packages/patches/java-jeromq-fix-tests.patch \ diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index e05cc6b28c..b3a0bfcb65 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -8177,6 +8177,40 @@ This is possible because TreeLayout separates the layout of a tree from the actual rendering.") (license license:bsd-3))) +(define-public java-antlr4-runtime + (package + (name "java-antlr4-runtime") + (version "4.8") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/antlr/antlr4") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m")) + (patches + (search-patches "java-antlr4-Add-standalone-generator.patch" + "java-antlr4-fix-code-too-large.java")))) + (build-system ant-build-system) + (arguments + `(#:jar-name "java-antlr4-runtime.jar" + #:source-dir "runtime/Java/src/org" + #:tests? #f; tests depend on java-antlr4 itself + #:phases + (modify-phases %standard-phases + (add-before 'build 'copy-resources + (lambda _ + (copy-recursively "runtime/Java/src/main/dot" + "build/classes") + #t))))) + (home-page "https://antlr.org") + (synopsis "ANTLR runtime library") + (description "This package contains the runtime library used with generated +sources by ANTLR.") + (license license:bsd-3))) + (define-public java-commons-cli-1.2 ;; This is a bootstrap dependency for Maven2. (package diff --git a/gnu/packages/patches/java-antlr4-Add-standalone-generator.patch b/gnu/packages/patches/java-antlr4-Add-standalone-generator.patch new file mode 100644 index 0000000000..75b6dce39f --- /dev/null +++ b/gnu/packages/patches/java-antlr4-Add-standalone-generator.patch @@ -0,0 +1,52 @@ +From 3b43b79da15be994348f13035474925ba592fe1f Mon Sep 17 00:00:00 2001 +From: Julien Lepiller +Date: Fri, 15 Sep 2017 10:06:42 +0200 +Subject: [PATCH] Add standalone template generator + +--- + tool/src/org/antlr/v4/unicode/UnicodeRenderer.java | 33 ++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + create mode 100644 tool/src/org/antlr/v4/unicode/UnicodeRenderer.java + +diff --git a/tool/src/org/antlr/v4/unicode/UnicodeRenderer.java b/tool/src/org/antlr/v4/unicode/UnicodeRenderer.java +new file mode 100644 +index 0000000..9e53213 +--- /dev/null ++++ b/tool/src/org/antlr/v4/unicode/UnicodeRenderer.java +@@ -0,0 +1,33 @@ ++package org.antlr.v4.unicode; ++ ++import org.stringtemplate.v4.*; ++import org.stringtemplate.v4.misc.ErrorBuffer; ++import org.antlr.v4.unicode.UnicodeDataTemplateController; ++ ++import java.io.File; ++import java.io.FileWriter; ++import java.io.IOException; ++import java.util.Map; ++import java.util.Map.Entry; ++ ++public class UnicodeRenderer extends UnicodeDataTemplateController { ++ public static void main(String[] arg) ++ throws IOException { ++ String inputdir = arg[0]; ++ String input = arg[1]; ++ String output = arg[2]; ++ ++ FileWriter fileWriter = new FileWriter(new File(output)); ++ ErrorBuffer listener = new ErrorBuffer(); ++ ++ STGroupDir group = new STGroupDir(inputdir); ++ ST st = group.getInstanceOf(input); ++ ++ for(Entry entry : getProperties().entrySet()) ++ st.add(entry.getKey(), entry.getValue()); ++ ++ st.write(new AutoIndentWriter(fileWriter), listener); ++ fileWriter.flush(); ++ fileWriter.close(); ++ } ++} +-- +2.13.5 + diff --git a/gnu/packages/patches/java-antlr4-fix-code-too-large.java b/gnu/packages/patches/java-antlr4-fix-code-too-large.java new file mode 100644 index 0000000000..9e9f92349d --- /dev/null +++ b/gnu/packages/patches/java-antlr4-fix-code-too-large.java @@ -0,0 +1,90 @@ +From d22db2048534bdf3d9615117291f9d86564ff10d Mon Sep 17 00:00:00 2001 +From: Julien Lepiller +Date: Sat, 19 Sep 2020 21:05:48 +0200 +Subject: [PATCH] Separate addPropertyAliases in two methods + +The quantity of data used to generate addPropertyAliases creates a big +method, that is too big for java and results in "error: code too large". +This is most likely due to added data between the expected version of +icu and the actual version of icu in Guix. +--- + .../org/antlr/v4/tool/templates/unicodedata.st | 17 ++++++++++++++--- + .../unicode/UnicodeDataTemplateController.java | 18 ++++++++++-------- + 2 files changed, 24 insertions(+), 11 deletions(-) + +diff --git a/tool/resources/org/antlr/v4/tool/templates/unicodedata.st b/tool/resources/org/antlr/v4/tool/templates/unicodedata.st +index 0f22c73..3573873 100644 +--- a/tool/resources/org/antlr/v4/tool/templates/unicodedata.st ++++ b/tool/resources/org/antlr/v4/tool/templates/unicodedata.st +@@ -1,4 +1,4 @@ +-unicodedata(propertyCodePointRanges, propertyAliases) ::= << ++unicodedata(propertyCodePointRanges, propertyAliasesA, propertyAliasesB) ::= << + package org.antlr.v4.unicode; + + import java.util.Arrays; +@@ -15,7 +15,7 @@ import org.antlr.v4.runtime.misc.Interval; + */ + public abstract class UnicodeData { + private static final Map\ propertyCodePointRanges = new HashMap\<\>(); +- private static final Map\ propertyAliases = new HashMap\<\>(); ++ private static final Map\ propertyAliases = new HashMap\<\>( + ); + + // Work around Java 64k bytecode method limit by splitting up static + // initialization into one method per Unicode property +@@ -30,9 +30,20 @@ static private void addProperty() { + propertyCodePointRanges.put("".toLowerCase(Locale.US), codePointRanges); + \}}; separator="\n\n"> + ++ // Property aliases ++ static private void addPropertyAliases1() { ++ ".toLowerCase(Locale.US), "".toLowerCase(Locale.US)); }; separator="\n"> ++ } ++ ++ // Property aliases ++ static private void addPropertyAliases2() { ++ ".toLowerCase(Locale.US), "".toLowerCase(Locale.US)); }; separator="\n"> ++ } ++ + // Property aliases + static private void addPropertyAliases() { +- ".toLowerCase(Locale.US), "".toLowerCase(Locale.US)); }; separator="\n"> ++ addPropertyAliases1(); ++ addPropertyAliases2(); + } + + // Put it all together +diff --git a/tool/src/org/antlr/v4/unicode/UnicodeDataTemplateController.java b/tool/src/org/antlr/v4/unicode/UnicodeDataTemplateController.java +index da244a3..dc591cb 100644 +--- a/tool/src/org/antlr/v4/unicode/UnicodeDataTemplateController.java ++++ b/tool/src/org/antlr/v4/unicode/UnicodeDataTemplateController.java +@@ -78,17 +78,19 @@ public abstract class UnicodeDataTemplateController { + addTR35ExtendedPictographicPropertyCodesToCodePointRanges(propertyCodePointRanges); + addEmojiPresentationPropertyCodesToCodePointRanges(propertyCodePointRanges); + +- Map propertyAliases = new LinkedHashMap<>(); +- addUnicodeCategoryCodesToNames(propertyAliases); +- addUnicodeBinaryPropertyCodesToNames(propertyAliases); +- addUnicodeScriptCodesToNames(propertyAliases); +- addUnicodeBlocksToNames(propertyAliases); +- addUnicodeIntPropertyCodesToNames(propertyAliases); +- propertyAliases.put("EP", "Extended_Pictographic"); ++ Map propertyAliases1 = new LinkedHashMap<>(); ++ Map propertyAliases2 = new LinkedHashMap<>(); ++ addUnicodeCategoryCodesToNames(propertyAliases1); ++ addUnicodeBinaryPropertyCodesToNames(propertyAliases1); ++ addUnicodeScriptCodesToNames(propertyAliases1); ++ addUnicodeBlocksToNames(propertyAliases2); ++ addUnicodeIntPropertyCodesToNames(propertyAliases2); ++ propertyAliases2.put("EP", "Extended_Pictographic"); + + Map properties = new LinkedHashMap<>(); + properties.put("propertyCodePointRanges", propertyCodePointRanges); +- properties.put("propertyAliases", propertyAliases); ++ properties.put("propertyAliasesA", propertyAliases1); ++ properties.put("propertyAliasesB", propertyAliases2); + return properties; + } + +-- +2.28.0 + -- 2.28.0 --MP_/EmZOkhwA+ErLU23qyQ6n4_D Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0003-gnu-Add-antlr4.patch >From 7141f332ac488f52de4674a4cb9e6079ebb9ba97 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sun, 20 Sep 2020 03:09:23 +0200 Subject: [PATCH 3/3] gnu: Add antlr4. * gnu/packages/java.scm (antlr4): New variable. --- gnu/packages/java.scm | 158 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm index b3a0bfcb65..cc0ef1a759 100644 --- a/gnu/packages/java.scm +++ b/gnu/packages/java.scm @@ -8211,6 +8211,164 @@ actual rendering.") sources by ANTLR.") (license license:bsd-3))) +(define-public antlr4 + (package + (inherit java-antlr4-runtime) + (name "antlr4") + (arguments + `(#:jar-name "antlr4.jar" + #:source-dir "tool/src" + #:test-dir "tool-testsuite/test:runtime-testsuite/test:runtime-testsuite/annotations/src" + #:test-include (list "**/Test*.java") + #:test-exclude (list + ;; no runnable method + "**/TestOutputReading.java" + ;; no @Test methods + "**/TestParserErrors.java" + "**/TestSemPredEvalParser.java" + "**/TestSets.java" + "**/TestListeners.java" + "**/TestParseTrees.java" + "**/TestParserExec.java" + "**/TestLexerErrors.java" + "**/TestPerformance.java" + "**/TestCompositeParsers.java" + "**/TestLexerExec.java" + "**/TestSemPredEvalLexer.java" + "**/TestLeftRecursion.java" + "**/TestFullContextParsing.java" + "**/TestCompositeLexers.java" + ;; Null pointer exception + "**/TestCompositeGrammars.java" + ;; Wrong assumption on emoji + "**/TestUnicodeData.java") + #:phases + (modify-phases %standard-phases + (add-before 'build 'fix-build.xml + (lambda _ + ;; tests are not in a java subdirectory + (substitute* "build.xml" + (("\\$\\{test.home\\}/java") "${test.home}")) + #t)) + ;; tests require to have a working antlr4 binary + (delete 'check) + (add-after 'bin-install 'check + (lambda _ + (invoke "ant" "compile-tests") + (invoke "ant" "check" "-Dtest.home=runtime-testsuite/annotations/src") + (invoke "ant" "check" "-Dtest.home=runtime-testsuite/test") + (invoke "ant" "check" "-Dtest.home=tool-testsuite/test"))) + (add-before 'check 'remove-unrelated-languages + (lambda _ + ;; There are tests for other languages that ANTLR can generate, but + ;; we don't have the infrastructure for that yet. Let's test Java + ;; generation only. + (for-each + (lambda (language) + (delete-file-recursively + (string-append "runtime-testsuite/test/org/antlr/v4/test/runtime/" + language))) + '("cpp" "csharp" "go" "javascript" "php" "python" "python2" + "python3" "swift")) + #t)) + (add-before 'check 'generate-test-parsers + (lambda* (#:key outputs #:allow-other-keys) + (define (run-antlr dir filename package) + (invoke "antlr4" "-lib" dir "-visitor" "-no-listener" + "-package" package (string-append dir "/" filename) + "-Xlog")) + (setenv "PATH" (string-append (getenv "PATH") ":" + (assoc-ref outputs "out") "/bin")) + (run-antlr "runtime-testsuite/test/org/antlr/v4/test/runtime/java/api" + "Java.g4" "org.antlr.v4.test.runtime.java.api") + (run-antlr "runtime-testsuite/test/org/antlr/v4/test/runtime/java/api" + "VisitorBasic.g4" "org.antlr.v4.test.runtime.java.api") + (run-antlr "runtime-testsuite/test/org/antlr/v4/test/runtime/java/api" + "VisitorCalc.g4" "org.antlr.v4.test.runtime.java.api") + #t)) + (add-before 'check 'remove-graphemes + (lambda _ + ;; When running antlr on grahemes.g4, we get a runtime exception: + ;; set is empty. So delete the file that depends on it. + (delete-file "runtime-testsuite/test/org/antlr/v4/test/runtime/java/api/perf/TimeLexerSpeed.java"))) + (add-after 'install 'bin-install + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((jar (string-append (assoc-ref outputs "out") "/share/java")) + (bin (string-append (assoc-ref outputs "out") "/bin"))) + (mkdir-p bin) + (with-output-to-file (string-append bin "/antlr4") + (lambda _ + (display + (string-append "#!" (which "sh") "\n" + "java -cp " jar "/antlr4.jar:" + (string-join + (apply + append + (map + (lambda (input) + (find-files (assoc-ref inputs input) + ".*\\.jar")) + '("antlr3" "java-stringtemplate" + "java-antlr4-runtime" "java-treelayout" + "java-jsonp-api" "java-icu4j"))) + ":") + " org.antlr.v4.Tool $*")))) + (chmod (string-append bin "/antlr4") #o755) + #t))) + (add-before 'build 'copy-resources + (lambda _ + (copy-recursively "tool/resources/" "build/classes") + #t)) + (add-before 'build 'generate-unicode + (lambda _ + ;; First: build the generator + (invoke "javac" "-cp" (getenv "CLASSPATH") + "tool/src/org/antlr/v4/unicode/UnicodeRenderer.java" + "tool/src/org/antlr/v4/unicode/UnicodeDataTemplateController.java") + ;; Then use it + (invoke "java" "-cp" (string-append (getenv "CLASSPATH") + ":tool/src:runtime/Java") + "org.antlr.v4.unicode.UnicodeRenderer" + "tool/resources/org/antlr/v4/tool/templates" + "unicodedata" + "tool/src/org/antlr/v4/unicode/UnicodeData.java") + (begin + ;; It seems there is a bug with our ST4 + (substitute* "tool/src/org/antlr/v4/unicode/UnicodeData.java" + (("\\\\>") ">")) + ;; Remove the additional file + (delete-file "tool/src/org/antlr/v4/unicode/UnicodeRenderer.java") + #t))) + (add-before 'build 'generate-grammar + (lambda* (#:key inputs #:allow-other-keys) + (with-directory-excursion "tool/src/org/antlr/v4/parse" + (for-each (lambda (file) + (format #t "~a\n" file) + (system* "antlr3" file)) + '("ANTLRLexer.g" "ANTLRParser.g" "BlockSetTransformer.g" + "GrammarTreeVisitor.g" "ATNBuilder.g" + "ActionSplitter.g" "LeftRecursiveRuleWalker.g"))) + (with-directory-excursion "tool/src/org/antlr/v4/codegen" + (copy-file "../parse/ANTLRParser.tokens" "ANTLRParser.tokens") + (format #t "SourceGenTriggers.g\n") + (invoke "antlr3" "SourceGenTriggers.g")) + #t))))) + (inputs + `(("antlr3" ,antlr3) + ("java-antlr4-runtime" ,java-antlr4-runtime) + ("java-icu4j" ,java-icu4j) + ("java-jsonp-api" ,java-jsonp-api) + ("java-stringtemplate" ,java-stringtemplate) + ("java-treelayout" ,java-treelayout))) + (native-inputs + `(("java-junit" ,java-junit))) + (synopsis "Parser and lexer generator in Java") + (description "ANTLR (ANother Tool for Language Recognition) is a powerful +parser generator for reading, processing, executing, or translating structured +text or binary files. It's widely used to build languages, tools, and +frameworks. From a grammar, ANTLR generates a parser that can build and walk +parse trees."))) + (define-public java-commons-cli-1.2 ;; This is a bootstrap dependency for Maven2. (package -- 2.28.0 --MP_/EmZOkhwA+ErLU23qyQ6n4_D--