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/qqmljslexer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/parser/qqmljslexer.cpp') diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp index ae016076b8..86c8ac714c 100644 --- a/src/qml/parser/qqmljslexer.cpp +++ b/src/qml/parser/qqmljslexer.cpp @@ -1390,7 +1390,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error) lex(); // skip T_DOT - if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) + if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_IMPORT)) return true; // expected a valid QML/JS directive const QString directiveName = tokenText(); @@ -1484,7 +1484,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error) // // recognize the mandatory `as' followed by the module name // - if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("as") && tokenStartLine() == lineNumber)) { + if (! (lex() == T_AS && tokenStartLine() == lineNumber)) { if (fileImport) error->message = QCoreApplication::translate("QQmlParser", "File import requires a qualifier"); else -- cgit v1.2.3