OCL Precedence rules
No edit summary
No edit summary
Line 1: Line 1:
The precedence order for the operations, starting with the highest precedence, in OCL is:
The precedence order for the operations, starting with the highest precedence, in OCL is:
* dot and arrow operations: “.” and “->”  
* dot and arrow operations: <code>“.”</code> and <code>“->”</code>
* unary “not” and unary minus  
* unary ''“not”'' and unary ''minus''
* “*” and “/”  
* <code>“*”</code> and <code>“/”</code>
* “+” and binary “-”  
* <code>“+”</code> and binary <code>“-”</code>
* “if-then-else-endif”  
* ''“if-then-else-endif”''
* “and”, “or,and “xor”  
* <code>“and”</code>, <code>“or”</code>, and <code>“xor”</code>
* “implies”  
* ''“implies”''
* “<“, “>”, “<=”, “>=”  
* <code>“<“</code>, <code>“>”</code>, <code>“<=”</code>, <code>“>=”</code>
* “=”, “<>”  
* <code>“=”</code>, <code>“<>”</code>
Parentheses “(“ and “)” can be used to change precedence.
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 “<>”
'''Note!''' This is not exactly according to the current OCL standard. In standard OCL, ''“and”'', ''“or”'', ''“xor”'' and ''“implies”'' have lower precedence than <code>“<“</code>, <code>“>”</code>, <code>“<=”</code>, <code>“>=”</code>, <code>“=”</code>, and <code>“<>”</code>

Revision as of 05:42, 18 September 2023

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 “<>”

This page was edited 54 days ago on 03/19/2024. What links here