Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Operator overloading in Xbase Expression(Operator overloading in Xbase Expression)
Operator overloading in Xbase Expression [message #1816520] Wed, 30 October 2019 12:25 Go to next message
Vikas Verma is currently offline Vikas VermaFriend
Messages: 3
Registered: October 2019
Junior Member
I have created a custom data type in the xtext grammar .
In the JVMModel inferrer , it is inferred as java data type.

Now in Xbase xpression i want to overload the operators so that operations can be performed on the custom data type.

In below example custom data type is FIXED, which is actually BigDecimal.
Now i want to support > operator on BigDecimal.
Is it possible?
Example:

PrimitiveType:
fixed=('FIXED') '(' (scale=INT) ')';

DSL:

FIXED(2) bigtest
....
XblockXpression
{
var x = bigtest > 12

}
Re: Operator overloading in Xbase Expression [message #1816626 is a reply to message #1816520] Fri, 01 November 2019 17:56 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
operators are mapped to method names by the naming conventions described in
org.eclipse.xtext.xbase.scoping.featurecalls.OperatorMapping
the extension classes should be added to the classpath of the model projects.
you can either import them explicitly in the model files are implicitely by adapting
org.eclipse.xtext.xbase.scoping.batch.ImplicitlyImportedFeatures


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Formatter2 - I need a backup plan - Create DSL File With Formatted String?
Next Topic:Check if a language/grammar file is defined twice in Workspace
Goto Forum:
  


Current Time: Sat Apr 20 01:31:19 GMT 2024

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

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

Back to the top