i'm a beginner at Xtext and i have the following grammer nearly identical to Tortoise language(one of 7 Languages )
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';
var alpha = 1 + 2; //Fails with + cannot be resolved.
The following is the inferance engine
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
]
}
]
}
if(y == "ASD") .....
i see the following error in the editor
== cannot be resolved.
and same for any == =< => ++ 1+2 and any similar operation