Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parse XExpressions
icon5.gif  Parse XExpressions [message #1697063] Mon, 01 June 2015 09:47 Go to next message
Daniel Kraus is currently offline Daniel KrausFriend
Messages: 5
Registered: June 2015
Junior Member
As part of my thesis I wrote a small DSL which describes special flowcharts. The decision nodes of those charts use the following parser rule:

Decision:
	'decision' name=ValidID '{'
		expression=XExpression
	'}'
;


In my IJvmModelInferrer I map each decision to a method and set the XExpression as its body. Most of the time those expressions contain a simple if clause (sometimes switch statements) to evaluate one or more system properties and to decide which node or leaf comes next.

In order to visualize a flowchart I have to analyze the given XExpressions (and therefore parts of the AST) to draw links between nodes. A short example for this (in DSL syntax):

decision myDecision {
	if  (foo)
		return anotherDecision
	else
		return MY_LEAF
}


So what I want to do is show myDecision (which I already accomplished) and have outgoing links to anotherDecision and MY_LEAF, ideally with a label "if (foo)" and "else".

What is the best or easiest way to parse my XExpressions to achieve this? I'm new to the world of EMF/Xtext/Xbase and thankful for any help or advice.

[Updated on: Tue, 02 June 2015 08:34]

Report message to a moderator

Re: Parse XExpressions [message #1697093 is a reply to message #1697063] Mon, 01 June 2015 14:02 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Daniel,

the expressions are already parsed. I assume what you are looking for is
ILogicalContainerProvider.getAssociatedExpression(JvmIdentifiableElement) and
a means to walk the expression tree that is obtained from there.
Please check whether the XbaseSwitch or a plain xtend dispatch method
for the various expression types suite your needs.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Parse XExpressions [message #1697186 is a reply to message #1697093] Tue, 02 June 2015 08:38 Go to previous message
Daniel Kraus is currently offline Daniel KrausFriend
Messages: 5
Registered: June 2015
Junior Member
Hey Sebastian,

I'm sorry for the ambiguous wording, your assumption was correct. I was able to get the parts of those XExpressions with a dispatch method, so thanks for your food for thought!

Regards,
Daniel
Previous Topic:Highlighting of hidden elements is not as expected
Next Topic:Scoping query
Goto Forum:
  


Current Time: Thu Mar 28 17:47:00 GMT 2024

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

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

Back to the top