Thank you for all your answers. The language I am trying to implement
is quite complex, unfortunately. It has various --and also optional--
block-like structures. Hence I personally would prefer setting the
context variable for the lexer, over rearranging the whole grammar just
for this nagging
Your solution attempts to modify lexer state from the parser,
which ties you to what would, ideally, be the implementation-dependent
details of precisely when the parser invokes the lexer.
Also seems like your solution only catches one side of the issue,
if I've understood it correctly.
AFAIK, bis