summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Parser.h
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-10-24 13:30:57 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-24 16:34:01 +0200
commit4fb96afafc6e87b75d2e310f949b0ca7b337b050 (patch)
treee654afea4bc7dd536d3d0b46182a3ed477e57fc2 /Libraries/LibJS/Parser.h
parent9f036959e867e52bbec12a384e00f21ee0a07be2 (diff)
downloadserenity-4fb96afafc6e87b75d2e310f949b0ca7b337b050.zip
LibJS: Support LegacyOctalEscapeSequence in string literals
https://tc39.es/ecma262/#sec-additional-syntax-string-literals The syntax and semantics of 11.8.4 is extended as follows except that this extension is not allowed for strict mode code: Syntax EscapeSequence:: CharacterEscapeSequence LegacyOctalEscapeSequence NonOctalDecimalEscapeSequence HexEscapeSequence UnicodeEscapeSequence LegacyOctalEscapeSequence:: OctalDigit [lookahead ∉ OctalDigit] ZeroToThree OctalDigit [lookahead ∉ OctalDigit] FourToSeven OctalDigit ZeroToThree OctalDigit OctalDigit ZeroToThree :: one of 0 1 2 3 FourToSeven :: one of 4 5 6 7 NonOctalDecimalEscapeSequence :: one of 8 9 This definition of EscapeSequence is not used in strict mode or when parsing TemplateCharacter. Note It is possible for string literals to precede a Use Strict Directive that places the enclosing code in strict mode, and implementations must take care to not use this extended definition of EscapeSequence with such literals. For example, attempting to parse the following source text must fail: function invalid() { "\7"; "use strict"; }
Diffstat (limited to 'Libraries/LibJS/Parser.h')
-rw-r--r--Libraries/LibJS/Parser.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/Libraries/LibJS/Parser.h b/Libraries/LibJS/Parser.h
index 007e8b6879..565f3ff704 100644
--- a/Libraries/LibJS/Parser.h
+++ b/Libraries/LibJS/Parser.h
@@ -87,7 +87,7 @@ public:
NonnullRefPtr<RegExpLiteral> parse_regexp_literal();
NonnullRefPtr<ObjectExpression> parse_object_expression();
NonnullRefPtr<ArrayExpression> parse_array_expression();
- NonnullRefPtr<StringLiteral> parse_string_literal(Token token);
+ NonnullRefPtr<StringLiteral> parse_string_literal(Token token, bool in_template_literal = false);
NonnullRefPtr<TemplateLiteral> parse_template_literal(bool is_tagged);
NonnullRefPtr<Expression> parse_secondary_expression(NonnullRefPtr<Expression>, int min_precedence, Associativity associate = Associativity::Right);
NonnullRefPtr<CallExpression> parse_call_expression(NonnullRefPtr<Expression>);
@@ -184,6 +184,7 @@ private:
bool m_in_function_context { false };
bool m_in_break_context { false };
bool m_in_continue_context { false };
+ bool m_string_legacy_octal_escape_sequence_in_scope { false };
explicit ParserState(Lexer);
};