I am currently writing the parser for a compiler of a toy language
using Happy & Alex. Since some form of optional layout is required I have to change
Alex's state before matching the block
non-terminal. Unfortunately
it seems that the lookahead token required by Happy is read before
I have the chance to change Alex's state.
Here is a small snippet demonstrating the problem:
funcDef : header localDefs block
^ I have to change alex's state
before the underlying lexer
starts reading the block tokens.
Is there a common approach to this problem ?