Jean Abou Samra <j...@abou-samra.fr> writes: > Le lundi 20 mars 2023 à 00:15 +0100, David Kastrup a écrit : > >> The MYBACKUP and MYPARSE stuff messes with the input in order to trigger >> syntactic decisions based on expression values. That's a bit more than >> usually expected from a Bison-generated parser. > > > Yes, I understand the basic way Bison parsers work. What I don't > understand is what other “effects” the lookahead can have, and why > having caused the reduction of the current rule is never a > problem. AFAIU, the parser works as a loop > > - Get next token from lexer. > > - Decide whether to shift or to reduce some rule. Use a lookahead > token if necessary. > > - Do the shift or the reduction and execute the semantic action. > > The lookahead token gets switched during the semantic action. Isn't it > a problem if the previous lookahead token says the current rule should > be reduced, but the new one would have required shifting? Or is that > just not a useful use of MYBACKUP/MYREPARSE?
Well, if you feel you should not touch that code until you confidently know the answer to that question, let me assure you that the principal justification for that code is that I needed it to work. The equivalent in football is called a "Hail Mary pass" I believe. -- David Kastrup