caseT(#id, #parent, #encl, #label)

Represents the case statement within the switch statement.

Attributes

#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'.

Sample Java Source

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;
	}
}

Its PEF Representation

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 Specification

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])
]).
Last modified: 2014/04/08 21:19
 
*