Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Server-side parsing concepts
Server-side parsing concepts [message #896399] Wed, 18 July 2012 05:42 Go to next message
Martin Buchheim is currently offline Martin Buchheim
Messages: 3
Registered: July 2012
Junior Member
Hello,

currently, I'm working on a project involving Xtext (2.3.0) in several contexts:

1- First, user's should be able to create files using my Xtext grammar in an embedded Xtext-editor, with syntax highlighting etc. => done using the new "EmbeddedEditorFactory"-approach, thank you for adding this Smile

2- The files will be transfered to and persisted on a server. This will simply store the editor-contents as a string in a database => done

3- On request, the contents should be taken from the database and be "evaluated" on the server-side

This third part currently gives me a few headaches. What I basically try to achieve is to retrieve the editor-content-string from the database, parse it through Xtext and retrieve the fitting EMF-model structure as it was generated by the grammar.

I've read in the documentation that Xtext should be running in a non-equinox context (which I have on the server) using the "StandaloneSetup" and injector, which is fine (and I'm already using this for the embedded editor).

However, I couldn't find any information on how to go on. Is it shomehow possible to get the IParser injected, pass the string through a StringReader and get the resulting structure in a IParseResult? That's exactly what I'd require, but I don't know how I could actually retrieve the initial parser.

Any hints if/how that coule be done would be greatly appreciated.

Thank you,
Martin
Re: Server-side parsing concepts [message #896423 is a reply to message #896399] Wed, 18 July 2012 07:30 Go to previous message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 656
Registered: July 2009
Senior Member
Use the EMF Resource API to load and parse models:
1) call <yourlanguge>StandaloneSetup.doSetup() to create the injector
and register the language to the EMF registries
2) create an XtextResourceSet
3) load the file as a resource into the resource set
4) access the resource's contents. This will be the AST


Am 18.07.12 11:42, schrieb Martin Buchheim:
> Hello,
>
> currently, I'm working on a project involving Xtext (2.3.0) in several
> contexts:
> 1- First, user's should be able to create files using my Xtext grammar
> in an embedded Xtext-editor, with syntax highlighting etc. => done using
> the new "EmbeddedEditorFactory"-approach, thank you for adding this :)
>
> 2- The files will be transfered to and persisted on a server. This will
> simply store the editor-contents as a string in a database => done
>
> 3- On request, the contents should be taken from the database and be
> "evaluated" on the server-side
>
> This third part currently gives me a few headaches. What I basically try
> to achieve is to retrieve the editor-content-string from the database,
> parse it through Xtext and retrieve the fitting EMF-model structure as
> it was generated by the grammar.
>
> I've read in the documentation that Xtext should be running in a
> non-equinox context (which I have on the server) using the
> "StandaloneSetup" and injector, which is fine (and I'm already using
> this for the embedded editor).
>
> However, I couldn't find any information on how to go on. Is it shomehow
> possible to get the IParser injected, pass the string through a
> StringReader and get the resulting structure in a IParseResult? That's
> exactly what I'd require, but I don't know how I could actually retrieve
> the initial parser.
>
> Any hints if/how that coule be done would be greatly appreciated.
>
> Thank you,
> Martin


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:importURI 101
Next Topic:NPE opening external files
Goto Forum:
  


Current Time: Sat Aug 30 22:43:24 EDT 2014

Powered by FUDForum. Page generated in 0.01584 seconds