Another problem I have run into is sending data back when a
recursive call
is finished. If the input is a := (b + c) + d, the code I have is as
follows:
stmt : ref_name BL_ASSIGNMENT expr {
fprintf(ptrToIrFile, "mov %s %s\n",
$<blIdentifier>3,
$<blIdentifier>1);
}
expr : expr BL_ADDOP expr {
if(strcmp($<blOperator>2, "+"))
strcpy($<blOperator>2, "add");
else
strcpy($<blOperator>2, "sub");
char bufferT[6];
changeToString(++amtOfTemps, "T", bufferT);
fprintf(ptrToIrFile, "%s %s %s %s\n",
$<blOperator>2, $<blIdentifier>1, $<blIdentifier>3,
bufferT);
strcpy($<blIdentifier>1, bufferT);
}
| ( expr)
as long as there isn't ( expr ) in the input input move up without
problem.
However once input does have an ( expr) part, $<blIdentifier>1 at
the ADDOP
level has the value of $<blIdentifier>1 at the ASSIGNMENT level.
When I add
the following action to the ( expr ) production-
{strcpy($<blIdentifier>1,
$<blIdentifier>2);}, $<blIdentifier>1 at the ADDOP level has the
correct
value but then the $<blIdentifier>1 at the ASSIGNMENT level value is
what I
changed $<blIdentifier>1 to be at the ( expr ) level. I'm very
confused.