(y == "ASD") // Operator == not defined
I'm trying to make a scripting language similar to Tortoise but not completely it has many implicit details i don't want the user to know but still want him to be able to write near java Code and xtend fits this perfectly.
Any operator i define doesn't Work in "XExpressionOrVarDeclaration" no matter what i do
x[0] // doesn't work x.get(0) works
x==1 // == not found
var x = 1 + 1; // + not found
* - / + ++ == =< any operator doesn't work
i only need to fix this problem so that it works with my current setup
var alpha = 1 + 2; //error msg: + not found
[Note]
I'm a beginner and this is my first project related to eclipse developmen
grammar xjad.Opponent with org.eclipse.xtext.xbase.Xbase
generate opponent "http://www.Opponent.xjad"
import "http://www.eclipse.org/xtext/xbase/Xbase"
Program :
subPrograms+=SubProgram*
body=Body
;
SubProgram:
'Node' type=JvmTypeReference name=ID MAC=STRING IP=STRING
;
Body returns XBlockExpression:
{XBlockExpression}
'begin'
(expressions+= XExpressionOrVarDeclaration ';'?)*
'end';
class OpponentJvmModelInferrer extends AbstractModelInferrer {
@Inject extension JvmTypesBuilder
public static val INFERRED_CLASS_NAME = 'OpponentProgram'
final String ImplicitSocketName = "ImplicitSocket";
def dispatch void infer(Program program, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
acceptor.accept(program.toClass(INFERRED_CLASS_NAME)) [
members += toField(ImplicitSocketName,typeRef(UsbSocket))[
static = true
final =true
initializer = '''new UsbSocket()'''
]
for (subp : program.subPrograms) {
members += subp.toField(subp.name, subp.type) [
static = true
final =true
initializer = '''new «subp.type.qualifiedName»(«ImplicitSocketName»,"«subp.MAC»","«subp.IP»")'''
]
}
if (program.body != null) {
members += program.toMethod("main", typeRef(Void.TYPE)) [
parameters += program.toParameter("args", typeRef(String).addArrayTypeDimension)
static = true
varArgs = true
body = program.body
]
}
]
}
}
t