From ca1f69757421845f563ebe90a5880509839efb31 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 31 Jul 2018 20:20:50 +0200 Subject: Fix grammar for ES modules * Always parse 'import' as a keyword, as it is now one in Qml and ES. * Always parse 'as' as keyword but allow it as identifier using the same trick as for the other keywords. This fixes basic import statements such as import "foo.mjs" as bar but still allows funny variations such as import "foo.mjs" as as. Change-Id: I76a600aab90c1b5c07d079bf11b0a78742d44c53 Reviewed-by: Lars Knoll --- src/qml/parser/qqmljskeywords_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/parser/qqmljskeywords_p.h') diff --git a/src/qml/parser/qqmljskeywords_p.h b/src/qml/parser/qqmljskeywords_p.h index 40094ecdf8..b0a4951ece 100644 --- a/src/qml/parser/qqmljskeywords_p.h +++ b/src/qml/parser/qqmljskeywords_p.h @@ -60,7 +60,7 @@ namespace QQmlJS { static inline int classify2(const QChar *s, int parseModeFlags) { if (s[0].unicode() == 'a') { if (s[1].unicode() == 's') { - return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_AS : Lexer::T_IDENTIFIER; + return Lexer::T_AS; } } else if (s[0].unicode() == 'd') { @@ -432,7 +432,7 @@ static inline int classify6(const QChar *s, int parseModeFlags) { if (s[3].unicode() == 'o') { if (s[4].unicode() == 'r') { if (s[5].unicode() == 't') { - return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_IMPORT) : int(Lexer::T_RESERVED_WORD); + return Lexer::T_IMPORT; } } } -- cgit v1.2.3