-
Notifications
You must be signed in to change notification settings - Fork 439
Parse hashbang as a child of SourceFileSyntax
#1979
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
Parse hashbang as a child of SourceFileSyntax
#1979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me. One general note: I think the standard term here is Shebang instead of hashbang.
8f39f7a
to
99152e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, one more general comment: Could you add an assertParse
text for the shebang? You might need to adjust BasicFormat.requiresNewline
as well to make sure it adds a newline after the shebang.
99152e4
to
605a5b8
Compare
I think we already have an |
Oh, I didn’t see that. Thanks for pointing it out |
@swift-ci Please test |
I created a corresponding pr in swiftlang/swift-format#590. Could you trigger CI again? |
@swift-ci please test |
@swift-ci please test |
Resolves #1825.
Instead of parsing hashbang into a token list, I think the easier way is to parse the whole as an identifier-like token since we don't care about the content of it.
Also, we could make use of
Lexer.Cursor.advanceToEndOfLine
to lex the first line as a hashbang token instead of doing this in the parser.What do you think about it?