XES - Programmers Guide - nodeLoop

For information about XES schema see these pages.

Loop

This can represent 'while', 'do-while','for' , and 'enhanced for' types of loop.

Depending on which of these (on the value of code) depends on the selection of preCondition, postCondition, initialiser and step as follows:

XES represents all these as one type 'loop' because all the loop constructs are equivalent in many ways. For instance, 'for' can be implemented using 'while' by implementing the initialiser and step separately, or 'while' can be implemented using 'for' by leaving initialiser and step empty.

The subnodes may include the following:

Since it is not possible to tell from the subnodes which type of loop it is we must use the 'code' attribute to determine the meaning of the subnodes as follows:

If code = "while" then the subnodes are:

  1. preCondition
  2. loopBlock

If code = "do" then the subnodes are:

  1. loopBlock
  2. postCondition

If code = "for" then the subnodes are:

  1. preCondition
  2. initialiser
  3. step
  4. loopBlock

If code = "extfor" then the subnodes are:

  1. array or container to be iterated over.
  2. loopBlock

In this enhanced for case there are two additional attributes:

These define the name and type of parameter which iterates over the array or container.

In addition to these subnodes there may be any number of comments at any place.

Value of code attribute in nodeLoop java example XES example
code = "while" while (true) {
break;
}
<loop code="while">
<constant boolConst="true"/>
<block>
<break identifier="break"/>
</block>
</loop>

code = "do" do {
break;
} while (true);
<loop code="do">
<block>
<break indentifier="break"/>
</block>
<constant boolConst="true"/>
</loop>
code = "for" for (i=0;i<2;i++) {
break;
}
<loop code="for">
<assign operator="=">
<variable name="i"/>
<constant/>
</assign>
<binaryOp operator="&lt;">
<variable name="i"/>
<constant/>
</binaryOp>
<variable name="i"/>
<block>
<break indentifier="break"/>
</block>
</loop>
code = "extfor" for (i : array) {
break;
}
<loop code="extfor" name="i" type="int">
<variable name="array"/>
<block>
<break indentifier="break"/>
</block>
</loop>
     
     
     
	<xs:complexType name="loop">
<xs:sequence>
<xs:element name="preCondition" type="booleanExpressionType"/>
<xs:element name="postCondition" type="booleanExpressionType"/>
<xs:element name="initialiser" type="blockType"/>
<xs:element name="step" type="blockType"/>
<xs:element name="block" type="blockType"/>
</xs:sequence>
<xs:attribute name="code" type="loopSubType"/>
</xs:complexType>
<xs:simpleType name="loopSubType">
<xs:restriction base="xs:string">
<xs:enumeration value="for"/>
<xs:enumeration value="extfor"/>
<xs:enumeration value="do"/>
<xs:enumeration value="while"/>
</xs:restriction>
</xs:simpleType>

Java

There are at least 4 forms a loop can take:

for (i=0;i<256;i++) { ... }
or
for (String i : array) { ... } // extended (foreach) form
or
while (i<256) { ... } // test at beginning
or
do { ... } while (i<256) // test at end

Scala

Two possible equivilants to java for loop above

for (i <- 0 until 256) { ... }

or equivilantly we could use

var i = 0; while (i < 256) { ...; i = i+1 }

 


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.