[antlr-interest] Bug ? In C++, the parameters passed to a rule become ASTRefCount<AST>

Ric Klaren klaren at cs.utwente.nl
Thu Jul 17 03:06:14 PDT 2003


Hi,

On Thu, Jul 17, 2003 at 11:37:25AM +0200, Anthony Brenelière wrote:
> // Here is the root rule, ciaoTreeDocument :
>
> ciaoTreeDocument
>
>       :     ( statementA )*
>
> ;
>
> // A pointer is created, named '_curstat'.
>
> // This pointer is passed to the rule 'statProperties'
>
> // Everything is OK when the rule is called, and _curstat is OK, with a
> type 'CObject *'
>
> statementA
>       {
>
>             CObject * _curstat = world->addObject();
>             _curstat->aP(CATEGORY, "Statement");
>       }
>
>       :     #(R_STA ( statProperties[ _curstat ])* statement)
>
> ;
>
> // In the statProperties rule, _curstat has changed : the value of the
> pointer has changed, // and the type of _curstat has also changed :
>
> // _curstat IS NOW 'antlr::ASTRefCount<antlr::AST>' instead of 'CObject
> *' !!!!!!!!!!!

This sounds more as a memory corruption bug to me than as a problem with
antlr. Did you inspect the generated code for strange things? Try turning
genHashLines off and stepping through the code step by step to see what
actually changes the pointer.

> Any idea to pass a pointer from a rule to another rule in the Treewalker
> in C++ ?

In principle your approach to passing a pointer is ok, at least I'm not
seeing anything strange about it.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Wit is cultured insolence. --- Aristotle


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list