[antlr-interest] Own AST : initializing extra private members
Kristoff Tempelaere
kristoff_tempelaere at yahoo.com.au
Thu Aug 19 13:40:48 PDT 2004
Hello,
I'm using my own AST which has following definition (only the relevant parts) :
class MyAST : public CommonAST {
private:
int _x;
public:
void setx(int x) {_x=x;}
in getx() const {return _x;}
//and others...
};
I want to set the x-value during parsing. I do this in the grammar (of the parser) by labeling the tokenreference and adding a semantic action {label->setx(7);} for example. But this adds a lot of semantic actions to my grammar, just for setting this x-value.
Can this be done in a better way? Instead of using myfactory.create(token), i would like the parser calls MyFactory.create(token,xvalue), passing the xvalue in the grammar. That is what I want, to avoid all those semantic actions... passing in the grammar values to initialize AST-members in a more elegant way. Is this possible? And how?
Thx in advance!
Kristoff
---------------------------------
Find local movie times and trailers on Yahoo! Movies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20040820/e293f839/attachment.html
More information about the antlr-interest
mailing list