XES - Programmers Guide - nodeBinaryOp

for information about XES schema see these pages.

BinaryOp

The binaryOp node is used to represent an operation on two operands which may be intergers, floating point , boolean or string.

Binary Operation contains two elements plus an operation to be performed on them, The operation is represented by a simple type and this node must contain the 2 elements to be combined, the left hand and right hand operands. In addition any number of comments can be added.

Attributes used

operator must be set to one of || , && , | , ^ , & , == , != , < , > , <= , >= , << , >> , >>> , + , - , * , / , %

Child Elements

There must be exactly two child elements, each one represents an operand (in addition there can be any number of comment nodes).

Each of the two operands can be either:

Schema entry

	<xs:complexType name="binaryOpType">
<xs:sequence minOccurs="2" maxOccurs="unbounded">
<xs:element name="variable" type="variableType"/>
<xs:element name="array" type="arrayType"/>
<xs:element name="constant" type="constantType"/>
<xs:element name="call" type="callType"/>
<xs:element name="binaryOp" type="binaryOpType"/>
<xs:element name="unaryOp" type="unaryOpType"/>
<xs:element name="comment" type="commentType"/>
</xs:sequence>
<xs:attribute name="operator" type="operatorType"/>
</xs:complexType>
<xs:simpleType name="operatorType">
<xs:restriction base="xs:string">
<xs:enumeration value="||"/>
<xs:enumeration value="&amp;&amp;"/>
<xs:enumeration value="|"/>
<xs:enumeration value="^"/>
<xs:enumeration value="&amp;"/>
<xs:enumeration value="=="/>
<xs:enumeration value="!="/>
<xs:enumeration value="&lt;"/>
<xs:enumeration value="&gt;"/>
<xs:enumeration value="&lt;="/>
<xs:enumeration value="&gt;="/>
<xs:enumeration value="&lt;&lt;"/>
<xs:enumeration value="&gt;&gt;"/>
<xs:enumeration value="&gt;&gt;&gt;"/>
<xs:enumeration value="+"/>
<xs:enumeration value="-"/>
<xs:enumeration value="*"/>
<xs:enumeration value="/"/>
<xs:enumeration value="%"/>
</xs:restriction>
</xs:simpleType>

Translation to other languages

In XES the precedence of operations is determined by the way that the binaryOp nodes are nested, so there is no need for explicit coding of brackets. However when converting from XES to java we have to use brackets when required, this is determined by the rules of precedence. Since this would be complicated to implement, as a first stage it is good enough to always wrap inner operations in brackets even though this may not always be necessary. Athough we should not wrap the outer most operation in brackets.

Possible Improvements

 

Examples of usage

usage java example XES example
  a = b || c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="||">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b && c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&amp;&amp;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b | c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="|">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b ^ c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="^">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b & c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&amp;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b == c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="==">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b != c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="!=">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b < c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&lt;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b > c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&gt;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b <= c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&lt;=">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b >= c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&gt;=">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b << c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&lt;&lt;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b >> c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&gt;&gt;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b >>> c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="&gt;&gt;&gt;">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b + c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="+">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b - c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="-">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b * c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="*">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b / c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="/">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b % c ; <assign operator="=">
<variable name="a"/>
<binaryOp operator="%">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</assign>
  a = b + c * d; <assign operator="=">
<variable name="a"/>
<binaryOp operator="+">
<variable name="b"/>
<binaryOp operator="*">
<variable name="c"/>
<variable name="d"/>
</binaryOp>
</binaryOp>
</assign>
  a = c * d + b; <assign operator="=">
<variable name="a"/>
<binaryOp operator="+">
<binaryOp operator="*">
<variable name="c"/>
<variable name="d"/>
</binaryOp>
<variable name="b"/>
</binaryOp>
</assign>
  a = (b + c) * d; <assign operator="=">
<variable name="a"/>
<binaryOp operator="*">
<variable>
<binaryOp operator="+">
<variable name="b"/>
<variable name="c"/>
</binaryOp>
</variable>
<variable name="d"/>
</binaryOp>
</assign>
  a = c * (d + b); <assign operator="=">
<variable name="a"/>
<binaryOp operator="*">
<variable name="c"/>
<variable>
<binaryOp operator="+">
<variable name="d"/>
<variable name="b"/>
</binaryOp>
</variable>
</binaryOp>
</assign>
     

Java

a = b + c

Scala

Every operation is a message send, written as a function, so b+c is called as add operation on object b.

b+c is interpreted as b.+(c)


metadata block
see also:

 

Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.