Where can I get the Antlr Ant task?

I am trying to invoke the Antlr task in my Ant build.xml as follows:

<path id="classpath.build"> <fileset dir="${dir.lib.build}" includes="**/*.jar" /> </path> ... <target name="generate-lexer" depends="init"> <antlr target="${file.antlr.lexer}"> <classpath refid="classpath.build"/> </antlr> </target> 

But Ant cannot find the definition of the problem. In this dir.lib.build :

  • ANTLR-3.1.jar
  • ANTLR-2.7.7.jar
  • ANTLR-environment-3.1.jar
  • StringTemplate-3.2.jar

But none of them have a definition of the problem. (I also tried putting these banks in my path to Ant, the same problem.)

+4
source share
6 answers

The current Antlr-task gang is available at http://www.antlr.org/share/1169924912745/antlr3-task.zip

It can be found on antlr.org in the "File Sharing" section.

+4
source

You should use antlrall.jar jar. You can go and just add it to your Ant installation, but that means that it will only work for this installation. We check the jar in and use taskdef to load the jar file so that it does not become another step for developers when they start as a team or switch to a new computer.

+2
source

I just got this job for myself. Took me for an hour. pah. anyway,

Step 1: download the ant -antlr3 task from

http://www.antlr.org/share/1169924912745/antlr3-task.zip

Step 2: copy to where ant can see it. My mac:

sudo cp / usr / local / lib / ant-antlr3.jar / usr / share / ant / lib /

my linux box:

sudo cp / tmp / ant-antlr3.jar / usr / local / apache-ant-1.8.1 / lib /

Step 3: Verify that antlr2, antlr3, ST are in the classpath. All in one here:

http://antlr.org/download/antlr-3.3-complete.jar

Step 4: use in the build.xml file

 <path id="classpath"> <pathelement location="${antlr3.jar}"/> <pathelement location="${ant-antlr3.jar}"/> </path> <target name="antlr" depends="init"> <antlr:ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" target="src/Tg" outputdirectory="build"> <classpath refid="classpath"/> </antlr:ant-antlr3> </target> 

Just added faq entry:

http://www.antlr.org/wiki/pages/viewpage.action?pageId=24805671

+2
source

The easiest way to run Antlr is to run the Antlr JAR:

 <project default="antlr"> <target name="antlr"> <java jar="antlr-4.1-complete.jar" fork="true"> <arg value="grammar.g4"/> </java> </target> </project> 

This is a bit slower because it deploys the JVM and it launches Antlr even if the grammar has not changed. But it works the same with every version of Antlr and does not need any special purposes.

+1
source

On Ubuntu, this should make it available:

sudo apt-get install ant-optional

0
source

Additional information on what everyone has done so far:

The ant-optional package in Ubuntu includes the task that comes with Ant 1.8.2, which is the task for ANTLR 2.7.2, so this will lead to an error with the error described in this post . The method described by Terence is the best way to use the ANTLR3 task.

If you do not have root access on a Linux machine, you can install the ant -antlr3.jar file in the Ant user directory: ~/.ant/lib . Use ant -diagnostics if ant -antlr3.jar is visible for Ant, as described in this other post .

If you use Eclipse, you will need to restart the IDE before it recognizes the new task, and you will also need to include antlr3.jar and stringtemplate.jar in your class path (but ant-antlr3.jar not required).

0
source

Source: https://habr.com/ru/post/1276425/


All Articles