Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to write xtext grammar for if statement(if statement grammar using xtext)
How to write xtext grammar for if statement [message #1732272] Sat, 14 May 2016 10:40 Go to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

I am new to xtext. Can anyone tell me how to build xtext grammar below if statement?

if ((b1135_law_cd_cat == 'CR' || b1135_law_cd_cat == 'MJ') && juv_test_flag == 1)
{
int a;
}

I tried the below grammar:

IfStatement: 'if' ((condition+=Condition)| ( '(' condition+=Condition ')' ));

but it is working for below example but not above.

if (b1135_law_cd_cat == 'CR' || b1135_law_cd_cat == 'MJ'

I know my grammar supports only if(condition) but not if((condition) && condition).

any suggestions?
Re: How to write xtext grammar for if statement [message #1732279 is a reply to message #1732272] Sat, 14 May 2016 13:36 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13181
Registered: July 2009
Senior Member
Hi have a Look At

https://typefox.io/parsing-expressions-with-xtext

And http://xsemantics.sourceforge.net/xsemantics-documentation/Expressions-example.html


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How to configure xtend-maven-plugin to target earlier Java versions
Next Topic:Xtext recursive statement
Goto Forum:
  


Current Time: Mon Nov 11 19:38:18 GMT 2019

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

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

Back to the top