[antlr-interest] gunit with custom AST nodes throws InvocationTargetException

Leon Su leon.antlr at mac.com
Fri Mar 28 12:00:50 PDT 2008


Hi Felix,

Thanks for addressing this issue. The current version of junit  
translator doesn't support custom adaptor.
For adding a custom adaptor to it, you could manually add the 2  
statements to the method "execParser" right
after creating a parser:
	XXXParser parser = new XXXParser(tokens)    // gunit gererates this  
for you
	XXXAdaptor adaptor = new XXXAdaptor();
	parser.setTreeAdaptor(adaptor);    // use custom adaptor

I'm going to release a newer version of gunit with some bugs fixed  
nowadays, and I may fix this either in this
release or the next. I am also thinking to add an option in gunit for  
using a custom adaptor.

Leon

On Mar 28, 2008, at 6:03 AM, Felix Dorner wrote:

> Ok,
>
> lot of things to learn. The gUnit creates a Parser instance and  
> obviously does not set its TreeAdaptor to my ASTAdaptor, therefore  
> the Parser creates CommonTree nodes. Then, some questions arise:
>
> As I learned from the Book, I set the parser's TreeAdaptor from  
> _outside_ the parser. I don't see a simple way to implicitly set  
> the Adaptor from _within_ the parser, when using the default  
> constructor (which gUnit does). Is there a reason why there's  
> nothing like, e.g. a parser option "Adapter" or so?
>
> So either gUnit would provide an option to set the desired Adaptor,  
> or I find a way to implicitly set the Adaptor from within the grammar.
>
> Thanks for your comments,
> Felix
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080328/cef50f74/attachment.html 


More information about the antlr-interest mailing list