Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 13:25 Go to next message
Macca1892 is currently offline Macca1892Friend
Messages: 14
Registered: May 2010
Junior Member
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 14:17 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

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


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: XtendParser [message #540653 is a reply to message #540559] Wed, 16 June 2010 20:36 Go to previous messageGo to next message
Macca1892 is currently offline Macca1892Friend
Messages: 14
Registered: May 2010
Junior Member
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 08:06 Go to previous message
Macca1892 is currently offline Macca1892Friend
Messages: 14
Registered: May 2010
Junior Member
sorry, my fault!
This code works well Smile
Previous Topic:[Acceleo] Syntax problems
Next Topic:[Acceleo] No common supertype error
Goto Forum:
  


Current Time: Tue Mar 19 10:23:53 GMT 2024

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

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

Back to the top