Skip to content

Commit

Permalink
Support hashbang
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bakker committed Nov 4, 2023
1 parent f085d50 commit 88e2ebf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/org/mozilla/javascript/TokenStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,10 @@ final int getToken() throws IOException {
String str = getStringFromBuffer();
this.string = (String) allStrings.intern(str);
return Token.STRING;
} else 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) {
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

0 comments on commit 88e2ebf

Please sign in to comment.