Implement translation phase 2#7
Open
newcomb-luke wants to merge 2 commits intodevelopfrom
Open
Conversation
TroyNeubauer
approved these changes
Feb 25, 2022
| // we had an error or not after lexing is complete | ||
| let mut had_error = false; | ||
|
|
||
| // This keeps track of if we are in a multi-line comment, which will have to be removed at this |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Translation phase 2 is specified as a set of operations on the token stream in the C specification. Translation phase 2 in the spec is described as:
Each instance of a backslash character ( ) immediately followed by a new-line
character is deleted, splicing physical source lines to form logical source lines.
Only the last backslash on any physical source line shall be eligible for being part
of such a splice. A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character before any such
splicing takes place.
In our phase 2, we also remove single-line comments, while multi-line comments are removed during the lexing stage.