Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Forward propogate rules to deturmine correct rule
Forward propogate rules to deturmine correct rule [message #674950] Sun, 29 May 2011 17:38 Go to next message
Richard Cookman is currently offline Richard CookmanFriend
Messages: 7
Registered: May 2011
Junior Member
I have two rules in xtext both of an indetermined number of tokens. These rules are very similar and only differentiate themselved from each other by the character at the end of the rule. They appear in the same place in the program.

So in other words I want to do something similar to this

if it is rule 1
then process it as rule 1
else
it isn't rule 1 so process it as rule two

If there is nice way of doing this then that would be great

Sorry if this has been asked before.

[Updated on: Sun, 29 May 2011 17:38]

Report message to a moderator

Re: Forward propogate rules to deturmine correct rule [message #674961 is a reply to message #674950] Sun, 29 May 2011 19:14 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

first of all rules like this make work for the parser very hard (and inefficient) and the language design should be that these problems do not occur at all (a "keyword" determining which grammar rule to use should be placed at the beginning, not at the end).

Model: rules+=Rule;
Rule: RuleWithCommaAtEnd|RuleWithDotAtEnd;
RuleWithCommaAtEnd: entry+=ID* ',';
RuleWithDotAtEnd: entry+=ID* '.';

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Forward propogate rules to deturmine correct rule [message #675236 is a reply to message #674961] Mon, 30 May 2011 20:54 Go to previous message
Richard Cookman is currently offline Richard CookmanFriend
Messages: 7
Registered: May 2011
Junior Member

I had a feeling that might be the answer, sadly in this case it cannot be avoided.

I'm not sure but it might be the complexity of my situation but I get errors when the two rules are OR-ed together.

I don't know if it is because my rules uses recursion heavily, would that make a difference? Either way I don't see a way around this.

I have now changed my compiler implementation (not a big problem in these circumstances).
Previous Topic:set up workspace for developing Xtext
Next Topic:Adding comments to the Node Model
Goto Forum:
  


Current Time: Thu Apr 25 18:50:49 GMT 2024

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

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

Back to the top