Skip to main content



      Home
Home » Modeling » TMF (Xtext) » How to restrict a rule
How to restrict a rule [message #1058265] Mon, 13 May 2013 08:16 Go to next message
Eclipse UserFriend
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 03:19 Go to previous messageGo to next message
Eclipse UserFriend
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 04:43 Go to previous message
Eclipse UserFriend
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: Sat Jul 12 17:17:25 EDT 2025

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

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

Back to the top