SE & SDA Wiki

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

User Tools

Site Tools



forT (#id, #parent, #encl, [#init_1,...], #condition, [#step_1,...], #body)

Represents the for statement.

Formerly called forLoopT: Renamed since JTransformer 2.3.1_200804151649.

Attributes

#id: id
the unique ID assigned to this fact.

#parent: id
ID of the parent node.

#encl: methodT, constructorT, classInitializerT
ID of the enclosing element.

[#init_1,…]: expression, localT
list of IDs of the initializer expressions in this for statement.

#condition: expression, null
ID of the expression in this for statement.

[#step_1,…]: expression
list of IDs of the update expressions in this for statement.

#body: statement
ID of the body of this for statement.

Sample Java Source

void myFor(){
	int j = 0;
	for (int i = 0; i < 10;i ++){ // corresponding code line to forT
		j++;
	}
}

Its PEF Representation

methodT(#Method, _, 'myFor', [], type(basic, void, 0), [], #Block),
blockT(#Block, #Method, #Method, [_, #For]),
...
forT(#For, #Block, #Method, [#Local], #OperationT, [#OperationT2], #Block2),  % for
localT(#Local, #For, #Method, type(basic, int, 0), 'i', ..),           %j = 0
...
operationT(#OperationT, #For, #Method, [..], '<', 0),                        % i<10
...
operationT(#OperationT2, #For, #Method, [..], '++', 1),                      %i++
...
blockT(#Block2, #For, #Method, [..]),

AST Specification

ast_node_def('Java',forT,[
     ast_arg(id,      mult(1,1,no ), id,  [forT]), % <-- convention!!!
     ast_arg(parent,  mult(1,1,no ), id,  [id]), % <-- convention!!!
     ast_arg(encl,    mult(1,1,no ), id,  [methodT, constructorT, classInitializerT]),
     ast_arg(inits,   mult(0,*,ord), id,  [expressionType,localT]),
     ast_arg(cond,    mult(0,1,no), id,   [expressionType,nullType]),
     ast_arg(updaters,mult(0,*,ord), id,  [expressionType]),
     ast_arg(body,    mult(1,1,no ), id,  [statementType])
]).
research/jtransformer/api/java/pefs/3.0/fort.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2018