Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using Xtext to populate memody model
Using Xtext to populate memody model [message #997820] Tue, 08 January 2013 20:14 Go to next message
Patrick Shea is currently offline Patrick Shea
Messages: 2
Registered: January 2013
Junior Member
Hi, I'm new to Xtext but not to antlr, I used antlr in the past to parse dsl and create a java model in memory.

I like what Xtext is doing and saw the code generator example but I don't see how I could generate objects at parse time.

I must be missing some step to accomplish this...
Re: Using Xtext to populate memody model [message #997931 is a reply to message #997820] Wed, 09 January 2013 02:22 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2500
Registered: July 2009
Senior Member
On 2013-08-01 22:11, Patrick Shea wrote:
> Hi, I'm new to Xtext but not to antlr, I used antlr in the past to parse
> dsl and create a java model in memory.
>
> I like what Xtext is doing and saw the code generator example but I
> don't see how I could generate objects at parse time.
>
> I must be missing some step to accomplish this...

There is no step... simple load the file into an EMF resource set and
the parser will be triggered, parse, link, etc. and give you the model
contents.

Also, other models can simply refer to model elements in the created
model without knowing that it is in fact a text based DSL.

How you do this differs slightly depending on if you are running inside
the IDE (while editing etc.) or if you want some stand alone tool that
performs the reading.

If you want to read the model for purpose of "building", the best way is
to hook into the Xtext builder framework - thus getting a callback when
things change, simply read the model and do whatever you want.

Need to know a bit more about what you want to do in order to be more
specific.

Hope this helps along the way.
Regards
- henrik
Re: Using Xtext to populate memody model [message #998142 is a reply to message #997820] Wed, 09 January 2013 12:38 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1371
Registered: July 2009
Senior Member
On 01/08/2013 10:11 PM, Patrick Shea wrote:
> Hi, I'm new to Xtext but not to antlr, I used antlr in the past to parse
> dsl and create a java model in memory.
>
> I like what Xtext is doing and saw the code generator example but I
> don't see how I could generate objects at parse time.
>
> I must be missing some step to accomplish this...

Are you asking how to generate the java model in memory at parse time
(as you do in antlr)? If this is what you ask, then you don't have to
worry about that: Xtext will generate the AST model for you while parsing :)

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Re: Using Xtext to populate memody model [message #998158 is a reply to message #997931] Wed, 09 January 2013 13:10 Go to previous messageGo to next message
Patrick Shea is currently offline Patrick Shea
Messages: 2
Registered: January 2013
Junior Member
Thanks, I already have the model build (java classes), all I want is to populate it based on the parsed text.

What is the xtext build framework? Do you mean the generator?
Re: Using Xtext to populate memody model [message #998197 is a reply to message #998158] Wed, 09 January 2013 14:44 Go to previous message
Henrik Lindberg is currently offline Henrik Lindberg
Messages: 2500
Registered: July 2009
Senior Member
On 2013-09-01 14:10, Patrick Shea wrote:
> Thanks, I already have the model build (java classes), all I want is to
> populate it based on the parsed text.
>
That happens when loading it as an EMF resource.

> What is the xtext build framework? Do you mean the generator?
No. Builders that run in the IDE. It is described in the documentation.

- henrik
Previous Topic:Help with scoping please.
Next Topic: Using Xtext code in an Eclipse Plugin
Goto Forum:
  


Current Time: Fri Oct 31 05:46:16 GMT 2014

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

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