Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dynamic loading of files conforming to arbitrary DSLs
Dynamic loading of files conforming to arbitrary DSLs [message #511484] Mon, 01 February 2010 17:14 Go to next message
Christoph Elsner is currently offline Christoph ElsnerFriend
Messages: 5
Registered: February 2010
Junior Member
Hello,

I am currently working on a simplifying frontend for XText (as an eclipse plugin).

The user should only need to provide an XText grammar and an "instance" of it (a file conforming to that grammar) and should receive the corresponding emf metamodel and model.

I was wondering if there is a chance to get the emf model of the "instance" (the file conforming to the grammar) without generating all the Java classes from the grammar explicitly. So, the resource loading and emf conversion for the "instance" should work dynamically (similar to how "dynamic EMF" works).

Is this possible? Or will I have to run the XText MWE Workflow generating all the Java classes for this and than integrate them via reflection?

Thank you a lot in advance!

Christoph
Re: Dynamic loading of files conforming to arbitrary DSLs [message #511676 is a reply to message #511484] Tue, 02 February 2010 09:12 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Xtext can work with dynamic emf models.
However, there are some generated convenience classes (e.g.
ProposalProvider) which refer to the generated Java clases.
But those components are not mandatory.

Sven

Christoph Elsner schrieb:
> Hello,
>
> I am currently working on a simplifying frontend for XText (as an
> eclipse plugin).
>
> The user should only need to provide an XText grammar and an "instance"
> of it (a file conforming to that grammar) and should receive the
> corresponding emf metamodel and model.
>
> I was wondering if there is a chance to get the emf model of the
> "instance" (the file conforming to the grammar) without generating all
> the Java classes from the grammar explicitly. So, the resource loading
> and emf conversion for the "instance" should work dynamically (similar
> to how "dynamic EMF" works).
>
> Is this possible? Or will I have to run the XText MWE Workflow
> generating all the Java classes for this and than integrate them via
> reflection?
>
> Thank you a lot in advance!
>
> Christoph


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Dynamic loading of files conforming to arbitrary DSLs [message #512022 is a reply to message #511676] Wed, 03 February 2010 16:45 Go to previous messageGo to next message
Christoph Elsner is currently offline Christoph ElsnerFriend
Messages: 5
Registered: February 2010
Junior Member
Hi Sven,

thanks for your reply. It's good to know that I do not have to generate an API for the metamodel.

My question was meant in an even more general (and maybe more naive) sense:
Is it possible to parse a file conforming to a XText DSL without generating any file at all (no grammar, no <Lang>RuntimeModule.java, no <Lang>StandaloneSetup.java, no Internal<Lang>Parser.java ...)

This would be a kind of "dynamic" parser then, which *interprets* the XText grammar instead of generating java/ANTLR code for parsing.

However, as I've seen now both ANTLR and the new XText alternative are "parser generators", not "grammar interpreters". So, finally, it seems I won't get around running a parser generator and jump into the generated code via reflection. Do you think so as well?

Cheers,

Christoph


Sven Efftinge wrote on Tue, 02 February 2010 04:12
Xtext can work with dynamic emf models.
However, there are some generated convenience classes (e.g.
ProposalProvider) which refer to the generated Java clases.
But those components are not mandatory.

Sven


Re: Dynamic loading of files conforming to arbitrary DSLs [message #512163 is a reply to message #512022] Thu, 04 February 2010 04:32 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Christoph Elsner schrieb:
> Hi Sven,
>
> thanks for your reply. It's good to know that I do not have to generate
> an API for the metamodel.
>
> My question was meant in an even more general (and maybe more naive) sense:
> Is it possible to parse a file conforming to a XText DSL without
> generating any file at all (no grammar, no <Lang>RuntimeModule.java, no
> <Lang>StandaloneSetup.java, no Internal<Lang>Parser.java ...)
>
> This would be a kind of "dynamic" parser then, which *interprets* the
> XText grammar instead of generating java/ANTLR code for parsing.
>
> However, as I've seen now both ANTLR and the new XText alternative are
> "parser generators", not "grammar interpreters". So, finally, it seems I
> won't get around running a parser generator and jump into the generated
> code via reflection. Do you think so as well?

Yes, those components are generated.
You could generate and compile at runtime and load the generated code
via URLClassLoader. But I don't know how well that would perform.

Sven


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:Grammar: String concatenate
Next Topic:[Xtext] Can Xtext directly reference Xtend's JavaBeansMetamodel like Xtend and Xpand do ?
Goto Forum:
  


Current Time: Tue Apr 23 16:15:47 GMT 2024

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

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

Back to the top