Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:39 Go to next message
Dominik Reinert is currently offline Dominik ReinertFriend
Messages: 14
Registered: May 2015
Junior Member
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 13:24 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3071
Registered: July 2009
Senior Member
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 14:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
Have a looj athttp://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html?m=1


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to handle left-recursive Call graphs in xtext? [message #1695355 is a reply to message #1695335] Wed, 13 May 2015 17:12 Go to previous messageGo to next message
Dominik Reinert is currently offline Dominik ReinertFriend
Messages: 14
Registered: May 2015
Junior Member
Thank you!

[Updated on: Wed, 13 May 2015 17:42]

Report message to a moderator

Re: How to handle left-recursive Call graphs in xtext? [message #1695360 is a reply to message #1695355] Wed, 13 May 2015 17:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
http://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html?m=1

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to handle left-recursive Call graphs in xtext? [message #1695413 is a reply to message #1695360] Thu, 14 May 2015 10:50 Go to previous messageGo to next message
Dominik Reinert is currently offline Dominik ReinertFriend
Messages: 14
Registered: May 2015
Junior Member
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 11:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
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);	


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to handle left-recursive Call graphs in xtext? [message #1695424 is a reply to message #1695416] Thu, 14 May 2015 13:39 Go to previous message
Dominik Reinert is currently offline Dominik ReinertFriend
Messages: 14
Registered: May 2015
Junior Member
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: Thu May 13 16:46:55 GMT 2021

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

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

Back to the top