I get the error:
14:9:16:11 ") else sel unexpected token(s)"
when I have two iterates and using tuples.
I've had this problem before but avoided it by solving the problem another
way, but that's not possible now.

Anyone know what the problem is? anyone else been able to use nested
iterates with tuple return value?

It is entirely possible that this is a bug in the OCL grammar definition,
possibly in the rule for tuple literals, collection literals, iterators, or
some combination thereof. There is already one bug report on the
if-expression rule, so maybe that is related, too.

If you can raise a bugzilla report and attach a JUnit test case that
reproduces the problem, then we can look into it. Of course, the simpler
the expression, the easier it will be to debug, so it would be very helpful
if you could reduce the problem from the example below. :-)

> Hi, Nick and Christian.
> Has this bug report been filed?
>
> Is the only thing that needs to be done an example project? I'd
> volunteer to create one based on Christian's EMF templates.
>
> Best, Philipp
>
> Christian W. Damus wrote:
>> Hi, Nick,
>>
>> It is entirely possible that this is a bug in the OCL grammar definition,
>> possibly in the rule for tuple literals, collection literals, iterators,
>> or
>> some combination thereof. There is already one bug report on the
>> if-expression rule, so maybe that is related, too.
>>
>> If you can raise a bugzilla report and attach a JUnit test case that
>> reproduces the problem, then we can look into it. Of course, the simpler
>> the expression, the easier it will be to debug, so it would be very
>> helpful
>> if you could reduce the problem from the example below. :-)
>>
>> Cheers,
>>
>> Christian

This should iterate through the components, then iterate through ports of
the components and add them to the tuple.
This assumes that components have ports. But I did this to keep the query
as simple as possible.

Error given:

Results:
5:61:5:61 ") unexpected token(s)"

I installed the newest version, 1.2.0M4, and got a different error:
3:41:3:49 missing "| oclExpressionCS )" to complete scope

The problem with your example, below, is the attempt to place an
expression "j.oclAsType(Port)" where a variable declaration is required in
the iterate() expression. Moreover, when only one variable is specified in
an iterate, it is the accumulator, which requires declaration of a type and
initial value expression (the iterator variable being implicit).

but does not achieve the goal of collecting all (component, port) pairs. It
only gets the pairs for the last component because the result of the inner
iterate *replaces* the "pairs" value in the outer iterate.

Cheers,

Christian

Nick wrote:

> Hi,
>
> I know that it can be solved much easier but the whole point of this was
> to try an iterate within an iterate. Does it work once you correct the
> problem?
>
> nick

Indeed, OCL queries can become large. I guess that's partly a consequence
of the relatively small and simple syntax. :-)

The classic text on OCL is the Warmer and Kleppe book which, I think, has
been updated for OCL 2.0. A search for the keywords "Warmer" and "OCL" on
Amazon should find it easily.

I can't actually recommend this book, though, because I have never read it.
The only reference that I have is the specification.

HTH,

Christian

nick wrote:

> hi,
>
> I was looking back at this question of mine.
>
> OCL queries can, in my opinion, be quite complicated. What's the best book
> on OCL and in particular (relatively) complicated queries out there?
> What do you use Christian?
>
> cheers,
> Nick