SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools



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])
]).
research/jtransformer/api/java/pefs/2.9/caset.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2025