Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to restrict a rule
How to restrict a rule [message #1058265] Mon, 13 May 2013 12:16 Go to next message
rohit ahuja is currently offline rohit ahujaFriend
Messages: 27
Registered: February 2013
Junior Member
I have something like,

Model
exp1= EXPRESSION '+' exp2=EXPRESSION

where EXPRESSION handles all kind of possible cases that i require.

Now the problem is that '+' is also part of an expression, and exp1 basically spans across the '+' symbol and consumes the exp2 as well.

is it possible to do this in some other way?

Thanks,
Rohit
Re: How to restrict a rule [message #1058447 is a reply to message #1058265] Tue, 14 May 2013 07:19 Go to previous messageGo to next message
Colonel Panic is currently offline Colonel PanicFriend
Messages: 7
Registered: May 2013
Junior Member
Before you can answer this question you need to decide for yourself how the compiler should decide which expression belongs in which side of the AST. For example, should it parse:

a + b + c


as
exp1='a' '+' exp2='b + c'

or
exp1='a + b' '+' exp2='c'


Until you can decide this for yourself, there isn't a general case answer to your problem.

It may be the case that you are trying to put too much validation into the parser. Consider parsing 'EXPRESSION + EXPRESSION' in a single rule, rather than two, then deciding in your model validation and/or inference which version of the rule is intended (according to rules of your own choosing).

Hope that helps!
Re: How to restrict a rule [message #1058461 is a reply to message #1058447] Tue, 14 May 2013 08:43 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6552
Registered: July 2009
Senior Member
This might help as well
http://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html
Previous Topic:Developing custom xtext editor
Next Topic:Generate mydsl Plug-in with Updatesite
Goto Forum:
  


Current Time: Mon Dec 22 15:02:11 GMT 2014

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

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