-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Never run parser if there are lexer errors (#179)
The OQ3 parser does lexer -> parser (to ast) -> semantic analysis We want to impose a couple of invariants that were not in place in the r-a code: 1. If there are any lexing errors, parsing is not performed 2. If there are any parsing (to ast) errors, then semantic analysis is not performed. This commit implements item number 1. We follow r-a in pushing lexing and parsing errors onto a single vector. However, because of rule 1, the errors in this vector will be either all lexer errors or all parser errors. The semantic analysis code receives a structure representing a parsed file (actually a structure including parsed included files) and errors. If there are any errors, semantic analysis is aborted. At the level of the semantic analysis, there is no need to check whether the errors returned are from lexing or parsing (and therefore whether there is any parse tree at all). The immediate impetus for this PR is that pragma statements in which "#pragma" is misspelled are processed as tokens `InvalidIdent` and a lexing error is recorded. Previously, lexing and parsing errors were lumped together and parsing always proceeded. This would result in spurious parser errors added to the lexer error. Rather than changing the parser (to ast) to recover from lexer errors, we don't allow the parser to see lexer errors. If the parser detects a lexer error, it should throw an error.
- Loading branch information
Showing
8 changed files
with
145 additions
and
29 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
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