Relative Content

Tag Archive for ccompiler-errorsbisonlexstreet-address

program using bison that creates a sequence of simple steps

Write a program using bison that creates a sequence of simple steps (three-address code) according to a given grammar for arithmetic expressions. For example, if the input is- a + b * c + d
the program should print the output as-
T1 = b * c T2 = a + T1 T3 = T2 + d
[Hint: use a global variable, say t initialised to 1. Store its value as an attribute of the LHS grammar symbol whenever a reduce-action is performed for a simple arithmetic operation., and increment t (so that for the next use it has a different value). Use this attribute value whenever that symbol appears on the RHS for a subsequent reduce action. When printing print this value along with the letter T.]