Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Conditional expression with xtext
Conditional expression with xtext [message #856565] Wed, 25 April 2012 19:48 Go to next message
asma geg is currently offline asma gegFriend
Messages: 5
Registered: April 2012
Junior Member
I am trying to write a grammar that enables me to choose the parser rule depending on the value of another attribute.
Let me explain more: The grammar I already have is :

Model:
elem+=Elements;
Table_name:
t1='Table1' | t2='Table2'
;
Column1:
t11='t1_c1'|t12='t1_c2'
;
Column2:
t21='t2_c1'|t22='t2_c2'
;
Elements:
'for' id=ID 'in' t= Table_name
'colonne=' column= ...

And I want the attribute column to be Column1 if Table_name==t1 and Column2 if Table_name==t2.
Do you have an idea of the way to do it?

Thank you
Re: Conditional expression with xtext [message #857339 is a reply to message #856565] Thu, 26 April 2012 13:13 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-25-04 21:48, asma geg wrote:
> I am trying to write a grammar that enables me to choose the parser rule
> depending on the value of another attribute.
> Let me explain more: The grammar I already have is :
>
> Model:
> elem+=Elements;
> Table_name:
> t1='Table1' | t2='Table2'
> ;
> Column1:
> t11='t1_c1'|t12='t1_c2'
> ;
> Column2:
> t21='t2_c1'|t22='t2_c2'
> ;
> Elements:
> 'for' id=ID 'in' t= Table_name
> 'colonne=' column= ...
>
> And I want the attribute column to be Column1 if Table_name==t1 and
> Column2 if Table_name==t2.
> Do you have an idea of the way to do it?
>
> Thank you

Elements : 'for' id = ID 'in' columns = Table ;

Table : Table1 | Table2 ;

Table1 : 'Table1' 'colonne' '=' column = ('t1_c1' | 't1_c2' ) ;
Table2 : 'Table2' 'colonne' '=' column = ('t2_c1' | 't2_c2' ) ;

- henrik
Previous Topic:General purpose language possible
Next Topic:new xtext
Goto Forum:
  


Current Time: Fri Apr 26 06:39:33 GMT 2024

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

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

Back to the top