Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » No operations in Xexpressionorvardeclaration
icon5.gif  No operations in Xexpressionorvardeclaration [message #1736372] Wed, 29 June 2016 00:46 Go to next message
Mostafa Kamel is currently offline Mostafa KamelFriend
Messages: 2
Registered: June 2016
Junior Member
(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
Re: No operations in Xexpressionorvardeclaration [message #1736447 is a reply to message #1736372] Wed, 29 June 2016 12:39 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
do you have xbase.lib on the class of the model (xxx.yourdsl) file ?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:IllegalValueException when extending EssentialOCL
Next Topic:No JVM Operators XExpressionOrVarDeclaration
Goto Forum:
  


Current Time: Fri Apr 26 23:42:05 GMT 2024

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

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

Back to the top