-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJava.stg
130 lines (79 loc) · 1.74 KB
/
Java.stg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
group Java;
program(globals,functions) ::= <<
public class Wrapper {
<globals; separator="\n">
}
>>
variable(type,name) ::= "<type> <name>;"
printer(state) ::= "System.out.println( <state> );"
sqler(v1,v2,v3) ::= <<
Statement stmt = null;
String query = 'SELECT <v1> INTO <v2> FROM <v3> ';
try {
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
} catch (SQLException e ) {
JDBCTutorialUtilities.printSQLException(e);
} finally {
if (stmt != null) { stmt.close(); }
}
>>
assignme(var1,var2) ::= "<var1> = <var2>;"
conditionals(v4,v5,v6) ::= <<
if(<v4>) {
<locals; separator="\n">
}
else
{
<stats; separator="\n">
}
>>
conditionalelsif(v7,v8) ::= <<
else if ( <v7> ) {
<v8>
}
>>
type_int() ::= "public int"
type_string() ::= "public String"
type_float() ::= "public float"
refVar(id) ::= "<id>"
iconst(value) ::= "<value>"
abequals(left,right) ::= "<left> == <right>"
abless(left,right) ::= "<left> \< <right>"
abright(left,right) ::= "<left> \> <right>"
abplus(left,right) ::= " <left> + <right>"
giveassign(t1,t2) ::= "<t1>=<t2>;"
findloop(t1,t2) ::= <<
do {
<locals; separator="\n">
} while (<t2>);
>>
wloop(t1,t2) ::= <<
while (<t2>) {
<locals; separator="\n">
}
>>
floop(t1,t2,t3,t4) ::= <<
for(<t1> \< <t3> && <t1> \> <t2> ; <t1>++) {
<locals; separator="\n">
}
>>
funccall(i,j) ::= "<i>=<j>();"
procall(j) ::= "<j>();"
commentId(t1) ::= <<
/*
* <t1>
*/
>>
procedure(t1,t2) ::= <<
public static void <t1>() {
<locals; separator="\n">
}
>>
function (t1,t2,t3,t4) ::= <<
<t2> <t1>() {
<t3>
<locals; separator="\n">
return <t5>
}
>>