Differences

This shows you the differences between two versions of the page.

Link to this comparison view

research:jtransformer:api:java:pefs:3.0:switcht [2018/05/09 01:59] (current)
Line 1: Line 1:
 +{{page>​prologast_bodypef_index&​fullpage&​nofooter}}
 +
 +----
 +
 +=== switchT(#​id,​ #parent, #​enclMethod,​ #expr, [#​statement_1,​ ...])  ===
 +
 +Represents the switch statement.
 +
 +=== Arguments ===
 +== ==
 +**#id:** id\\ 
 +the unique ID assigned to this fact.
 +
 +**#​parent:​** id\\ 
 +ID of the parent node.
 +
 +**#encl:** [[methodT|methodT]],​ [[constructorT|constructorT]],​ [[classInitializerT|classInitializerT]]\\ ​
 +ID of the enclosing method declaration.
 +
 +**#expr:** [[plastexpression|expression]]\\ ​
 +ID of the selection expression (the variable used to switch).
 +
 +**[#​statement_1,​ ...]:** [[plaststatement|statement]]\\ ​
 +list of the statements in the switch. Cases ([[caset|caseT]]) are a special kind of statement here, much like labels. The **default** statement is a case statement with the label '​null'​.
 +
 +=== Sample Java Code ===
 +== ==
 +<Code lang-java>​
 +void mySwitch() {
 + int month = 1;
 + switch (month) {// corresponding code line to switchT
 + case 1:     //​caseT ​                    
 +    ​System.out.println("​January"​);​
 +    ​break; ​  //​breakT
 + default: ​   //caseT
 +    ​System.out.println("​Invalid month."​);​
 +    ​break; ​  //​breakT
 + }
 +}
 +</​Code>​
 +
 +
 +=== Its PEF Representation ===
 +== ==
 +<Code lang-prolog>​
 +switchT(#​id,​ #parent, #​enclMethod,​ #expr, [#state_1, #state_2, #state_3, #state_4, #state_5, #state_6]).
 +blockT(#​parent,​ #​enclMethod,​ #​enclMethod,​ [..., #id]).
 +methodT(#​enclMethod,​ ..., '​mySwitch',​ [], type(basic, void, 0), [], #parent).
 +identT(#​expr,​ #id, #​enclMethod,​ '​month',​ ...).
 +caseT(#​state_1,​ #id, #​enclMethod,​ ...).
 +execT(#​state_2,​ #id, #​enclMethod,​ ...).
 +breakT(#​state_3,​ #id, #​enclMethod,​ '​null',​ #id).
 +caseT(#​state_4,​ #id, #​enclMethod,​ '​null'​).
 +execT(#​state_5,​ #id, #​enclMethod,​ #parent1).
 +breakT(#​state_6,​ #id, #​enclMethod,​ '​null',​ #id).
 +</​Code>​
 +
 +=== AST Specification ===
 +== ==
 +<​Code>​
 +ast_node_def('​Java',​switchT,​[
 +     ​ast_arg(id, ​    ​mult(1,​1,​no ), id,  [switchT]), % <-- convention!!!
 +     ​ast_arg(parent,​ mult(1,1,no ), id,  [id]), % <-- convention!!!
 +     ​ast_arg(encl, ​  ​mult(1,​1,​no ), id,  [methodT, constructorT,​ classInitializerT]),​
 +     ​ast_arg(cond, ​  ​mult(1,​1,​no ), id,  [expressionType]),​
 +     ​ast_arg(stmts, ​ mult(0,​*,​ord),​ id,  [statementType]) % caseT,​...,​breakT,​...,​defaultT
 +]).
 +</​Code>​
  
research/jtransformer/api/java/pefs/3.0/switcht.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019