SDA SE WikiSoftware Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Represents the case statement within the switch statement.
#id:
the unique ID assigned to this fact.
#parent:
ID of the switch statement being used for the node. (which incidentally is the parent within the AST).
#encl: methodT, constructorT, classInitializerT
ID of the enclosing element.
#label: expression, null
ID of the reference to a label. For the default case (default:) this is 'null'.
void mySwitch() {
int month = 1;
switch (month) {
case 1: // case 1
System.out.println("January");
break;
default: // case 2
System.out.println("Invalid month.");
break;
}
}
methodT(#Method, #Class, 'mySwitch', [], type(basic, void, 0), [], #Block), ... switchT(#Switch, #Block, #Method, ., ...), ... caseT(#Case, #Switch, #Method, #Expression), //case 1 literalT(#Expression, #Case, #Method, type(basic, int, 0), '1'), ... caseT(#CaseDefault, #Switch, #Method, 'null'), // case 2 ...
ast_node_def('Java',caseT,[
ast_arg(id, mult(1,1,no ), id, [caseT]), % <-- convention!!!
ast_arg(parent, mult(1,1,no ), id, [id]), % <-- convention!!!
ast_arg(encl, mult(1,1,no ), id, [methodT, constructorT, classInitializerT]),
ast_arg(expr, mult(0,1,no), id, [expressionType, nullType])
]).