Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » XtendParser([Xtend] how to get an AST by parsing an .ext file)
XtendParser [message #540542] Wed, 16 June 2010 09:25 Go to next message
Eclipse UserFriend
There could be a larger oAW community here

Anyone knows how we can get an AST by parsing an .ext file by using XtendFacade? I can only see that we could get an ExtensionFile object. I have tried to parse an .ext file to get an ExtensionFile object but not successful yet

ExtensionFile f = ParseFacade.file(new StringReader(expression), fileName);

expression is a string but I don't understand what should I assign for it

Please help!
Re: XtendParser [message #540559 is a reply to message #540542] Wed, 16 June 2010 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Use the XtendFacade, passing the path to the .ext file relative to the classpath.

If you have the ExtensionFile instance that's actually the AST.

You should consider looking into the Xtend test plugin for some sources.
CVS coordinates:
- dev.eclipse.org
- /cvsroot/modeling
- org.eclipse.m2t/org.eclipse.xpand/plugins/org.eclipse.xtend. tests

~Karsten
Re: XtendParser [message #540653 is a reply to message #540559] Wed, 16 June 2010 16:36 Go to previous messageGo to next message
Eclipse UserFriend
Thank you so much!

I have looked into org.eclipse.m2t/org.eclipse.xpand/plugins/org.eclipse.xtend. tests and there are many examples there

I tried one of them but now I have another problem with java.lang.NullPointerException at this point:
ec = (ExecutionContextImpl) ec.cloneWithResource(file);

I am quite sure that parse function works well because I can read some information from the instance of ExtensionFile. Thus I don't understand why NullPointerException is there Confused

Here is the test code:
ec = new ExecutionContextImpl();
ec.registerMetaModel(new JavaMetaModel("JavaMetaModel", new JavaBeansStrategy()));

final ExtensionFile file = parse(
"foo(String str) : 'String';" +
"foo(Integer int) : 'Int';" +
"foo(Void void) : 'void';");
ec = (ExecutionContextImpl) ec.cloneWithResource(file);
XtendFacade facade = XtendFacade.create(ec);
assertEquals("String",facade.call("foo", "String"));
assertEquals("Int",facade.call("foo", new Long(42)));
assertEquals("void",facade.call("foo", (Object) null));
Re: XtendParser [message #540727 is a reply to message #540542] Thu, 17 June 2010 04:06 Go to previous message
Eclipse UserFriend
sorry, my fault!
This code works well Smile
Previous Topic:[Acceleo] Syntax problems
Next Topic:[Acceleo] No common supertype error
Goto Forum:
  


Current Time: Thu Jul 24 11:57:39 EDT 2025

Powered by FUDForum. Page generated in 0.04630 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top