-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fixed the SHEBANG detection #4290
base: master
Are you sure you want to change the base?
Conversation
Added a check for non '[' character before continuing with SHEBANG lexing See https://doc.rust-lang.org/stable/reference/input-format.html#shebang-removal
There was a small issue regarding the Cpp and CSharp language specific changes. Should be fixed now. |
rust/RustLexer.g4
Outdated
@@ -133,7 +133,9 @@ OUTER_BLOCK_DOC: | |||
|
|||
BLOCK_COMMENT_OR_DOC: ( BLOCK_COMMENT | INNER_BLOCK_DOC | OUTER_BLOCK_DOC) -> channel (HIDDEN); | |||
|
|||
SHEBANG: {this.SOF()}? '\ufeff'? '#!' ~[\r\n]* -> channel(HIDDEN); | |||
SHEBANG: {this.SOF()}? '\ufeff'? '#!' {this._input.LA(1) != 97}? ~[\r\n]* -> channel(HIDDEN); |
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.
Strictly speaking, this is not "target agnostic" (#4286 (comment)) because !=
is a target-specific operator. The entire expression should go in a base class, which is already done for both lexer and parser. Please add a "is...()" method, reference that here, and implement the methods for each of the targets.
In Rust a shebang is only if the '#!' is not followed by a '['. I added an action to fix it. If it is possible to do it with normal ANTLR, I don't know how.