]> ocean-lang.org Git - ocean/commit
parsergen: avoid infinite loop on error.
authorNeilBrown <neil@brown.name>
Sat, 10 Oct 2020 22:50:12 +0000 (09:50 +1100)
committerNeilBrown <neil@brown.name>
Sat, 10 Oct 2020 22:50:12 +0000 (09:50 +1100)
commit1e17521c96f4116042cdaf3cf2aac40284f6dec8
tree318142a0637e7078a33137c4435eb35d1c45ca91
parent2594d150e123c29949493c37c8b9c14aa6abe5a4
parsergen: avoid infinite loop on error.

If the grammar allows "ERROR" in a recursive location, error handling
can loop for every.
e.g.

 foo -> foo bar
 foo -> ERROR

Rather than detect and reject such grammars, detect the infinite loop
as it start, and discard an extra token.

i.e.  if error handling doesn't discard any tokens from the input
stream, and another error is triggered before anything is shifted, then
we force the next error handling phase to discard at least one token,
or to abort if that token is EOF.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/parsergen.mdc