[antlr-interest] ANTLR installation/use on Unix

Jim Idle jimi at temporal-wave.com
Sun Nov 30 09:55:47 PST 2008


On Sun, 2008-11-30 at 03:06 -0600, Gary R. Van Sickle wrote:

> > From: Jim Idle
> > 
> > On Fri, 2008-11-28 at 21:28 -0600, Gary R. Van Sickle wrote: 
> > 
> > 	
> > 	Hi Terence et al,
> > 	
> > 	Am I just getting old, or shouldn't I be able to (in a 
> > More Ideal World(tm),
> > 	of course) do something like this on a Unix-like box?:
> > 	
> > 	$ cd antlr-src-distro-dir/
> > 	$ make install
> > 	$ antlr --version
> > 
> > 
> > Well, ANTLR is a Java tool,
> 
> It's a tool.  There's no reason the user should have to care what language
> it's implemented in simply in order to use it.  


I am not talking about using it, I am talking about building it! To run
it as if it were a command, you can set up a bash script.


> Gcc is written in C, but I
> don't care about that when I use it to compile C++, Fortran, or Java code.
> I don't actually know what languages Flex or Bison are written in (though I
> of course have a pretty good idea), but that doesn't in the least prevent me
> from invoking them like this:
> 
> 	$ flex [whatever]
> 	$ bison [whatever]
> 
> Is there a reason why I shouldn't be able to do the equivalent with ANTLR?


Well, only if you can't write a one line bash script. flex and bison are
native programs and as such are easier to just stick in /usr/local/bin
and forget about it.


> 
> > so make install only works for 
> > the C runtime distribution (after a ./configure).
> > 
> 
> Right, but I'm talking about the ANTLR tool itself, not any of its
> language-specific runtimes.


So am I.

> 
> > The ANTLR source can be bult from scratch now using maven though:
> > 
> > 1) In stall Maven 2.0.9 or better;
> > 2) Find the directories with pom.xml in them
> > 3) cd to them and type: mvn
> > 4) Look at the output of the build to see where the .jar 
> > files go if are not familiar with Maven.
> > 
> 
> I'm less concerned with the building of it than the installation and use of
> it.  Can I do this?:
> 
> 	$ cd antlr-src-distro-dir/
> 	$ mvn install
> 	$ antlr [whatever]
> 
> Like I said, it's the 20th century.  


Is it really? I must have missed something. Maven does not require you
to do any of this as it is from the 21st century :-)


> I, as the user, shouldn't have to be
> "looking at the output" of anything, picking out the "artifacts" (as the
> kids call 'em these days), worrying about where they should go, and then
> have to move them manually.  As you indicated above, I don't have to with
> the C runtime, why should I have to for the tool itself?


Well, I took the time to create a configure script and Visual Studio
projects. Still, people have problems with this and I think that as soon
as it goes wrong, your make install would be more confusing than a
simple bash script. If you are using Maven, then there is no need to do
any of this because maven already knows where to get the latest jars
from and how to build .g files using it. This is only useful for java
output though of course.



> 
> > Note that the Maven build, as well as constructing the ANTLR 
> > .jar file also creates a complete executable (I.e Java -jar) 
> > jar file that includes all the dependencies  to make things 
> > easier for developers.
> > 
> 
> Ok, so can't it go the last mile and also create a simple shell script
> wrapper so I can:
> 
> 	$ antlr MyGrammar.g
> 
> ?  In fact, rumor has it that the Maven tool of which you speak uses exactly
> that approach itself.
> 
> To answer my own question, I broke out my autotools- and script-fu last
> night and rolled an automake+autoconf+built-shell-script which does in fact
> allow me to:
> 
> 	$ ./configure
> 	$ make
> 	$ make install
> 	$ antlr
> 	ANTLR Parser Generator  Version 3.1.1
> 	[etc etc]
> 
> The JARs aren't actually built, but rather the pre-built one in the source
> distro's /lib directory is installed, and the "antlr" shell script is
> generated from a template (a default Java interpreter and the path to the
> JAR are substituted).  "make install" puts everything in reasonable places
> and, Bob's your uncle, everything works just as it should.
> 
> Terence (or anybody), any interest in this?  I could certainly BSD-license
> it and contribute it.

You know - I was just trying to point you in the right direction - there
is no need to get all huffy, rant at me about being in the wrong century
and complain that ANTLR isn't an instant install on your particular
system and so on. All you need is the composite jar and:

#! /bin/bash
java -jar whereverthejaris.jar $*

With make install, you have to detect the java install, find the
dependencies, it only works on *nix etc. Generic installers are a lot
more work and maintaining a configure script for this does not seem
worth it to me - it is Ter's call in the end though.

Jim


> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081130/34bc98ca/attachment.html 


More information about the antlr-interest mailing list