|
@@ -311,11 +311,12 @@ assign_statement : IDENTIFIER LSQUARE exp RSQUARE ASSIGN exp
|
|
|
gen_move_immediate(program, location, $3.value);
|
|
|
gen_addi_instruction(program, infty, REG_0, $3.infty);
|
|
|
}
|
|
|
- else
|
|
|
+ else {
|
|
|
instr = gen_add_instruction
|
|
|
(program, location, REG_0, $3.value, CG_DIRECT_ALL);
|
|
|
gen_add_instruction(program, infty, REG_0, $3.infty,
|
|
|
CG_DIRECT_ALL);
|
|
|
+ }
|
|
|
|
|
|
/* free the memory associated with the IDENTIFIER */
|
|
|
free($1);
|
|
@@ -433,7 +434,7 @@ return_statement : RETURN
|
|
|
|
|
|
read_statement : READ LPAR IDENTIFIER RPAR
|
|
|
{
|
|
|
- int locationi, infty;
|
|
|
+ int location, infty;
|
|
|
|
|
|
/* read from standard input an integer value and assign
|
|
|
* it to a variable associated with the given identifier */
|
|
@@ -446,7 +447,7 @@ read_statement : READ LPAR IDENTIFIER RPAR
|
|
|
|
|
|
/* insert a read instruction */
|
|
|
gen_read_instruction (program, location);
|
|
|
- gen_addi_instruction(program, infty, REG_0, 1)
|
|
|
+ gen_addi_instruction(program, infty, REG_0, 1);
|
|
|
|
|
|
/* free the memory associated with the IDENTIFIER */
|
|
|
free($3);
|
|
@@ -476,10 +477,10 @@ write_statement : WRITE LPAR exp RPAR
|
|
|
}
|
|
|
;
|
|
|
|
|
|
-exp: NUMBER { $$ = create_expression ($1, 1, IMMEDIATE); }
|
|
|
- | UNDEF { $$ = create_expression (0, 0, IMMEDIATE); }
|
|
|
- | PLUSINFTY { $$ = create_expression (1, -1, IMMEDIATE); }
|
|
|
- | MINUSINFTY { $$ = create_expression (2, -1, IMMEDIATE); }
|
|
|
+exp: NUMBER { $$ = create_expression_inf ($1, 1, IMMEDIATE); }
|
|
|
+ | UNDEF { $$ = create_expression_inf (0, 0, IMMEDIATE); }
|
|
|
+ | PLUSINFTY { $$ = create_expression_inf (1, -1, IMMEDIATE); }
|
|
|
+ | MINUSINFTY { $$ = create_expression_inf (2, -1, IMMEDIATE); }
|
|
|
| IDENTIFIER {
|
|
|
int location, infty;
|
|
|
|
|
@@ -489,7 +490,7 @@ exp: NUMBER { $$ = create_expression ($1, 1, IMMEDIATE); }
|
|
|
|
|
|
/* return the register location of IDENTIFIER as
|
|
|
* a value for `exp' */
|
|
|
- $$ = create_expression (location, infty, REGISTER);
|
|
|
+ $$ = create_expression_inf (location, infty, REGISTER);
|
|
|
|
|
|
/* free the memory associated with the IDENTIFIER */
|
|
|
free($1);
|
|
@@ -559,7 +560,7 @@ exp: NUMBER { $$ = create_expression ($1, 1, IMMEDIATE); }
|
|
|
$$ = handle_binary_comparison (program, $1, $3, _GT_);
|
|
|
}
|
|
|
| exp EQ exp {
|
|
|
-` if (($1.expression_type == IMMEDIATE) &&
|
|
|
+ if (($1.expression_type == IMMEDIATE) &&
|
|
|
($3.expression_type == IMMEDIATE)) {
|
|
|
int undef = ($1.infty * $3.infty != 0);
|
|
|
int value = (($1.infty + $3.infty) * ($1.value == $3.value)) != 0;
|