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 04fe3be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/org/mozilla/javascript/TokenStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,12 @@ final int getToken() throws IOException {
case '`':
return Token.TEMPLATE_LITERAL;

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

default:
parser.addError("msg.illegal.character", c);
return Token.ERROR;
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 04fe3be

Please sign in to comment.