Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Want add Array slice feature for my library(Couldn't resolve reference to JvmIdentifiableElement 'c' for my obj)
Want add Array slice feature for my library [message #1834946] Sat, 21 November 2020 14:36 Go to next message
zhaoxi du is currently offline zhaoxi duFriend
Messages: 2
Registered: November 2020
Junior Member
I want add Array slice feature for my library, those days i watched books and videos still confused how to implement this.

Feel a little disappointed about xbase , so complicated.

Erro:
Couldn't resolve reference to JvmIdentifiableElement 'c'.

import cn.centipede.numpy.Numpy.np

package cn.simbaba {
	script SVM {
		a:int
		
		def test1() {
			var b = np.arange(12).reshape(3,4);
			var d = c[0];
			d.dump() // [[4,5,6,7]]
		}
	}
}


And the grammay as follows:
..........
..........
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types

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

AbstractElement:
	PackageDeclaration | Entity;

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

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

Feature:
	Property | Operation;

Property:
	name=ValidID ':' type=JvmTypeReference;

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

@Override 
XCastedExpression returns xbase::XExpression:
	NPExpression (=>({XCastedExpression.target=current} 'as') type=JvmTypeReference)*
;

NPExpression returns xbase::XExpression:
	NPArrayCall =>({XPostfixOperation.operand=current} feature=[types::JvmIdentifiableElement|OpPostfix])?
;

NPArrayCall returns xbase::XExpression:
	XMemberFeatureCall => ({Array.left = current} '[' index=INT ']')*
;
Re: Want add Array slice feature for my library [message #1834960 is a reply to message #1834946] Sun, 22 November 2020 13:36 Go to previous message
zhaoxi du is currently offline zhaoxi duFriend
Messages: 2
Registered: November 2020
Junior Member
I implemented myself today, thanks~ if you want use xbase happily, you need dig too much, and you should have concept on compile.
Previous Topic:64bit figure
Next Topic:Defining long in xtext and expecting rule_long error
Goto Forum:
  


Current Time: Wed Aug 04 10:43:21 GMT 2021

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

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

Back to the top