]> ocean-lang.org Git - ocean/commitdiff
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)
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>

No differences found