I am extremely confused. I have an error in my file and funcBodyLoop2 error aEOS
is NOT used.
Why? This is what is bothering me. funcBodyLoop2 has an empty rule so it can never fail. And to fail funcBodyLoop2 must reduce at least once before it can attempt to run the rule | funcBodyLoop2 funcBody
By looking at these rules the only place it can get an error is funcBody. So i added | funcBodyLoop2 error aEOS
(aEOS checks of one or more end of statements, which are newlines and ';'). So since funcBodyLoop2 is already reduce should the error always be at | funcBodyLoop2 error aEOS
? Running it i always got reduce to a rule further back then i wanted. I end up writing | error aEOS
just to see what happens and i see funcBodyLoop2 b being reported after my error.
My question is, why is it using that rule or not using funcBodyLoop2 error aEOS
. I dont understand.
funcBodyLoop2:
| funcBodyLoop2 funcBody
| funcBodyLoop2 error aEOS { doerror("funcBodyLoop2", YYRECOVERING()); yyclearin; yyerrok; }
| error aEOS { doerror("funcBodyLoop2 b", YYRECOVERING()); yyclearin; yyerrok; }
funcBody:
funcBodyA
| funcBodyS mEOS
| funcBodyEs aEOS
| error aEOS { doerror("funcBody", YYRECOVERING()); yyclearin; yyerrok; }
error
is completely unlike a normal terminal in what it does, so its probably that you're confused as to what it does. Post a more complete grammar, the exact input that is not doing what you expect, and what you expect to happen. – Chris DoddfuncBodyLoop2 funcBody
to be caught and handled in| funcBodyLoop2 error aEOS
and to keep looping inside of funcBodyLoop2 but that isnt the case – user34537