OCL Precedence rules
m ((username removed) (log details removed))
(Updated Edited template to July 12, 2025.)
 
Line 14: Line 14:


'''Note!''' This is not exactly according to the current OCL standard. In standard OCL, “and”, “or”, “xor” and ''“''implies” have lower precedence than <code><span class="col-black">“<“</span></code>, <code><span class="col-black">“>”</span></code>, <code><span class="col-black">“<=”</span></code>, <code><span class="col-black">“>=”</span></code>, <code><span class="col-black">“=”</span></code>, and <code><span class="col-black">“<>”</span></code>
'''Note!''' This is not exactly according to the current OCL standard. In standard OCL, “and”, “or”, “xor” and ''“''implies” have lower precedence than <code><span class="col-black">“<“</span></code>, <code><span class="col-black">“>”</span></code>, <code><span class="col-black">“<=”</span></code>, <code><span class="col-black">“>=”</span></code>, <code><span class="col-black">“=”</span></code>, and <code><span class="col-black">“<>”</span></code>
{{Edited|July|12|2024}}
{{Edited|July|12|2025}}
[[Category:OCL]]
[[Category:OCL]]

Latest revision as of 05:59, 20 January 2025

This page was created by Lars.olofsson@mdriven.net on 2023-05-03. Last edited by Edgar on 2025-01-20.


The precedence order for the operations, starting with the highest precedence, in OCL is:

  • dot and arrow operations: “.” and “->”
  • unary “not” and unary minus
  • “*” and “/”
  • “+” and binary “-”
  • “if-then-else-endif”
  • “and”, “or”, and “xor”
  • “implies”
  • “<“, “>”, “<=”, “>=”
  • “=”, “<>”

Parentheses “(“ and “)” can be used to change precedence.

Note! This is not exactly according to the current OCL standard. In standard OCL, “and”, “or”, “xor” and implies” have lower precedence than “<“, “>”, “<=”, “>=”, “=”, and “<>”