[antlr-interest] How to pass a pointer from a rule to another in the Treewalker in C++ ?
Anthony Brenelière
abreneliere at telys.com
Wed Jul 16 10:12:36 PDT 2003
// 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
*' !!!!!!!!!!!
statProperties
[ CObject * _curstat ]
: statStateA[ _curstat ]
| statId[ _curstat ]
;
So, my question is :
Any idea to pass a pointer from a rule to another in the Treewalker in
C++ ?
Cordially,
Anthony
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list