for information about XES schema see these pages.
Switch
Call different blocks depending on value of variable.
for information about XES schema see these pages.
Call different blocks depending on value of variable.
<xs:complexType name="switchType">
<xs:sequence>
<xs:element name="variable" type="variableType"/>
<xs:element name="case" type="caseType"/>
<xs:element name="default" type="caseType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="caseType">
<xs:sequence>
<xs:element name="constant" type="constantType"/>
<xs:element name="block" type="blockType"/>
</xs:sequence>
</xs:complexType>
It may be better to change this as described here.
It seems to me this requires two node types switch and case
because default can be encoded as a special type of case.
But what should be the structure? I get the impression that Java and C# are
defined in a slightly different way? In Java cases are like labels and if a
break is not encountered then code execution just carries on past the label,
but in C# cases are more like nodes?
Similarly I think we could encode the structure in two different ways (although
I think the syntax independent of the semantics)
To explain what I mean I will use the following pseudo code:
switch (variable) {
case 0:
StatementA;
StatementB;
case 1:
StatementC;
default:
StatementD;
StatementE;
}
The first way to encode this would be to put case nodes and all
statements directly under the switch node. If this is done then
case nodes would not have any child subnodes, this seems to me to
give the cases the same sort of structure as labels. This is the way that the
program is parsed at the moment (version 0.9).
The second way to encode this would be to put only case nodes under
the switch and to put StatementA and StatementB under case 0, StatementC
under case 1, StatementD and StatementE under default.
I seems to me that the second is a better structure and although there is a
sort of implication that the statements belong to the cases it does not prevent
code from flowing between cases.
switch (number) { case 1: s="one";break; case 2: s="two";break; default: s="more";break; }
object dictionary {
val data = Array(null, "A","B","C")
def apply(x:String) = x match {
case "one" => data(1)
case "two" => data(2)
case "three" => data(3)
}
def update(x:String,y:String) = x match {
case "one" => data(1) = y // ...this gets turned to data.update(1,y)
case "two" => data(2) = y
case "three" => data(3) = y
}
def main(args:Array[String]) { // ...shorthand for this.apply("one")
Console.println(this("one")+","+this("two")+","+this("three"))
this("one") = "X" // ...and this becomes this.update("one","X")
this("two") = "Y"
this("three") = "Z"
Console.println(this("one")+","+this("two")+","+this("three"))
}
}
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.