-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fake-eof and related behavior in lex/parse
Lexer is now sending explicit tFAIL token after error. That token is interpreted in the parser accordingly. The assumption is that, contrary to parse errors, it doesn't make sense to continue processing input after a lex error, as there's usually a cascade of mess afterwards. Even if I could do better than this assumption, that's the silent behavior of previous code, which was misbehaving anyway - see below. In addition to sending tFAIL token by lexer and interpreting it in the parser (eg. there are two final tokens now, examined by parser.matchEnd and parser.checkEnd; the error printing is fixed as well), there is also a check inside block parsing to return earlier after tFAIL. This can be extended in the future for other parts of the parser. Now about a previous subtle bug: tEOF after tERR was read by parser.advance only because it was zero-value from closed channel. It could be seen as 'line 1:1: error at end: ...' error message, even though 1:1 is definitely not end of the stream. Parser was relying on this behavior, so for example after starting tokens with iota+1 it went into infinite loop.
- Loading branch information
Showing
5 changed files
with
89 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.