Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Let statements for collection of collections(Such let statements may prevent the code to be parsed)
Let statements for collection of collections [message #1713063] Fri, 30 October 2015 14:13 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 73
Registered: July 2014
Member
At the end of the attached test file, there is the following query definition:

def: aTest(): String =
--let y : Set(Sequence(uml::Transition)) = self.GetAllTransitionPaths(Set(Sequence(uml::Transition)){{self}}) in
doSomething(y)

As is, there is an error because of the "let" statement hidden in a comment, leaving "y" undefined. However, the whole file is correctly parsed and its structure displayed on the outline view.

Now, if I activate this let statement (line 34) in order to define "y", the file cannot be parsed anymore.

I don't see what is wrong in my let statement on line 34 that prevents the entire file to be parsed.

Is it a bug?

Yves

Eclipse Modeling Tools
Version: Mars.1 Release (4.5.1) Build id: 20150924-1200

OCL All-In-One SDK
Version: 6.0.1.v20150908-1239
  • Attachment: test.ocl
    (Size: 1.18KB, Downloaded 80 times)


Yves
Re: Let statements for collection of collections [message #1713073 is a reply to message #1713063] Fri, 30 October 2015 15:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi Yves

[I really dislike the Complete OCL syntax; it has no {} or ; to help a
parser recover, consequently it can be really obscure where an error
actually occurs. I have to delete chunks of source text until the error
goes away rather too often. Occasionally I have to do this with Java too
to localize a mismatched }.]

Your problem, once you remove the comment, is in:

def: aTest(): String =
let y : Set(Sequence(uml::Transition)) =
self.GetAllTransitionPaths(Set(Sequence(uml::Transition)){{self}}) in
doSomething(y)

Perhaps you thought "{{self}}" was a nested literal. It isn't. "{self}"
works. Unfortunately the error is "mismatched input 'def' expecting
'(''" about three "def" constructs earlier.

Similar source text in OCLinEcore gives "no viable alternative at input
'{'" and "mismatched input '}' expecting 'in'" both at the error.

----

Maybe one day I'll provide a better Complete OCL syntax.

Maybe once I apply incremental update technology to the editor I'll
learn how to do better error recovery with Xtext or whatever.

Sorry; not a high priority.

Had a couple of ideas:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=481129 raised.

Regards

Ed Willink

On 30/10/2015 14:13, Yves BERNARD wrote:
> At the end of the attached test file, there is the following query definition:
>
> def: aTest(): String =
> --let y : Set(Sequence(uml::Transition)) = self.GetAllTransitionPaths(Set(Sequence(uml::Transition)){{self}}) in
> doSomething(y)
>
> As is, there is an error because of the "let" statement hidden in a comment, leaving "y" undefined. However, the whole file is correctly parsed and its structure displayed on the outline view.
>
> Now, if I activate this let statement (line 34) in order to define "y", the file cannot be parsed anymore.
>
> I don't see what is wrong in my let statement on line 34 that prevents the entire file to be parsed.
>
> Is it a bug?
>
> Yves
>
> Eclipse Modeling Tools
> Version: Mars.1 Release (4.5.1) Build id: 20150924-1200
>
> OCL All-In-One SDK
> Version: 6.0.1.v20150908-1239
Re: Let statements for collection of collections [message #1713076 is a reply to message #1713073] Fri, 30 October 2015 16:00 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 73
Registered: July 2014
Member
Ed,

Thanks so much.

So "{self}" is suffcient to specify the "set of sequences" litteral.

But now, assume x:T, y:T in the following litteral specification:

Set(Sequence(T)){x,y}

Would it be interpreted as a set of 2 sequences, each of them having only one element, or as a set of only one sequence of two elements?

What would be the correct syntax for the other interpretation?

Yves


Yves
Re: Let statements for collection of collections [message #1713081 is a reply to message #1713076] Fri, 30 October 2015 16:17 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

There are no nested literals. You must manually nested flat literals.

You probably wanted Set{Sequence{self}}.

Regards

Ed Willink


On 30/10/2015 16:00, Yves BERNARD wrote:
> Ed,
>
> Thanks so much.
>
> So "{self}" is suffcient to specify the "set of sequences" litteral.
>
> But now, assume x:T, y:T in the following litteral specification:
> Set(Sequence(T)){x,y}
>
> Would it be interpreted as a set of 2 sequences, each of them having
> only one element, or as a set of only one sequence of two elements?
>
> What would be the correct syntax for the other interpretation?
>
> Yves
Previous Topic:Using OCL with EMF Profiles
Next Topic:OCL query creation fails when using UML profile
Goto Forum:
  


Current Time: Fri Nov 16 05:59:35 GMT 2018

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

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

Back to the top