[antlr-interest] Problem with AST type in tree grammar in C target

Jim Idle jimi at temporal-wave.com
Fri Feb 18 15:17:39 PST 2011


I can't see what you are doing wrong without seeing your grammar. Oh, you
removed it altogether and there is an issue somewhere in StringTemplate
where it does not see the default that I set up.

Just copy from this or the examples grammars in the examplse tar:

// Author: Jim Idle, Temporal Wave LLC, Feb 2008.
//
tree grammar tsqlwalker;
//
--------------------------------------------------------------------------
-----------------
//
--------------------------------------------------------------------------
-----------------
// Grammar options
//
options
{
	//
	tokenVocab		= tsql;
	
	//
	ASTLabelType	= pANTLR3_BASE_TREE;
	
	language	= C;
}

Jim


> -----Original Message-----
> From: Kevin J. Cummings [mailto:cummings at kjchome.homeip.net]
> Sent: Friday, February 18, 2011 2:42 PM
> To: Jim Idle
> Subject: Re: [antlr-interest] Problem with AST type in tree grammar in
> C target
>
> On 02/18/2011 04:59 PM, Jim Idle wrote:
> > The type of a node is pANTLR3_BASE_TREE and that is the default, you
> > do not need to specify it as it is ALWAYS that unless you want to do
> > lots and lots of work, which you don't.
>
> If I remove the ASTLabelType option, I get the following errors:
>
> > m2Emit.h:120:8: error: 'start' does not name a type
> > m2Emit.h:121:8: error: 'stop' does not name a type
> > m2Emit.h:127:8: error: 'start' does not name a type
> > m2Emit.h:128:8: error: 'stop' does not name a type
>
> Which makes sense since I see:
>
> > typedef struct m2Emit_exp_return_struct {
> >        start;
> >        stop;
> > }
> >     m2Emit_exp_return;
> >
> > typedef struct m2Emit_ref_return_struct {
> >        start;
> >        stop;
> > }
> >     m2Emit_ref_return;
>
> but is not what I expected from what you just said.  Shouldn't there by
> types for those struct members?  Of course this problem breaks the next
> one....
>
> > m2Emit.c: In function 'void stmt(m2Emit_Ctx_struct*)':
> > m2Emit.c:868:43: error: 'struct m2Emit_ref_return' has no member
> named 'start'
> > m2Emit.c:868:43: error: 'struct m2Emit_ref_return' has no member
> named 'start'
> > m2Emit.c:868:111: error: 'struct m2Emit_exp_return' has no member
> named 'start'
> > m2Emit.c:868:111: error: 'struct m2Emit_exp_return' has no member
> named 'start'
> > m2Emit.c: In function 'm2Emit_exp_return exp(m2Emit_Ctx_struct*)':
> > m2Emit.c:1113:12: error: 'struct m2Emit_exp_return' has no member
> named 'start'
> > m2Emit.c:1113:34: error: 'struct m2Emit_exp_return' has no member
> named 'stop'
> > m2Emit.c:1113:48: error: 'struct m2Emit_exp_return' has no member
> named 'start'
> > m2Emit.c: In function 'm2Emit_ref_return ref(m2Emit_Ctx_struct*)':
> > m2Emit.c:2193:12: error: 'struct m2Emit_ref_return' has no member
> named 'start'
> > m2Emit.c:2193:34: error: 'struct m2Emit_ref_return' has no member
> named 'stop'
> > m2Emit.c:2193:48: error: 'struct m2Emit_ref_return' has no member
> named 'start'
>
> I'm feeling very frustrated at this....
>
> --
> Kevin J. Cummings
> kjchome at verizon.net
> cummings at kjchome.homeip.net
> cummings at kjc386.framingham.ma.us
> Registered Linux User #1232 (http://counter.li.org)


More information about the antlr-interest mailing list