Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross-Reference
Cross-Reference [message #876403] Thu, 24 May 2012 14:27 Go to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
Hello;
I have a problem with Cross-Reference & XBase
The following Code is not working at:

Entity:
'entity' name=EntityName ('extends' superType=[Entity])? '{'
	features+=Feature*
'}';


and

Reference:
type=[Entity] name=ID ';';



The whole code of the project is:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	elements+=AbstractElement*;

AbstractElement:
	Package | Import | Entity;

Package:
	'package' name=QualifiedName ';';

Import:
	'import' name=QualifiedNameWithWildCard ';';

Entity:
	'entity' name=EntityName ('extends' superType=[Entity])? '{'
		features+=Feature*
	'}';

Feature:
	Attribut | Reference;

Attribut:
	datatype=Datatype name=ID ';';

Reference:
	type=[Entity] name=ID ';';

enum Datatype:
	String | Integer | Double | TimeStamp | Text | Char;

terminal EntityName:
	('A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*;

QualifiedNameWithWildCard:
	QualifiedName '.*'?;




Code of my DSL is
package org.demo01;
import org.demo.*;

entity Klaus {
	String akke;
}

entity Alfred {
	String alfred;
}



I can not write :
entity Alfred extends Klaus {
	String alfred;
}



I can not write :
entity Alfred {
	String alfred;
        Klaus klaus;
}


What is wrong in my DSL

Re: Cross-Reference [message #876492 is a reply to message #876403] Thu, 24 May 2012 18:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
Hi,

why do you inherit from Xbase if you do not use it?
the actual problem is:

EntityName hides ID

i would remove entityname and replace it with ID

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876714 is a reply to message #876492] Fri, 25 May 2012 07:11 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
I have changed it, but i still get an error.
mismatched input Klaus expecting RULE_ID.

Entity:
	'entity' name=ID ('extends' superType=[Entity])? '{'
		features+=Feature*
	'}';


I use Xbase because this is not the whole code.
In other Code I have to use
Operation:
	visibility=Visibility? 'op' name=ValidID '(' (params+=JvmFormalParameter (',' params+=JvmFormalParameter)*)? ')' ':' type=JvmTypeReference 
		body=XBlockExpression;

Re: Cross-Reference [message #876717 is a reply to message #876714] Fri, 25 May 2012 07:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
Please Post a complete reproduceable grammar

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876725 is a reply to message #876717] Fri, 25 May 2012 07:44 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	elements+=AbstractElement*;

AbstractElement:
	Package | Import | Entity;

Package:
	'package' name=QualifiedName ';';

Import:
	'import' name=QualifiedNameWithWildCard ';';

Entity:
	'entity' name=ID ('extends' superType=[Entity])? '{'
		features+=Feature*
	'}';

Feature:
	Attribut | Reference;

Attribut:
	datatype=Datatype name=ID ';';

Reference:
	'Ref' type=[Entity] '[0..1]' name=ValidID ';';

enum Datatype:
	String | Integer | Double | TimeStamp | Text | Char;

terminal EntityName:
	('A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*;

QualifiedNameWithWildCard:
	QualifiedName '.*'?;


Re: Cross-Reference [message #876734 is a reply to message #876725] Fri, 25 May 2012 07:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
Hi delete this entityname crap

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876756 is a reply to message #876734] Fri, 25 May 2012 08:41 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
thanks, now it works
One more question:
How can i define, that an Entity can not begin with a number?

For example:
terminal ID:
('A'..'Z' | 'a'..'z' | '_')*;
Re: Cross-Reference [message #876760 is a reply to message #876756] Fri, 25 May 2012 08:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
Hi,

and ID already cannt begin with a number can it? (see Terminals Supergrammar)

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876765 is a reply to message #876760] Fri, 25 May 2012 08:51 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
thanks
very good

One more last Question:
I want to write the following Code
Mensch [0..1] mensch;


My Grammar is
Reference:
	type=[Entity] refEnum=RefEnum name=ValidID ';';
	
enum RefEnum:
	[1..1], [1..*], [*..1], [*..*];


How must I write:
[1..1], [1..*], [*..1], [*..*];
Re: Cross-Reference [message #876786 is a reply to message #876765] Fri, 25 May 2012 09:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
hi,

have a look at the docs

enum RefEnum:
onetoone="[1..1]"| oneton="[1..*]"| ntoone="[*..1]"| nton="[*..*]";


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876800 is a reply to message #876786] Fri, 25 May 2012 09:53 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
Thanks.
I have solved it the following way
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	elements+=AbstractElement*;

AbstractElement:
	Package | Import | Entity;

Package:
	'package' name=QualifiedName ';';

Import:
	'import' name=QualifiedNameWithWildCard ';';

Entity:
	'entity' name=ID ('extends' superType=[Entity])? '{'
	features+=Feature*
	'}';

Feature:
	Attribut | Reference;

Attribut:
	datatype=Datatype name=ID ';';

Reference:
	(containment=Containment)? type=[Entity] '[' lowerBound=BoundLiteral '..' upperBound=BoundLiteral ']' name=ValidID
	';'
;

//enum RefEnum:
//	ONE_TO_ONE='[1..1]' | ONE_TO_MANY='[1..*]' | MANY_TO_ONE='[*..1]' | MANY_TO_MANY='[*..*]';

enum BoundLiteral:
	ONE='1' | MANY='*';

enum Containment:
	contains;

enum Datatype:
	String | Integer | Double | TimeStamp | Text | Char;

QualifiedNameWithWildCard:
	QualifiedName '.*'?;


But now I have the problem, that the CodeAssist don't work with
Reference:
	(containment=Containment)? type=[Entity] '[' lowerBound=BoundLiteral '..' upperBound=BoundLiteral ']' name=ValidID
Re: Cross-Reference [message #876804 is a reply to message #876800] Fri, 25 May 2012 09:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
what do you mean with "the CodeAssist don't work with"

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876815 is a reply to message #876804] Fri, 25 May 2012 10:11 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
When I use the DSL
package org.demo;

import org.demo01.*;

entity Customer {
	String test;
}

entity Item {
}

entity Order {
	Customer [1..*] customer;
	contains Detail [1..*] details;
}

entity Detail {
	Item [1..1] item;
}


Here all is ok, but for following the CodeAssist don't work
Customer [1..*] customer;
=> here especialy for [1..*]

Code Assit = <Ctrl> + <Leertaste>

[Updated on: Fri, 25 May 2012 10:12]

Report message to a moderator

Re: Cross-Reference [message #876836 is a reply to message #876815] Fri, 25 May 2012 11:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13494
Registered: July 2009
Senior Member
Hi,

you have to override isKeywordWorthyToPropose in the proposalprovider (you are the guy using Xbase Wink)

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross-Reference [message #876864 is a reply to message #876836] Fri, 25 May 2012 12:10 Go to previous message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
Thanks, all ok.
Previous Topic:[Xtend 2.3 M6] Function1 cannot be used as parameter
Next Topic:Possible leak in SortOutlineContribution
Goto Forum:
  


Current Time: Mon Jul 13 12:01:16 GMT 2020

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

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

Back to the top