[antlr-interest] ANTLR installation/use on Unix

Gary R. Van Sickle g.r.vansickle at att.net
Sun Nov 30 15:50:42 PST 2008


> From:  Jim Idle
> 
> 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!

Well, I guess that's our first disconnect. ;-)  I just want to use the dern
thing!

> To run it as if it were a command, you can set up a bash script.
> 

Yeah, I can, and I have (and also you forgot "manually put the JARs
somewhere").  That doesn't mean I should have had to.  I didn't have to do
anything of the sort with flex, bison, or any of a hundred other tools I use
every day.  Why am I, Mr. ANTLR User, expected to treat this one
differently?

> 	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.

Unfortunately it takes more than one line to do it semi-right.  But you're
missing my point: Why did I have to write a shell script at all?

> flex 
> and bison are native programs and as such are easier to just 
> stick in /usr/local/bin and forget about it.
> 

Your argument starts to fray when one realizes that:

1. Shell scripts aren't native programs either.
2. I've never manually moved a flex or bison binary anywhere.  I bet you
haven't either.

Just because ANTLR is written in Java, it somehow gets special dispensation
to not behave like all other tools (including others that are also written
in Java)?  Sorry, that dog won't hunt.

Seriously, the last time I had to write a wrapper script for a
"compiler-like" tool simply in order to run it was... well, technically
never.  I say, let's use my now-broken
never-had-to-write-a-wrapper-just-to-run-a-tool streak as an opportunity to
save the next guy the same hassle - turn lemons into lemonade, if you will!

> 	
> 	> 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?

At the utter most.  If you're one of those who would believe what the
calendars tell you, consider: Would any citizen of the 21st century be
reduced to moving files around and writing shell scripts simply to invoke
his tools?  Why, it strains all credulity my good sir!

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

This "Maven" of which you speak sounds like quite the tool.  I'll have to
investigate how effortlessly it is able to build and install projects
consisting of source written in an arbitrary mix of non-Java languages such
as C, C++, lex, yacc, ANTLR, some custom built sources, etc etc, with
various interdependencies between the various source files.  Since it will
most certainly be at least the 21st century before I am able to get to that,
may I humbly suggest that in the interim we work together and arrange it so
that ANTLR does not dictate the build system used to invoke it?

> 	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.

Hear hear, many hands make light work!

> 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.

My "make install" installs a simple shell script.  (Not "bash script" BTW,
remember this is Unix: there's a non-zero possibility that there's one guy
out there somewhere running the original "sh", and hence we cannot use any
shell constructs introduced since 1971.)

> If you are using 
> Maven,

I'm not.  Millions of people are not.  Why should that fact deprive them of
ANTLRy goodnesss?

> 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.
> 

Of course.  Considering ANTLR can target about a half-dozen non-Java
languages, doesn't that seem like a less-than-ideal solution?

> 	> 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,

Whoah whoah whoah, nobody here's getting "all huffy".  I'm here to help, as
clearly indicated in the sentence above.

> rant at me 
> about being in the wrong century

Well, unless you have a nuclear-turbine-powered flying car you'd like to
sell me, I'm afraid that shoe fits all of us. ;-)

> and complain that ANTLR 
> isn't an instant install on your particular system and so on. 

On who's particular system is ANTLR's install on par with, say, bison's?  As
far as I can discern, nobody's, unless possibly they are using this thing
you call "Maven".

> All you need is the composite jar and:
> 
> #! /bin/bash
> java -jar whereverthejaris.jar $*
> 

Well, that's a start... now where did I put that JAR?  ;-)

> With make install, you have to detect the java install,

Wrong.  *I* don't.  The dudes providing the ANTLR tool do.  I'm guessing
they'll do that at "make install"-time, but whatever, none of my business,
all that *I*, Mr. ANTLR User, need to know is:

	$ antlr MyGrammar.g

...and it's all good.  Give to Caesar what is Caesars, sez I.

> find 
> the dependencies,

I thought they were all in the JAR?

> it only works on *nix etc.

Hey hey hey, one front at a time!  *nix alone opens up a pretty big chunk of
real estate, wouldn't you say?  Including OSX and Windows (in Cygwin form).

> Generic 
> installers are a lot more work and maintaining a configure 
> script for this does not seem worth it to me

Right, that's why I left that part up to the autotools.

> - it is Ter's 
> call in the end though.
> 
> Jim

Terence, what say you?  Should I send you what I have?  It's pretty sweet
;-).

-- 
Gary R. Van Sickle
 



More information about the antlr-interest mailing list