File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,11 @@ relop "=="|"!="|"<="|">="|"<"|">"
28
28
" true" { return TRUE ;}
29
29
" false" { return FALSE ;}
30
30
{id } { sscanf (yytext, " %s" , yylval.id ); return IDENTIFIER;}
31
- {inum } { return INT_NUM;}
32
- {fnum } { return FLOAT_NUM;}
33
- {arithop } { return ARITH_OP;}
34
- {boolop } { return BOOL_OP;}
35
- {relop } { return REL_OP;}
31
+ {inum } { yylval. integer = atoi (yytext); return INT_NUM;}
32
+ {fnum } { yylval. floatType = atof (yytext); return FLOAT_NUM;}
33
+ {arithop } { sscanf (yytext, " %s " , yylval. smallString ); return ARITH_OP;}
34
+ {boolop } { sscanf (yytext, " %s " , yylval. smallString ); return BOOL_OP;}
35
+ {relop } { sscanf (yytext, " %s " , yylval. smallString ); return REL_OP;}
36
36
[\(\)\{\} ;=, ] { return yytext[0 ];}
37
37
\n { ++line_num;}
38
38
%%
Original file line number Diff line number Diff line change @@ -196,11 +196,14 @@ expression:
196
196
}
197
197
}
198
198
| expression ARITH_OP expression {
199
- if ($1 .varType == $3 .varType ) {
200
- if ($1 .varType == VarType::INT_TYPE)
201
- appendToCode (" i" + getOperationCode($2 ));
202
- else // it's float
199
+ if ($1 .varType == $3 .varType ) {
200
+ cout<<" Arith " <<$2 <<endl;
201
+ if ($1 .varType == VarType::INT_TYPE) {
202
+ appendToCode (" i" + getOperationCode($2 ));
203
+ }
204
+ else { // it's float
203
205
appendToCode (" f" + getOperationCode($2 ));
206
+ }
204
207
}
205
208
}
206
209
| ' (' expression ' )' {$$ .varType = $2 .varType;}
You can’t perform that action at this time.
0 commit comments