File tree Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Expand file tree Collapse file tree 2 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 1
- .class public test
1
+ .class public java_class
2
2
.super java/lang/Object
3
3
4
4
.method public <init> ()V
@@ -15,7 +15,31 @@ iconst_0
15
15
istore_1
16
16
iconst_0
17
17
istore_2
18
+ ldc 121
19
+ tore_
20
+ iconst_0
21
+ istore_3
22
+ ldc 122
23
+ ore_
24
+ iconst_0
25
+ istore_4
26
+ ldc 12666
27
+ re_
28
+ iconst_0
29
+ istore_5
30
+ ldc 98
31
+ e_
32
+ iconst_0
33
+ istore_6
34
+ ldc 97
35
+ _
36
+ iconst_0
37
+ istore_7
38
+ ldc 110
39
+
18
40
fconst_0
19
- fstore_3
41
+ fstore_8
42
+ ldc 0.000000
43
+ not declared
20
44
return
21
45
.end method
Original file line number Diff line number Diff line change 19
19
%error-verbose
20
20
21
21
%token <id> IDENTIFIER
22
- %token INT_NUM
23
- %token FLOAT_NUM
22
+ %token <integer> INT_NUM
23
+ %token <floatType> FLOAT_NUM
24
24
%token <smallString> ARITH_OP
25
25
%token <smallString> BOOL_OP
26
26
%token <smallString> REL_OP
47
47
char id[30 ];
48
48
char smallString[20 ];
49
49
int varType;
50
+ int integer;
51
+ float floatType;
50
52
51
53
struct ExpressionType {
52
54
int varType;
@@ -167,8 +169,13 @@ assignment: IDENTIFIER '=' expression ';'{
167
169
};
168
170
169
171
expression :
170
- INT_NUM {$$ .varType = VarType::INT_TYPE; }
171
- | FLOAT_NUM {$$ .varType = VarType::FLOAT_TYPE ; }
172
+ INT_NUM {
173
+ $$ .varType = VarType::INT_TYPE;
174
+ appendToCode (" ldc " + to_string($1 ));
175
+ }
176
+ | FLOAT_NUM {
177
+ $$ .varType = VarType::FLOAT_TYPE ;
178
+ appendToCode (" ldc " + to_string($1 )); }
172
179
| IDENTIFIER {
173
180
// check if the identifier already exist to load or not
174
181
if (checkIfVariableExists($1 )) {
You can’t perform that action at this time.
0 commit comments