Skip to main content


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 09:42 Go to next message
Martin Buchheim is currently offline Martin BuchheimFriend
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 11:30 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:importURI 101
Next Topic:NPE opening external files
Goto Forum:
  


Current Time: Sat Apr 20 03:00:11 GMT 2024

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

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

Back to the top