Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Unassigned rule call...
icon5.gif  Unassigned rule call... [message #638192] Wed, 10 November 2010 12:04 Go to next message
Kai Maschke is currently offline Kai MaschkeFriend
Messages: 16
Registered: October 2010
Junior Member
Hi,

I just started to use xtext. I got stuck with an error that says:
Quote:
Multiple markers at this line
- An unassigned rule call is not allowed, when the 'current'
was already created.
- Cannot change type twice within a rule


The affected code is:
CondExpr:
	OrcondExpr | 'AND' CondExpr OrcondExpr;

OrcondExpr:
	NotcondExpr | 'OR' OrcondExpr NotcondExpr;
	
NotcondExpr:
	Condition | 'NOT' Condition;


The errors show up at "OrcondExpr" in the first rule and at NotcondExpr in the second rule.

What is the solution to solve this?
I already read the user guide (http://www.eclipse.org/Xtext/documentation/0_7_0/xtext.html) and it haven't helped me.

Thanks!
Re: Unassigned rule call... [message #638337 is a reply to message #638192] Wed, 10 November 2010 21:38 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
You might want to have a look at the latest documentation (http://www.eclipse.org/Xtext/documentation/1_0_1/xtext.html) and the third section of chapter 9. I think where you're going with your grammar, but I don't really understand it. Can you give an example of expressions it should accept? Using assigned rule calls/assignments on the right hand side might go a long way in getting the grammar to work (more.

Re: Unassigned rule call... [message #638401 is a reply to message #638192] Thu, 11 November 2010 08:15 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

note that Xtext ships with an example containing expressions (arithmetics example). Also have a look at Sven's blog post on expressions http://blog.efftinge.de/2010/08/parsing-expressions-with-xte xt.html.

The basic issue is that a grammar does not only specify the (allowed) syntax of the files parsed but also the way a model is created from them. Your snippet is not valid as it gives no hint how to build the correct model.

> CondExpr:
> OrcondExpr | 'AND' CondExpr OrcondExpr;

Simply speaking each rule creates an object of some type, so CondExpr will return something. In the first alternative the decision what to return is delegated to OrcondExpr, however in the second (as the error message you get tells you) the call to CondExpr will have created an object and it is unclear what OrcondExpr should do with that object.
A stupid approach would be to change the rule to

CondExpr:
OrcondExpr | 'AND' left=CondExpr right=OrcondExpr;

making the calls assigned rule calls (the return objects of the calls are stored in a feature of the object created by the calling rule). But what you really want is a model tree that corresponds to the expressions (hence read up on expressions in Xtext as mentioned above).

Alex
Previous Topic:Integrate Xtext with SWT
Next Topic:Parsing incomplete models
Goto Forum:
  


Current Time: Fri Apr 26 02:31:37 GMT 2024

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

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

Back to the top