Skip to main content



      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 10:14 Go to next message
Eclipse UserFriend
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 10:15] by 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 12:46 Go to previous messageGo to next message
Eclipse UserFriend
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 11:27 Go to previous messageGo to next message
Eclipse UserFriend
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 15:54 Go to previous message
Eclipse UserFriend
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 27 16:19:20 EDT 2025

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

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

Back to the top