Skip to main content



      Home
Home » Modeling » TMF (Xtext) » How to handle left-recursive Call graphs in xtext?
How to handle left-recursive Call graphs in xtext? [message #1695265] Wed, 13 May 2015 02:39 Go to next message
Eclipse UserFriend
Hello Community,

I am currently working on a project for the university and I need to implement a language that can be used by schooled personel. That means: I need to give them a short introduction to the language and they should know how to use it.

The project is about CEP (Complex event processing), but the time we have only allows a simple IF - THEN architecture.

So here is the grammar (I already put it in xtext like this, so if you want to know the exact problems you may simply add it into your eclipse editor):

/* The general appearance of the language */
ruleLanguage:
	'if ['timeInMs=INT']('CONDITIONS')then('ACTIONS')';
	
/* There can be as many conditions as the user wants to */
/* link to another*/
CONDITIONS:
	SCOND | CONDITIONS '&' SCOND;
	
/* This is how one condition is set up: */
/* name << value	 */
/* for example: */
/* sensor1.temperature << 100°C*/
SCOND:
	sname=ID COMP value=INT;

/* These are the possible operators (comparison only)  */	
COMP:
	'<<' | '>>' | '==' | '<=' | '>=';

/* The conditions defined earlier can also have as many */
/* actions as the user wants */
ACTIONS:
	ACTION | ACTIONS '&' ACTION;

/* An action has a name and gets a parameter list, e.g.: */
/* sendEmail ("example@googlemail.com") */
ACTION:
	fname=ID '(' PARLIST ')';

/* Whatever comes here should just be given to the */
/* called function of the main program */	
PARLIST:
	'(' INT ')' | '(' ID ')';


I already googled this of course, but I don't understand the answers or at least don't know how to tailor them to my problem.

I would be deeply grateful for your help.

Greetings,
Dominik Reinert
Re: How to handle left-recursive Call graphs in xtext? [message #1695322 is a reply to message #1695265] Wed, 13 May 2015 09:24 Go to previous messageGo to next message
Eclipse UserFriend
Moving this to the TMF - Xtext forum.
Re: How to handle left-recursive Call graphs in xtext? [message #1695335 is a reply to message #1695322] Wed, 13 May 2015 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Have a looj athttp://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html?m=1
Re: How to handle left-recursive Call graphs in xtext? [message #1695355 is a reply to message #1695335] Wed, 13 May 2015 13:12 Go to previous messageGo to next message
Eclipse UserFriend
Thank you!

[Updated on: Wed, 13 May 2015 13:42] by Moderator

Re: How to handle left-recursive Call graphs in xtext? [message #1695360 is a reply to message #1695355] Wed, 13 May 2015 13:22 Go to previous messageGo to next message
Eclipse UserFriend
http://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html?m=1
Re: How to handle left-recursive Call graphs in xtext? [message #1695413 is a reply to message #1695360] Thu, 14 May 2015 06:50 Go to previous messageGo to next message
Eclipse UserFriend
With the help of Christian Dietrich I came to this:

/* The general appearance of the language */
ruleLanguage:
	'if ['timeInMs=INT']('CONDITIONS')then('ACTIONS')';
	
/* There can be as many conditions as the user wants to */
/* link to another									   */
CONDITIONS returns Expression:
	SCOND ({CONDITIONS.left=current} '&' right=SCOND)*;
	
/* This is how one condition is set up:				   */
/* name << value									   */
/* for example:										   */
/* sensor1.temperature << 100°C						   */
SCOND returns Expression:
	sname=ID COMP value=INT;

/* These are the possible operators (comparison only)  */	
COMP:
	'<<' | '>>' | '==' | '<=' | '>=';

/* The conditions defined earlier can also have as many */
/* actions as the user wants                            */
ACTIONS returns Expression:
	ACTION ({ACTIONS.left=current}'&' right=ACTION)*;

/* An action has a name and gets a parameter list, e.g.:*/
/* sendEmail ("example@googlemail.com")				    */
ACTION returns Expression:
	fname=ID '(' PARLIST ')';

/* Whatever comes here should just be given to the      */
/* called function of the main program                  */	
PARLIST returns Expression:
	INT | ID | MOREPAR ({PARLIST.left=current} ',' right=MOREPAR)*;
	
MOREPAR:
	INT | ID; 



Now it tells me:

Quote:
Multiple markers at this line
- Cannot change type twice within a rule
- An unassigned rule call is not allowed, when the 'current'
was already created.


next to the third line

and:
Quote:
An unassigned rule call is not allowed, when the 'current' was
already created.


beneath the 'ACTION' line.

The last one is:
Quote:
An action is not allowed, when the current may still be unassigned.

beneath the PARLIST line.


any suggestions?
Re: How to handle left-recursive Call graphs in xtext? [message #1695416 is a reply to message #1695413] Thu, 14 May 2015 07:47 Go to previous messageGo to next message
Eclipse UserFriend
you basically miss tons of assignments


import "http://www.eclipse.org/emf/2002/Ecore" as ecore

ruleLanguage:
	'if ['timeInMs=INT']('conds=CONDITIONS')then('actions=ACTIONS')';
	
/* There can be as many conditions as the user wants to */
/* link to another									   */
CONDITIONS returns Expression:
	SCOND ({CONDITIONS.left=current} '&' right=SCOND)*;
	
/* This is how one condition is set up:				   */
/* name << value									   */
/* for example:										   */
/* sensor1.temperature << 100°C						   */
SCOND returns Expression:
	sname=ID COMP value=INT;

/* These are the possible operators (comparison only)  */	
COMP:
	'<<' | '>>' | '==' | '<=' | '>=';

/* The conditions defined earlier can also have as many */
/* actions as the user wants                            */
ACTIONS returns Expression:
	ACTION ({ACTIONS.left=current}'&' right=ACTION)*;

/* An action has a name and gets a parameter list, e.g.:*/
/* sendEmail ("example@googlemail.com")				    */
ACTION returns Expression:
	fname=ID '(' params=PARLIST ')';

/* Whatever comes here should just be given to the      */
/* called function of the main program                  */	
PARLIST returns Expression:
	MOREPAR ({PARLIST.left=current} ',' right=MOREPAR)*;
	
MOREPAR  returns Expression:
	{MOREPAR}MOREPARValue=MOREPARValue ;
	
MOREPARValue returns ecore::EString:(INT | ID);	
Re: How to handle left-recursive Call graphs in xtext? [message #1695424 is a reply to message #1695416] Thu, 14 May 2015 09:39 Go to previous message
Eclipse UserFriend
Thank you man. I am glad someone like you helped me with this.
Previous Topic:Using annotations in DSL
Next Topic:keywords in grammar
Goto Forum:
  


Current Time: Sun Jul 27 16:21:50 EDT 2025

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

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

Back to the top