[antlr-interest] how to configure the antlr jar in unix for C/c++

Parsiad Azimzadeh parsiad.azimzadeh at gmail.com
Mon Jul 18 01:57:24 PDT 2011


To have ANTLR output C code, you need only change the `options = Java`
to `options = C`. Once you've got your outputted C code, you'll need
to compile it with the appropriate ANTLR header files and link it with
the appropriate ANTLR runtime library.

So, grab the source code:
http://www.antlr.org/wiki/display/ANTLR3/Using+the+ANTLR3+C+Target#UsingtheANTLR3CTarget-FindingtheSourceCode

And build it:
http://www.antlr.org/wiki/display/ANTLR3/Using+the+ANTLR3+C+Target#UsingtheANTLR3CTarget-BuildinginUNIXStyleEnvironments

And use your compiler of choice to compile the ANTLR code. The guide
above has instructions to install the library and headers in a
location where your compiler might be aware of them (I usually abstain
from this as I only allow my package manager to be in charge of
anything outside of my home on *nix). If you do not install the
headers and library in a place where your compiler is aware of them,
do not forget to use whatever flags your compiler makes available to
supply it with the location of the header files and libraries.

I personally use Arch Linux, and a package for the ANTLR C runtime is
available (see https://aur.archlinux.org/packages.php?ID=42227). Check
to see if your distribution of whatever *nix you're on has packages
available for you.

--
Parsiad Azimzadeh
http://sfu.ca/~paa4


More information about the antlr-interest mailing list