Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Is it possible to start a parse from a sub-rule?
Is it possible to start a parse from a sub-rule? [message #778190] Wed, 11 January 2012 15:14 Go to next message
Thomas Williams is currently offline Thomas WilliamsFriend
Messages: 15
Registered: January 2012
Junior Member
Hello Xtexters,

I come from an antlr background where it was possible to start a parse from a sub-rule when under certain circumstances we just needed to parse a fragment from a much larger language, e.g. validating a single expression that the user has entered via a dialog before inserting it into a larger (language described) mathematical model.

Is this possible with Xtext? It seems that the parse always needs to start from the first rule?

I suppose it would be possible to augment the first rule to accept the language fragments we needed to be able to parse separately and then as a post-processing step analyse the semantic model to check that what has been parsed was appropriate to the context (i.e. whether we thought we were parsing a fragment or parsing a complete language text) ?

Regards,

Tom

[Updated on: Wed, 11 January 2012 15:15]

Report message to a moderator

Re: Is it possible to start a parse from a sub-rule? [message #778212 is a reply to message #778190] Wed, 11 January 2012 17:46 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Maybe you can divide your grammar into 2, the second one starting with the fragment you want so that when you want to parse juste a piece you'll use the second one only.
Re: Is it possible to start a parse from a sub-rule? [message #778419 is a reply to message #778190] Wed, 11 January 2012 16:27 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi Tom,

Xtext uses a partial parsing strategy transparently.
Please have a look at the IParser interface for more information (but
note it's actually not meant to be used directly by clients).

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 11.01.12 16:15, schrieb Thomas Williams:
> Hello Xtexters,
>
> I come from an antlr background where it was possible to start a parse from
> a sub-rule when under certain circumstances we just needed to parse a
> fragment
> from a much larger language, e.g. validating a single expression that
> the user
> has entered via a dialog before inserting it into a larger (language
> described)
> mathematical model.
>
> Is this possible with Xtext? It seems that the parse always needs to start
> from the first rule?
>
> I suppose it would be possible to augment the first rule to accept the
> language fragments we needed to be able to parse separately and then as
> a post-processing step analyse the semantic model to check that what has
> been parsed was appropriate to the context (i.e. whether we thought we
> were parsing a fragment or parsing a complete language text) ?
> Regards,
>
> Tom
Re: Is it possible to start a parse from a sub-rule? [message #1220122 is a reply to message #778212] Mon, 09 December 2013 20:54 Go to previous message
Vlad Gheorghe is currently offline Vlad GheorgheFriend
Messages: 127
Registered: May 2011
Senior Member
Hi everyone,

Is there a way to choose different start parsing rules for the EmbeddedEditor ?
In that use case it makes even more sense, as it might be that different EmbeddedEditors on the same form parse different parts of the language.

Regards
Vlad



Previous Topic:xtext rename participant
Next Topic:DSL debugger
Goto Forum:
  


Current Time: Sun Jul 12 14:19:09 GMT 2020

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

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

Back to the top