In many cases, getParser().Lex()
and getLexer().Lex()
are anti-patterns. If you do
if (!f(...))
return ...;
getLexer().Lex();
Consider moving Lex
into the body of f
:
if (!f(...))
return ...;
parseToken
or parseOptionalToken
are useful. There is some complexity if one wants to track precise SMLoc
, though.
I have landed some commits to remove a lot of getLexer().Lex()
(XXX Use parseOptionalToken. NFC
).
Many targets don’t appear to test the error code paths (rg '\[\[#@LINE\+1' test/MC
for some examples). I hope that the owners can improve the situation.