[antlr-interest] Antlr C target and Objective-c

Jim Idle jimi at temporal-wave.com
Tue Aug 12 15:58:43 PDT 2008


On Tue, 2008-08-12 at 18:44 -0400, Jesse Grosjean wrote:

> Jim,
> 
> Not sure if I should ask report these to you directly, or post to  
> antlr-interest. Please let me know.


Copied to list as this concerns everyone using the C target.

> 
> I just downloaded 3.1 and generated my AST grammar for the C target.  
> It appears that there is a problem with the generation template. For  
> example here's what I got in my parser.h file:
> 
> typedef struct TPQParser_statements_return_struct
> {
>      /** Generic return elements for ANTLR3 rules that are not in tree  
> parsers or returning trees
>       */
>      pANTLR3_COMMON_TOKEN    start;
>      pANTLR3_COMMON_TOKEN    stop;
>            tree;
> }


You need to set the option:

option
{
    ASTLabelType = pANTLR3_BASE_TREE;
}

in your grammar files. It should default in string template but does not
seem to in some places.

> 
> Not the "tree'" doesn't have an associated type, and so the generated  
> file won't compile. Replacing that line with:
> 
>      pANTLR3_BASE_TREE	    tree;
> 
> Seems to fix the problem.
> 
> Second issue, probably just OS X related, but when I run autoconf to  
> build the runtime I get this error on a vanilla OS X Leopard:
> 
> $ autoconf
> configure.ac:49: error: possibly undefined macro: AM_INIT_AUTOMAKE
>        If this token and others are legitimate, please use
> m4_pattern_allow.
>        See the Autoconf documentation.
> configure.ac:52: error: possibly undefined macro: AM_MAINTAINER_MODE
> configure.ac:53: error: possibly undefined macro: AM_PROG_LIBTOOL


These are known issues with autoconf, but you don't need to run
autoconf, that is just for me to run to produce teh configure and
makefile stubs. You need to unpack the tar.gz in the dist subdiretory
(or now, the official C runtime download) and just run:

./configure. 

Besides, when using a different version of autoconf you first have to
use autoreconf -i --force   

> 
> For now I'm just including the sources in my Xcode project and  
> compiling that way. But it would probably be good to have it build out  
> of the box on OS X from the command line... unfortunately I don't  
> really know what needs to be changed to make it work. But at least you  
> know it's a problem :)


I know it's your problem ;-P. Please read the API docs where it tells
you how to build the runtime libraries. The link "BUilding from source
will show you how".

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


More information about the antlr-interest mailing list