I am trying to make a CFG that is equivalent the function below. I know that B is the loop counter so it could be a series of elements pushed onto a stack, every time the loop is completed an element from B is popped and if B = Epsilon quit. How do I handle the addition in the top half of the while loop?
PROCEDURE multiply a, b;
VAR a, b, z;
BEGIN
z := 0;
WHILE b > 0 DO BEGIN
z := a + z;
b := b - 1;
END
RETURN z;
END;