[antlr-interest] Newbie C-code generation

Jim Idle jimi at temporal-wave.com
Tue Jun 17 12:28:19 PDT 2008


On Tue, 2008-06-17 at 11:05 +0200, mimarob at algonet.se wrote:

> Hello!
> 
> I just installed 3.0.1 antlr and also a daily build from 2008-05-25
> 
> I then took some example code (cgram.tgz sorry dont know which 
> version) 
> 
> The cgram examples work great (ok I had to remove some silly  import 
> CToken; stuff but that 
> was all)
> 
> Then I wanted to generate C-code instead of java so I added language 
> to the options section in
> the GnuCParser.g file :
> 
> options {
> 
>    language=C;
> 
>         k = 2;
>         exportVocab = GNUC;
>         buildAST = true;
> 
> ...
> }
> 
> 
> 
> $ make
> java antlr.Tool StdCParser.g
> ANTLR Parser Generator   Version 2.7.7 (20060906)   1989-2005
> 
> .... lots of antlr output...
> 
> StdCParser.g:1354:     k==3:<end-of-token>,'\u0000'..'\u00ff'
> StdCParser.g:1354:     between alt 4 and exit branch of block
> java antlr.Tool -glib "StdCParser.g" GnuCParser.g
> ANTLR Parser Generator   Version 2.7.7 (20060906)   1989-2005
> .\expandedGnuCParser.g:15:0: Invalid option: language
> Exiting due to errors.
> make: *** [GnuCParser.java] Error 1
> 
> 
> Do I need to add the C generation module someway?
> 
> Do I need to recompile antlr myself for this to work?



You are suing ANTLR 2.7.7 not ANTLR 3, so you cannot generate C code.
Remove the pre-installed antlr 2 package from your system and download
the ANTLR 3 atr from the dowloads section of the web site.

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080617/a3775d92/attachment.html 


More information about the antlr-interest mailing list