简体   繁体   中英

java expressions with binary operators in xbase not working

I'm using xbase

grammar xolang.Xolang with org.eclipse.xtext.xbase.Xbase

and an

XBlockExpression

where I expect to write my code

When write an expression like

val c = 1 + 1

Then I get the following error

The method +(int) is undefined

The same happens with Strings. In fact it happens with every binary operator: ==, < , >, ... Now I know that xbase supports operator overloading, maybe that has something to do with it? (Maybe I still have to define somewhere that you can add numbers?)

I solved my problem.

You need to add the xbase.lib jarfile (the right version of course) to the buildpath of the project that uses your DSL.

If you wonder how you can easily add the xbase lib in Eclipse: Right Click on your Project that makes use of your DSL, select Build-Path->Add Libraries and choose XTend Library. The XTend Library includes the correct XBase Lib.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM