Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xbase] Scripting Language
[Xbase] Scripting Language [message #1411159] Fri, 22 August 2014 14:38 Go to next message
Eclipse GuestFriend
Messages: 93
Registered: February 2013
Location: Vienna
Member
Hello to everyone. I'm a student. At the moment i would like to implement the "Scripting Language" for Xtext illustrated in the official guide.
I'm using the last version of Eclipse (Luna) with Xtext and Xbase 2.6
In the tutorial we have the specification of Xbase libraries instead of Terminals, the import of Xbase libraries from "http://www.eclipse.org/xtext/xbase/Xbase" and the definition of the model "Script"

Script returns XBlockExpression
    {Script}
    (expressions += XExpressionsInsideBlock ';'?)*;


After that i wrote the grammar, i obtained this error
"XExpressionsInsideBlock" cannot be resolve as a rule

I would like to define a tiny version of Java with the basic type and basic operators,
without definition of class.

Can i resolve this problem?
Thank you
Re: [Xbase] Scripting Language [message #1411177 is a reply to message #1411159] Fri, 22 August 2014 15:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13264
Registered: July 2009
Senior Member
Hi,

in Xtext 2.6.2 the rulename has changed to XExpressionOrVarDeclaration


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xbase] Scripting Language [message #1411828 is a reply to message #1411177] Sun, 24 August 2014 15:12 Go to previous messageGo to next message
Eclipse GuestFriend
Messages: 93
Registered: February 2013
Location: Vienna
Member
Thank you very much for your reply. It works!
Now i have another problems, related to variable and our visibility in the code.
I defined the following grammar:

Domainmodel:
	importSection=XImportSection?
	elements+=AbstractElement*
;

AbstractElement:
	PackageDeclaration | Entity
;

PackageDeclaration:
	'package' name=QualifiedName '{'
		elements+=AbstractElement*
	'}'
;

Entity:
	'entity' name=ValidID
	('extends' superType=JvmTypeReference)? '{'
		features+=Feature*
	'}'
;

Feature:
	Property | Operation	
;

//Dichiarazione variabili
Property:
	 type=JvmTypeReference name=ValidID ';'
;

Operation:
	'function' name=ValidID
	'('(params+=FullJvmFormalParameter
		(',' params+=FullJvmFormalParameter)*)? ')'
	':' type=JvmTypeReference
	body=XBlockExpression	
;


Now i can declare variable in a java way, but when i try to use a variable inside the "function", i obtain this error "Couldn't resolve reference to JvmIdentifiableElement".
please how can i resolve this problem?
Thank you very much
Re: [Xbase] Scripting Language [message #1411837 is a reply to message #1411828] Sun, 24 August 2014 15:42 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13264
Registered: July 2009
Senior Member
hi

this is usually done by mapping the dsl concepts to java concepts in the jvmmodelinferrer


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Referencing elements of one DSL from another DSL
Next Topic:[SOLVED] Serializer Enum
Goto Forum:
  


Current Time: Mon Dec 09 07:03:37 GMT 2019

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

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

Back to the top