1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibJS: Implement the 'Hashbang Grammar for JS' proposal

Stage 3 since August 2019 - we already have shebang stripping
implemented in js(1), so this removes it from there in favor of adding
support to the lexer directly.

Most straightforward proposal and implementation I've ever seen :^)

https://github.com/tc39/proposal-hashbang
This commit is contained in:
Linus Groh 2021-06-18 19:11:26 +01:00
parent 299c3069c1
commit 597cf88c08
3 changed files with 14 additions and 28 deletions

View file

@ -33,3 +33,12 @@ test("unterminated multi-line comment", () => {
expect("/* foo").not.toEval();
expect("foo /*").not.toEval();
});
test("hashbang comments", () => {
expect("#!").toEvalTo(undefined);
expect("#!/bin/js").toEvalTo(undefined);
expect("#!\n1").toEvalTo(1);
expect(" #!").not.toEval();
expect("\n#!").not.toEval();
expect("#!\n#!").not.toEval();
});