[Xbase] Scripting Language [message #1411159] |
Fri, 22 August 2014 10:38  |
Eclipse Guest 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 #1411828 is a reply to message #1411177] |
Sun, 24 August 2014 11:12   |
Eclipse Guest 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03369 seconds