Robert Soule wrote: > Hi Jim, > > I'd like to use my own custom AST and write my own tree adapter. > One thing that I haven't been able to figure out is how to substitute > my adapter for the default adapter when the parser code is generated. > > The adapter is declared in the parser header file as: > pANTLR3_BASE_TREE_ADAPTOR adaptor; > > and then used with the macro definition: > #define ADAPTOR ctx->adaptor > > What I was wondering is, is there an option that I can specify to > have antlr generate a parser that refers to my adapter? > > pMY_CUSTOM_TREE_ADAPTOR adaptor; > > and the associated functions like: > ANTLR3_TREE_ADAPTORNew(..) ? > Once you have created the parser, just install a pointer to your own adaptor. You can also do this in @apifuncs I think. As in:
ADAPTOR = pointerToMyAdaptor; You adaptor structure needs to be the same structure that the common adaptor uses and provide the same function set. To be honest with you, even in Java I have found it easier just to call my own functions directly from actions and not try and create an adaptor, thoguh this is essentially because of what type of tree is needed in the case of errors and so on. Jim List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
