forked from FrevoProject/FREVO
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Java.stg
213 lines (132 loc) · 4.76 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
group Java;
program(globals,functions) ::= <<
class Representation {
public static class Result{
public final float[] output;
public Result(float outp[], int outputsize){
output=outp;
}
}
<globals; separator="\n">
<functions; separator="\n">
}
>>
variable(type,name) ::= "<type> <name>;"
variableInit(type,name,value) ::= "<type> <name> = <value>;"
arrayDeclaration(type,name,size) ::= "<type>[] <name> = new <type>[<size>];"
arrayInitialization(type,name,values,size) ::= "<type>[] <name> = new <type>[] <values>;"
doubleArrayDeclaration(type,name,sizeone,sizetwo) ::= "<type>[][] <name> = new <type>[<sizeone>][<sizetwo>];"
doubleArrayInitialization(type,name,values,sizeone,sizetwo) ::= "<type>[][] <name> = new <type>[][] <values>;"
array(name,indices) ::= << <name><indices:{ind|[<ind>]}> >>
arrayexp(index) ::= "[<index>]"
cast(type) ::= "(<type>)"
castvalue(type,value) ::= "(<type>)<value>"
dummy() ::= "dummy"
globalVariable ::= variable
globalVariableInit ::= variableInit
globalArrayDeclaration ::= arrayDeclaration
globalArrayInitialization ::= arrayInitialization
globalDoubleArrayDeclaration ::= doubleArrayDeclaration
globalDoubleArrayInitialization ::= doubleArrayInitialization
function(type,name,args,locals,stats) ::= <<
<type> <name>(<args; separator=", ">) {
<locals; separator="\n">
<stats; separator="\n">
}
>>
type_int() ::= "int"
type_long_int ::= type_int
type_long_long_int() ::= "long"
type_unsigned_long_int ::= type_long_int
type_unsigned_long_long_int ::= type_long_long_int
type_unsigned_int ::= type_int
type_char() ::= "char"
type_float() ::= "float"
type_double() ::= "double"
type_user_object(name) ::= "<name>"
parameter(type,name) ::= "<type> <name>"
arrayparameter(type,name) ::= "<type>[] <name>"
doublearrayparameter(type,name) ::= "<type>[][] <name>"
statement(expr) ::= "<expr>;"
brackets(expr) ::= "(<expr>)"
return(expr) ::= "return <expr>;"
statementList(locals,stats) ::= <<
{
<locals; separator="\n">
<stats; separator="\n">
}<\n>
>>
forLoop(e1,e2,e3,locals,stats) ::= <<
for (<e1>; <e2>; <e3>) {
<locals; separator="\n">
<stats; separator="\n">
}
>>
ifBlock(e,locals,stats) ::= <<
if (<e>) {
<locals; separator="\n">
<stats; separator="\n">
}
>>
elseBlock(locals,stats) ::= <<
else {
<locals; separator="\n">
<stats; separator="\n">
}
>>
funcinstance(name,args) ::= << <name>(<args; separator=",">)>>
constrinstance(type,name,args) ::= << <type> <name> = new <type>(<args; separator=",">);>>
arrayInitializationBody(args) ::= <<{<args; separator=",">}>>
inkrement(e) ::= "<e>++"
dekrement(e) ::= "<e>--"
inkrementby(lhs,rhs) ::= "<lhs>+=<rhs>"
dekrementby(lhs,rhs) ::= "<lhs>-=<rhs>"
assignmultiply(lhs,rhs) ::= "<lhs>*=<rhs>"
assigndivide(lhs,rhs) ::= "<lhs>/=<rhs>"
assign(lhs,rhs) ::= "<lhs>=<rhs>"
conjunction(left,right) ::= "<left> && <right>"
disjunction(left,right) ::= "<left> || <right>"
equals(left,right) ::= "<left> == <right>"
lessThan(left,right) ::= "<left>\<<right>"
moreThan(left,right) ::= "<left>\><right>"
lessOrEqual(left,right) ::= "<left>\<=<right>"
moreOrEqual(left,right) ::= "<left>\>=<right>"
unEqual(left,right) ::= "<left>!=<right>"
add(left,right) ::= "<left>+<right>"
substract(left,right) ::= "<left>-<right>"
multiply(left,right) ::= "<left>*<right>"
divide(left,right) ::= "<left>/<right>"
bitwiseand(left,right) ::= "<left>&<right>"
bitwiseor(left,right) ::= "<left>|<right>"
bitwisexor(left,right) ::= "<left>^<right>"
bitwiseleftshift(left,right) ::= "<left> \<\< <right>"
bitwiserightshift(left,right) ::= "<left> \>\> <right>"
floor_function(argument) ::= "Math.floor(<argument>)"
round_function(argument) ::= "Math.round(<argument>)"
ceil_function(argument) ::= "Math.ceil(<argument>)"
sin_function(argument) ::= "Math.sin(<argument>)"
sinh_function(argument) ::= "Math.sinh(<argument>)"
cos_function(argument) ::= "Math.cos(<argument>)"
cosh_function(argument) ::= "Math.cosh(<argument>)"
tan_function(argument) ::= "Math.tan(<argument>)"
tanh_function(argument) ::= "Math.tanh(<argument>)"
exp_function(argument) ::= "Math.exp(<argument>)"
log_function(argument) ::= "Math.log(<argument>)"
log10_function(argument) ::= "Math.log10(<argument>)"
sqrt_function(argument) ::= "Math.sqrt(<argument>)"
abs_function(argument) ::= "Math.abs(<argument>)"
pow_function(base,exponent) ::= "Math.pow(<base>,<exponent>)"
refVar(id) ::= "<id>"
iconst(value) ::= "<value>"
minusNumber(value) ::= "-<value>"
valueWithSemicolon(value) ::= "<value>;"
floatFloatingPoint(value) ::="<value>f"
doubleFloatingPoint(value) ::="<value>d"
defaultInt(value) ::= "<value>"
unsignedInt ::= defaultInt
longInt ::= defaultInt
longLongInt(value) ::= "<value>L"
unsignedLongInt ::= longInt
unsignedLongLongInt ::= longLongInt
boolean_false()::= "false"
boolean_true()::= "true"