| Recursive Definitions in xtext [message #52950] | 
Thu, 25 June 2009 15:14   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
 
I'm getting into trouble when I use recursive definitions in xtext. 
 
The following simple grammar produces Stack-Overflow-Exceptions when it is  
generated: 
 
 ------------------------------------------------------------ 
Model: 
(assignment+=RightAssignment)*; 
 
RightAssignment: 
AdditiveOperation; 
 
AdditiveOperation: 
MultiplikativeOperation (("+" | "-") MultiplikativeOperation)* ; 
 
MultiplikativeOperation: 
UnaryExpression (("*" | "/") UnaryExpression)* ; 
 
UnaryExpression: 
Literal | "(" AdditiveOperation ")"; 
 
Literal: 
ID | INT; 
 ------------------------------------------------------------ -- 
 
The reason of the Stack-Overflow seems to be the -"(" AdditiveOperation  
")"- construct in the UnaryExpression rule. 
 
What's wrong with this recursive approach? 
 
Thanks for your help!
 |  
 |  
  | 
 | 
 | 
 | 
 | 
| Re: Recursive Definitions in xtext [message #53204 is a reply to message #53178] | 
Fri, 26 June 2009 05:44   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi Gunnar, 
 
currently you'll get more helpful answers to questions regarding oAW  
Xtext at http://www.openarchitectureware.org/forum/?menu=Forum. 
 
Regards, 
Sebastian 
 
 
Am 26.06.2009 11:27 Uhr, schrieb Gunnar Reimann: 
> Hi Sebastian, 
> 
> thank you for your help! But as we are not working with xtext 0.7, this 
> one does, what we want: 
> 
> ----------------------------------------------------- 
> 
> Model: 
> (right+=RightAssignment)*; 
> 
> RightAssignment: 
> (AdditiveOperation); 
> 
> AdditiveOperation: 
> expr+=MultiplikativeOperation (("+" | "-") 
> expr+=MultiplikativeOperation)* ; 
> 
> MultiplikativeOperation: 
> expr+=UnaryExpression (("*" | "/") expr+=UnaryExpression)* ; 
> 
> UnaryExpression: 
> literal=Literal | "(" expr+=AdditiveOperation ")"; 
> 
> NumLiteral: 
> INT; 
> 
> SymLiteral: 
> ID; 
> 
> Literal: 
> NumLiteral | SymLiteral; 
> 
>  ------------------------------------------------------------ -- 
> 
> 
> Greetings, 
> 
> Gunnar 
> 
> 
>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.05983 seconds