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/qqmljs.g | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml/parser/qqmljs.g') diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index c5aabeaa01..4c5748f818 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -119,7 +119,7 @@ %token T_FOR_LOOKAHEAD_OK "(for lookahead ok)" --%left T_PLUS T_MINUS -%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET T_OF T_STATIC T_FROM +%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY T_ON T_SET T_GET T_OF T_STATIC T_FROM T_AS %nonassoc REDUCE_HERE %start TopLevel @@ -1366,6 +1366,7 @@ JsIdentifier: T_SET; JsIdentifier: T_FROM; JsIdentifier: T_STATIC; JsIdentifier: T_OF; +JsIdentifier: T_AS; IdentifierReference: JsIdentifier; BindingIdentifier: IdentifierReference; @@ -1848,6 +1849,7 @@ ReservedIdentifier: T_WITH; ReservedIdentifier: T_CLASS; ReservedIdentifier: T_EXTENDS; ReservedIdentifier: T_EXPORT; +ReservedIdentifier: T_IMPORT; ComputedPropertyName: T_LBRACKET AssignmentExpression_In T_RBRACKET; /. -- cgit v1.2.3