How do I pass extra parameters to AST constructors?

Monty Zukowski

You can't. ASTs define initialize() methods that take either an AST node or a Token object. The appropriate place is to make your own subclass of either Token or AST which can hold the data your want.

If you want to keep track of the file name that created this subtree (for handling C's #includes, for instance), the appropriate place is to attach that to the Token as the lexer creates it. Then create your own AST which can store that info and which sets it from the initialize(Token) method.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact