[PATCH] gnu: Add antlr4.

  • Done
  • quality assurance status badge
Details
2 participants
  • Julien Lepiller
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Julien Lepiller
Severity
normal
J
J
Julien Lepiller wrote on 20 Sep 2020 03:18
(address . guix-patches@gnu.org)
20200920031817.1ff59225@tachikoma.lepiller.eu
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).
From e9fa7e24a17870f3d3fc29742a85b7c699fbffdd Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
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(+)

Toggle diff (44 lines)
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
R
R
Ricardo Wurmus wrote on 20 Sep 2020 08:59
(name . Julien Lepiller)(address . julien@lepiller.eu)(address . 43525@debbugs.gnu.org)
87eemxszll.fsf@elephly.net
Hi Julien,

Toggle quote (6 lines)
> + (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")))

Please let the phase end on #t. Please also use double spacing in
comments.

Toggle quote (21 lines)
> + (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)))

Why have a BEGIN here?

Toggle quote (6 lines)
> + (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)

I’m not sure this actually outputs anything. Does it? I’m not a fan of
using FORMAT when DISPLAY would work just fine.

Toggle quote (2 lines)
> + (system* "antlr3" file))

Why not INVOKE?

Toggle quote (6 lines)
> + '("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")

You can use INSTALL-FILE to avoid having to restate the target file name.

Toggle quote (2 lines)
> + (format #t "SourceGenTriggers.g\n")

How about DISPLAY here?

--
Ricardo
J
J
Julien Lepiller wrote on 20 Sep 2020 14:00
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 43525-done@debbugs.gnu.org)
20200920140009.7ddfb572@tachikoma.lepiller.eu
Pushed as 1d630fe0f64d16d7428a78ee4bf94e8179ce4a94 to
f9a6e3894b1648e32371e1916dfdf820de496050, thank you!
Closed
?