DSL with "private" sections [message #779857] |
Mon, 16 January 2012 17:29 |
Klaus Birken Messages: 25 Registered: December 2009 |
Junior Member |
|
|
Hi all,
I am building a DSL where some objects must be hidden from outside a given scope. I.e., it should support something like "private" sections in C++ or private members in Java.
Simplified "toy" example (left out import-stuff):
Model:
(boxes+=Box)*
(toys+=Toy)*
(kids+=Kid)* ;
Box: 'box' name=ID (toys+=Toy)*;
Toy: 'toy' name=ID;
Kid: name=ID 'has' toy=[Toy|ID];
A kid should be able to reference only the toys which are part of Model.toys, not those which are in a box (Box.toys). In an extended version, each kid might have some access to more toys depending on the boxes' names.
After reading some documentation, I guess I have to provide my own implementation of IResourceDescription.Manager to avoid the "private" EObjects being published in the index. Additionally, I would have to add an additional filter (using local scoping) for handling intra-file references correctly.
However, this solution seems quite clumsy, there might be something more elegant. And: The above solution starts getting complicated in conjunction with FQN - how/where should the name computation for the exported EObjectDescription objects be done? So, I guess I went down the wrong path.
Did someone implement such "private"ish stuff before?
Thanks in advance and regards,
Klaus
|
|
|
|
|
|
Re: DSL with "private" sections [message #780094 is a reply to message #779857] |
Tue, 17 January 2012 07:02 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Klaus,
I'd allow to establish the cross reference but validate the visibility
explicitly. The error messages will be more helpful. You may want to
compare that approach with JDTs error messages if you try access
invisible members of a class.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 16.01.12 18:29, schrieb Klaus Birken:
> Hi all,
>
> I am building a DSL where some objects must be hidden from outside a
> given scope. I.e., it should support something like "private" sections
> in C++ or private members in Java.
> Simplified "toy" :) example (left out import-stuff):
>
> Model:
> (boxes+=Box)*
> (toys+=Toy)*
> (kids+=Kid)* ;
>
> Box: 'box' name=ID (toys+=Toy)*;
>
> Toy: 'toy' name=ID;
> Kid: name=ID 'has' toy=[Toy|ID];
>
>
> A kid should be able to reference only the toys which are part of
> Model.toys, not those which are in a box (Box.toys). In an extended
> version, each kid might have some access to more toys depending on the
> boxes' names.
>
>
> After reading some documentation, I guess I have to provide my own
> implementation of IResourceDescription.Manager to avoid the "private"
> EObjects being published in the index. Additionally, I would have to add
> an additional filter (using local scoping) for handling intra-file
> references correctly.
>
> However, this solution seems quite clumsy, there might be something more
> elegant. And: The above solution starts getting complicated in
> conjunction with FQN - how/where should the name computation for the
> exported EObjectDescription objects be done? So, I guess I went down the
> wrong path.
>
> Did someone implement such "private"ish stuff before?
>
> Thanks in advance and regards,
> Klaus
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03964 seconds