diff --git a/src/org/mozilla/javascript/TokenStream.java b/src/org/mozilla/javascript/TokenStream.java index 15ad0ae5a0..2e5292d5ba 100644 --- a/src/org/mozilla/javascript/TokenStream.java +++ b/src/org/mozilla/javascript/TokenStream.java @@ -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; diff --git a/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java b/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java index db31713b23..70ee634479 100644 --- a/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java +++ b/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java @@ -116,7 +116,6 @@ public class Test262SuiteTest { "String.prototype.matchAll", "Symbol.matchAll", "tail-call-optimization", - "hashbang", "u180e")); static { diff --git a/testsrc/test262.properties b/testsrc/test262.properties index 23251c6462..30b5b4c2af 100644 --- a/testsrc/test262.properties +++ b/testsrc/test262.properties @@ -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]}