1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:28:13 +00:00

LibJS: Add a mode to parse JS as a module

In a module strict mode should be enabled at the start of parsing and we
allow import and export statements.
This commit is contained in:
davidot 2021-08-14 17:30:37 +02:00 committed by Linus Groh
parent d6d7d11590
commit 7613c22b06
8 changed files with 38 additions and 15 deletions

View file

@ -330,11 +330,11 @@ bool Lexer::is_identifier_middle() const
bool Lexer::is_line_comment_start(bool line_has_token_yet) const
{
return match('/', '/')
|| match('<', '!', '-', '-')
|| (m_allow_html_comments && match('<', '!', '-', '-'))
// "-->" is considered a line comment start if the current line is only whitespace and/or
// other block comment(s); or in other words: the current line does not have a token or
// ongoing line comment yet
|| (match('-', '-', '>') && !line_has_token_yet)
|| (m_allow_html_comments && !line_has_token_yet && match('-', '-', '>'))
// https://tc39.es/proposal-hashbang/out.html#sec-updated-syntax
|| (match('#', '!') && m_position == 1);
}