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

Harmon Nine hnine at isis.vanderbilt.edu
Tue Dec 11 14:17:37 PST 2007


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/20071211/f41cd248/attachment.html 


More information about the antlr-interest mailing list