StefanoMunari/FAC

Decide how to treat statement with no effect

Closed this issue · 1 comments

We should decide where and how to treat statement with no effect.

If we parse them and then simply ignore them during the syntactic analysis, we encounter problems in the if and while TAC generation, because we assume that the body of the statements and especially of the if is not NULL.

I have two solution' proposals:

  1. Avoid sintactically the statement --> stmt expr SEPARATOR. The advantage of this solution is that it does not affect the rest of the program.
  2. Solve them during TYPE-checking so that we can accept this kind of statement and then remove dead code. Advantage: gcc like and more powerful - Disadvantage we have to modify (massively??) the type checker to control if the bodies of if and while are not empty

I vote for the simpler/faster one, so 1.