Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Changing XBase syntax
Changing XBase syntax [message #731490] Sat, 01 October 2011 11:52 Go to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Hi,

I am using Xbase as the basis for a expression language for business users. Because of that I want to change the syntax more towards what they are used to. For example, I changed:
if( a == 1 )
    "1"
else 
    "2"
into
IF a > 1 THEN
    "1"
ELSE 
    "2"
ENDIF
This is straightforward.
Then I changed the '==' with the keyword 'EQUALS', expecting it to work in the same straightforward way. To my surprise this doesn't work, I get the error message:
Couldn't resolve reference to JvmIdentifiableElement 'EQUALS'.
It seems that Xbase uses the concrete syntax '==' for the lookup as a Java element. I was not expecting that anything in the concrete syntax would implicitly be part of the abstract syntax of Xbase.

I think Xbase should make this distinction between the abstract and concrete syntax because it makes for a much more clean language definition . That way anyone can simply change the '==' to the 'EQUALS' string and change the concrete syntax to look like what is usual in the domain of the DSL that is being developed. After all, that is what DSL's are about. I think Xbase will appeal to a much larger audience this way.

Given the fact that I cannot do this now, can anyone give a pointer as to what I should do to replace strings like '==' by 'EQUALS' ? I am guessing I should create a ValueConverter and simply change the concrete syntax string to '==' again in there myself.

Jos
Re: Changing XBase syntax [message #731493 is a reply to message #731490] Sat, 01 October 2011 11:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

have a look at the class org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Changing XBase syntax [message #731498 is a reply to message #731493] Sat, 01 October 2011 12:40 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Christian,

The workaround with the ValueConverter works ok, I just tried that out. The OperatorMapping class can be changed to allow for the alternative syntax as well I see. I just need to find out where to inject the new version of the class.

Jos
Re: Changing XBase syntax [message #731499 is a reply to message #731498] Sat, 01 October 2011 12:41 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

just add a binding to the runtime module

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Content assist context ignores terminating whitespace
Next Topic:Cross Referencing to objects containing white spaces
Goto Forum:
  


Current Time: Fri Apr 26 22:51:04 GMT 2024

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

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

Back to the top