[antlr-interest] Problem with "C" code generation on tree parser

Jim Idle jimi at temporal-wave.com
Sat Dec 15 14:47:29 PST 2007


I was travelling and not able to look at this, but if you care to send
me your grammar I will see what is going on. This sounds like something
I have fixed in the development version.

 

Jim

 

  _____  

From: Harmon Nine [mailto:hnine at isis.vanderbilt.edu] 
Sent: Tuesday, December 11, 2007 2:18 PM
To: antlr-interest Interest
Subject: [antlr-interest] Problem with "C" code generation on tree
parser

 

Hello all.

 

Since C++ code generation is not available for 3.0.1, I’m trying to
interface to the “C”-generated code.

 

The options in the “.g” file are:

options {

  language=C;

  output=AST;

  tokenVocab=MatLab;

  ASTLabelType=CommonTree;

}

 

 

The compiler (visual studio 2005) is currently complaining about 2
things:

 

1)

c:\projects\hcddes\trunk\mfile\mfileparser\matlabudm.c(1130) : error
C2039: 'stop' : is not a member of 'MatLabUdm_input_return_struct'

c:\projects\hcddes\trunk\mfile\mfileparser\matlabudm.h(99) : see
declaration of 'MatLabUdm_input_return_struct'

 

Here is the offending line in “matlabudm.c”:

//------------

pMatLabUdm_BlockPop();

 

retval.stop = LT(-1); /* OFFENDING LINE */

retval.tree = ADAPTOR->rulePostProcessing(ADAPTOR, root_0);

ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start,
retval.stop); /* SEE 2) BELOW */

//------------

 

Here’s the MatLabUdm_input_return_struct definition:

 

//------------

typedef struct MatLabUdm_input_return_struct

{

    pANTLR3_BASE_TREE       start;/* @returnScope.ruleReturnMembers() */

    pANTLR3_BASE_TREE   tree;

    /* End @returnScope.ruleReturnMembers() */   

}

    MatLabUdm_input_return;

//------------

 

QUESTION:  should “stop” be added as a member of this struct, i.e. as
type “pANTLR3_BASE_TREE”?  I’ve tried doing this in “C.stg”, but there
is still a problem (see below).

 

 

2)  The compiler also complains about an incompatible type being passed
to “ADAPTOR->setTokenBoundaries” in the above code:

 

c:\projects\hcddes\trunk\mfile\mfileparser\matlabudm.c(1132) : warning
C4133: 'function' : incompatible types - from 'pANTLR3_BASE_TREE' to
'pANTLR3_COMMON_TOKEN'

 

How can this be remedied?

 

 

Thanks.

-- Harmon


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


More information about the antlr-interest mailing list