Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL: Iterate over code lines
OCL: Iterate over code lines [message #895139] Wed, 11 July 2012 19:26
Wouter Schaekers is currently offline Wouter SchaekersFriend
Messages: 17
Registered: July 2012
Junior Member


num a = 1
num b = 2
num c = 3
num d = 4
num e = 5 <- ERROR

I want to iterate over all lines (eg the grammar lines that define the 'plus') and make sure that the first argument is never higher than the second argument. So: -> a becomes 3 -> c becomes 7 -> a becomes 10 -> 10 > 5 -> ERROR

Ofcourse it isn't difficult if you store the solution of every operation in a new variable, but that's not what I want. I want to put the sum in the first argument.
I know how to iterate over a collection in OCL. (eg self.rules->iterate(n : Name; sum : Integer = 0 | sum + n.int1) < 15) But in here, I have to use some sort of index or use a next() or previous() command if that exists.
Is it possible to do such a thing in OCL?


PS: I posted the same question here, but I was advised to post this question on this forum.

[Updated on: Wed, 11 July 2012 19:27]

Report message to a moderator

Previous Topic:parsing ocl in guards
Next Topic:Package as Ocl Context
Goto Forum:

Current Time: Mon May 28 01:37:44 GMT 2018

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

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

Back to the top