Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Linking XCastExpression to a "toX" function
Linking XCastExpression to a "toX" function [message #1774571] Tue, 17 October 2017 12:54 Go to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Dear all.

In my DSL, I would like to enable operator overriding for the cast expressions.
My idea is:

Let the following code:
var x = ...
var y = x as String
var z = x as Y


"x as String" should be map to the Java code "x.toString()".

"x as Y" should be be map to the Java code:
* "x.toY()" if this instance function is defined and accessible,
* "toY(x)" if this class function is defined and accessible,
* "(Y) x" otherwise

My question is: what are the typical classes within Xbase to be extended for enabling this behavior?

I think about:
* XbaseCompiler for generating the Java code,
* DSLValidator for changing the validation test.

What else?

Thank in advance.
Stéphane.
Re: Linking XCastExpression to a "toX" function [message #1774572 is a reply to message #1774571] Tue, 17 October 2017 12:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14067
Registered: July 2009
Senior Member
XbaseCompiler. Possibly Validator. Possibly FeatureScopes
Xbase Type Computer. Maybe XExpressionHelper


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: Linking XCastExpression to a "toX" function [message #1774574 is a reply to message #1774572] Tue, 17 October 2017 13:02 Go to previous message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Thank you, I will start to work based on this list of classes.

Stéphane.
Previous Topic:Expression Language: Using ".*" in combination with Decimal Numbers
Next Topic:Xtext Standalone: Add/Remove/Modify resources
Goto Forum:
  


Current Time: Sat Sep 25 10:31:15 GMT 2021

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

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

Back to the top