1 { lib, stdenv, fetchurl, jre
2 , fetchFromGitHub, cmake, ninja, pkg-config
5 , CoreFoundation ? null
16 version, sourceSha256, jarSha256,
17 extraCppBuildInputs ? [],
18 extraCppCmakeFlags ? [],
21 source = fetchFromGitHub {
25 sha256 = sourceSha256;
28 antlr = stdenv.mkDerivation {
33 url = "https://www.antlr.org/download/antlr-${version}-complete.jar";
40 mkdir -p "$out"/{share/java,bin}
41 ln -s "$src" "$out/share/java/antlr-${version}-complete.jar"
43 echo "#! ${stdenv.shell}" >> "$out/bin/antlr"
44 echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.Tool \"\$@\"" >> "$out/bin/antlr"
46 echo "#! ${stdenv.shell}" >> "$out/bin/antlr-parse"
47 echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' -Xmx500M org.antlr.v4.gui.Interpreter \"\$@\"" >> "$out/bin/antlr-parse"
49 echo "#! ${stdenv.shell}" >> "$out/bin/grun"
50 echo "'${jre}/bin/java' -cp '$out/share/java/antlr-${version}-complete.jar:$CLASSPATH' org.antlr.v4.gui.TestRig \"\$@\"" >> "$out/bin/grun"
52 chmod a+x "$out/bin/antlr" "$out/bin/antlr-parse" "$out/bin/grun"
53 ln -s "$out/bin/antlr"{,4}
54 ln -s "$out/bin/antlr"{,4}-parse
61 jarLocation = antlr.src;
65 description = "Powerful parser generator";
67 ANTLR (ANother Tool for Language Recognition) is a powerful parser
68 generator for reading, processing, executing, or translating structured
69 text or binary files. It's widely used to build languages, tools, and
70 frameworks. From a grammar, ANTLR generates a parser that can build and
73 homepage = "https://www.antlr.org/";
74 sourceProvenance = with sourceTypes; [ binaryBytecode ];
75 license = licenses.bsd3;
76 platforms = platforms.unix;
81 cpp = stdenv.mkDerivation {
82 pname = "antlr-runtime-cpp";
86 patches = extraPatches;
88 outputs = [ "out" "dev" "doc" ];
90 nativeBuildInputs = [ cmake ninja pkg-config ];
92 lib.optional stdenv.isDarwin CoreFoundation ++
95 cmakeDir = "../runtime/Cpp";
97 cmakeFlags = extraCppCmakeFlags;
100 description = "C++ target for ANTLR 4";
101 homepage = "https://www.antlr.org/";
102 license = licenses.bsd3;
103 platforms = platforms.unix;
110 antlr4_13 = (mkAntlr {
112 sourceSha256 = "sha256-s1yAdScMYg1wFpYNsBAtpifIhQsnSAgJg7JjPDx+htc=";
113 jarSha256 = "sha256-vG9KvA0iWidXASbFFAJWnwAKje2jSHtw52QoQOVw5KY=";
114 extraCppCmakeFlags = [
115 # Generate CMake config files, which are not installed by default.
116 "-DANTLR4_INSTALL=ON"
118 # Disable tests, since they require downloading googletest, which is
119 # not available in a sandboxed build.
120 "-DANTLR_BUILD_CPP_TESTS=OFF"
124 antlr4_12 = (mkAntlr {
126 sourceSha256 = "sha256-0JMG8UYFT+IAWvARY2KnuXSr5X6LlVZN4LJHy5d4x08=";
127 jarSha256 = "sha256-iPGKK/rA3eEAntpcfc41ilKHf673ho9WIjpbzBUynkM=";
128 extraCppCmakeFlags = [
129 # Generate CMake config files, which are not installed by default.
130 "-DANTLR4_INSTALL=ON"
132 # Disable tests, since they require downloading googletest, which is
133 # not available in a sandboxed build.
134 "-DANTLR_BUILD_CPP_TESTS=OFF"
138 antlr4_11 = (mkAntlr {
140 sourceSha256 = "sha256-SUeDgfqLjYQorC8r/CKlwbYooTThMOILkizwQV8pocc=";
141 jarSha256 = "sha256-YpdeGStK8mIrcrXwExVT7jy86X923CpBYy3MVeJUc+E=";
142 extraCppCmakeFlags = [
143 # Generate CMake config files, which are not installed by default.
144 "-DANTLR4_INSTALL=ON"
146 # Disable tests, since they require downloading googletest, which is
147 # not available in a sandboxed build.
148 "-DANTLR_BUILD_CPP_TESTS=OFF"
152 antlr4_10 = (mkAntlr {
154 sourceSha256 = "sha256-Z1P81L0aPbimitzrHH/9rxsMCA6Qn3i42jFbUmVqu1E=";
155 jarSha256 = "sha256-QZSdQfINMdW4J3GHc13XVRCN9Ss422yGUQjTOCBA+Rg=";
156 extraCppBuildInputs = lib.optional stdenv.isLinux libuuid;
157 extraCppCmakeFlags = [
158 "-DANTLR4_INSTALL=ON"
159 "-DANTLR_BUILD_CPP_TESTS=OFF"
163 antlr4_9 = (mkAntlr {
165 sourceSha256 = "1af3cfqwk7lq1b5qsh1am0922fyhy7wmlpnrqdnvch3zzza9n1qm";
166 jarSha256 = "0dnz2x54kigc58bxnynjhmr5iq49f938vj6p50gdir1xdna41kdg";
167 extraCppBuildInputs = [ utf8cpp ]
168 ++ lib.optional stdenv.isLinux libuuid;
169 extraCppCmakeFlags = [
170 "-DCMAKE_CXX_FLAGS='-I${lib.getDev utf8cpp}/include/utf8cpp'"
177 antlr4_8 = (mkAntlr {
179 sourceSha256 = "1qal3add26qxskm85nk7r758arladn5rcyjinmhlhznmpbbv9j8m";
180 jarSha256 = "0nms976cnqyr1ndng3haxkmknpdq6xli4cpf4x4al0yr21l9v93k";
181 extraCppBuildInputs = lib.optional stdenv.isLinux libuuid;
182 extraCppCmakeFlags = [ "-DANTLR4_INSTALL=ON" ];