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

Support hashbang #1417

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/org/mozilla/javascript/TokenStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,15 @@ final int getToken() throws IOException {
return Token.STRING;
}

if (c == '#'
&& cursor == 1
&& peekChar() == '!'
&& !this.parser.calledByCompileFunction) {
// #! hashbang: only on the first line of a Script, no leading whitespace
skipLine();
return Token.COMMENT;
}

switch (c) {
case ';':
return Token.SEMI;
Expand Down
1 change: 0 additions & 1 deletion testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public class Test262SuiteTest {
"String.prototype.matchAll",
"Symbol.matchAll",
"tail-call-optimization",
"hashbang",
"u180e"));

static {
Expand Down
5 changes: 3 additions & 2 deletions testsrc/test262.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2712,8 +2712,9 @@ language/block-scope 68/145 (46.9%)
syntax/redeclaration/var-redeclaration-attempt-after-function.js
syntax/redeclaration/var-redeclaration-attempt-after-generator.js

language/comments 36/52 (69.23%)
hashbang 29/29 (100.0%)
language/comments 9/52 (17.31%)
hashbang/function-constructor.js
hashbang/module.js {unsupported: [module]}
mongolian-vowel-separator-multi.js {unsupported: [u180e]}
mongolian-vowel-separator-single.js {unsupported: [u180e]}
mongolian-vowel-separator-single-eval.js {unsupported: [u180e]}
Expand Down