Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement translation phase 2 #7

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

newcomb-luke
Copy link
Collaborator

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.

@newcomb-luke newcomb-luke changed the base branch from master to develop February 25, 2022 14:30
@@ -24,6 +24,11 @@ pub fn lex(session: &Session, input_file: Rc<SourceFile>) -> LexResult {
// 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: long sentence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants