Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error when saving the model
Error when saving the model [message #52036] Wed, 17 June 2009 08:46 Go to next message
Aurel Ganga is currently offline Aurel GangaFriend
Messages: 14
Registered: July 2009
Junior Member
Hello,

I have a grammar and I write some code in its editor, which goes smoothly.
When saving my model through ctrl+s following error messages appear. For
each entity I create there is a similar message.
Anybody know what that could be related to?


org.xtext.example.myDsl.impl.Entity_TypeImpl cannot be cast to
java.util.Collection MyModel.mydsl /org.xtext.example.mydsl.generator/src/model /org.xtext.example.mydsl.generator/src/model/MyModel.mydsl EMF
Problem
Re: Error when saving the model [message #52065 is a reply to message #52036] Wed, 17 June 2009 11:15 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Aurel,

seems like your metamodel expects a multi-value reference, but you
defined a single valued reference in your grammar.

Please check for patterns like
'something += Entity_Type' and 'something = Entity_Type'
in your grammar and double check them.

Hope that helps,
Sebastian

Am 17.06.2009 9:46 Uhr, schrieb Aurel Ganga:
> Hello,
>
> I have a grammar and I write some code in its editor, which goes
> smoothly. When saving my model through ctrl+s following error messages
> appear. For each entity I create there is a similar message. Anybody
> know what that could be related to?
>
>
> org.xtext.example.myDsl.impl.Entity_TypeImpl cannot be cast to
> java.util.Collection MyModel.mydsl
> /org.xtext.example.mydsl.generator/src/model
> /org.xtext.example.mydsl.generator/src/model/MyModel.mydsl EMF Problem
>
>
Re: Error when saving the model [message #52089 is a reply to message #52065] Wed, 17 June 2009 21:19 Go to previous messageGo to next message
Aurel Ganga is currently offline Aurel GangaFriend
Messages: 14
Registered: July 2009
Junior Member
Thanks for the reply.
I checked for that construct, but it only appears once in my code and
should not be the reason. (under Injection)

Here the code for those who want to take a look, because I can't find
anything yet, mostly because there are not alot of references to
Entity_Type.

Aurel




grammar org.xtext.example.MyDsl with org.eclipse.xtext.common.Terminals

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

//-----------------------------------------------Model------ ------------------------------------------------------------ ----------//
Model:
(elements+=Element)*;

//Elements can be Objects or Predicates
Element:
Object_Type | Predicate | Constraint| DerivationRule;

//-----------------------------------------------Objects---- ------------------------------------------------------------ ------------//
//Objects are Entities or Values
Object_Type:
Entity_Type | Value_Type (IsPrimitive?="subtypes"
supertype=[Object_Type])?;

//Entities
Entity_Type:
"entity" name=ID (IsPrimitive?="subtypes" supertype=[Object_Type])? "{"
(IsNested?="nests" Predicate=[Predicate])?
("definition" def=STRING)?
("subconstr" sub=STRING)?
"}";

//Value is a DataType or not
Value_Type:
Data_Type | "value" name=ID (IsPrimitive?="subtypes"
supertype=[Object_Type])? ;

//DataTypes includes Integer, String, Boolean...
Data_Type:
"data" STRING | "data" INT | "data" type=[Value_Type];

//Instance
Instance:
name=ID;
//-----------------------------------------------Predicates- ------------------------------------------------------------ ---------------//
//Predicate
Predicate:
"predicate" name=ID "{"
"part" (Participants+=Participant",")+
// (constr=Uniqueness_Constr",")*
(Arity=Arity)?
(IsDerived?="derived")?
"}";

//Participants in the predicate
Participant:
type=[Object_Type] role=Role;

//Role
Role:
"role" name=ID (IsMandatory?="mand")?;


//Arity
Arity:
"arity" value=INT;

//-----------------------------------------------Reference
Schemes----------------------------------------------------- -------------//
//Reference_Schemes - Injection
Injection:
"inject" object=[Entity_Type] name=[Object_Type];

//-----------------------------------------------Constraints ------------------------------------------------------------ ----------------//
//Constraints
Constraint:

Uniqueness_Constr|KLC_Constr|IOR_Constr|XOR_Constr|Enum_Cons tr|Range_Constr|RV_Constr|Subset_Constr|Equality_Constr|Excl usive_Constr;

//Uniqueness-Constraint
Uniqueness_Constr:
"UC" name=ID "{"
predicate=[Predicate]
(C_Lines+=C_Line)+
"}";

C_Line:
(content+=[Role])+ ",";

//KeyLengthCheck-Constraint
KLC_Constr:
"KLC" name=ID "{"
predicate=[Predicate]
"}";

//Inclusive-OR
IOR_Constr:
"IORC" name=ID "{" (roles+=[Role])+ "}";

//Exclusive-OR
XOR_Constr:
"XORC" name=ID "{" (roles+=[Role])+ "}";


//Enumeration_Constraint
Enum_Constr:
"EnumC" name=ID "{"ref_value=[Value_Type] "(" (instances+=Instance)* ")"
"}";

//Range-Constraint
Range_Constr:
"RangeC" name=ID "{"ref_value=[Value_Type] "(" from=Instance ".."
to=Instance ")" "}";

//RoleValueConstraint
RV_Constr:
"RVC" name=ID "{" ref_role=[Role] (instances+=Instance)* "}";

//Subset-Constraint
Subset_Constr:
"SsC" name=ID "{"subset_role=[Role] superset_role=[Role] "}";

//Equality-Constraint
Equality_Constr:
"EqC" name=ID "{"role1=[Role] role2=[Role] "}";

//Exclusion-Constraint
Exclusive_Constr:
"XC" name=ID "{" (roles+=[Role])+ "}";

//-----------------------------------------------Derivation
Rules------------------------------------------------------- ---------------------//

//Dervation Rule
DerivationRule:
"derivationRule" name=ID STRING;
Re: Error when saving the model [message #52170 is a reply to message #52089] Thu, 18 June 2009 07:35 Go to previous messageGo to next message
Aurel Ganga is currently offline Aurel GangaFriend
Messages: 14
Registered: July 2009
Junior Member
After rebuilding the whole project from scratch, the error seized to
exist. Weird, because I didn't change anything in the code.
Anyway, problem solved!

Feel free to comment my code syntactically (or esthetically) if you want,
because I am still learning. :)
Re: Error when saving the model [message #52196 is a reply to message #52170] Thu, 18 June 2009 07:40 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Aurel,

see below.

Am 18.06.2009 8:35 Uhr, schrieb Aurel Ganga:
> After rebuilding the whole project from scratch, the error seized to
> exist. Weird, because I didn't change anything in the code. Anyway,
> problem solved!
>
> Feel free to comment my code syntactically (or esthetically) if you
> want, because I am still learning. :)
>

From a first glance I'ld advise you to use lowercase attribute names to
increase readability of your grammar :-)
Previous Topic:An invalid XML character
Next Topic:Re-designed xtext website
Goto Forum:
  


Current Time: Thu Oct 10 22:25:53 GMT 2024

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

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

Back to the top