OCL Precedence rules
(Replacing message template with parser tag) |
No edit summary |
||
Line 1: | Line 1: | ||
<message>Write the content here to display this box</message> | <message>Write the content here to display this box</message> | ||
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: <code>“.”</code> and <code>“->”</code> | * dot and arrow operations: <code><span class="col-black">“.”</span></code> and <code><span class="col-black">“->”</span></code> | ||
* unary ''“not”'' and unary ''minus'' | * unary ''“not”'' and unary ''minus'' | ||
* <code>“*”</code> and <code>“/”</code> | * <code><span class="col-black">“*”</span></code> and <code><span class="col-black">“/”</span></code> | ||
* <code>“+”</code> and binary <code>“-”</code> | * <code><span class="col-black">“+”</span></code> and binary <code><span class="col-black">“-”</span></code> | ||
* ''“if-then-else-endif”'' | * ''“if-then-else-endif”'' | ||
* <code>“and”</code>, <code>“or”</code>, and <code>“xor”</code> | * <code><span class="col-black">“and”</span></code>, <code><span class="col-black">“or”</span></code>, and <code><span class="col-black">“xor”</span></code> | ||
* ''“implies”'' | * ''“implies”'' | ||
* <code>“<“</code>, <code>“>”</code>, <code>“<=”</code>, <code>“>=”</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> | ||
* <code>“=”</code>, <code>“<>”</code> | * <code><span class="col-black">“=”</span></code>, <code><span class="col-black">“<>”</span></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, | '''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|2024}} | ||
[[Category:OCL]] | [[Category:OCL]] |
Revision as of 05:47, 19 June 2024
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 “<>”