I was reading a book about compiler design, then in the CFG section, they introduced the dangling-else problem. They offered to match the the `else` with the last `if`. I still don't see how this solves the problem. Can somebody give me an explanation? 

I searched before I put the question and none answered my question

[![enter image description here](https://i.stack.imgur.com/d0J04.jpg)](https://i.stack.imgur.com/d0J04.jpg)