diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-02-09 13:33:35 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-04-25 17:48:56 +0000 |
commit | dad5d1cc82a57a4f657aa3f37ad2f55b69d5b015 (patch) | |
tree | 1110fbbc2b15734533476c42ffcea2596f5f14f1 /src/qml/parser/qqmljsast_p.h | |
parent | 6d42c6fd3396ece5e74e602f7cdfc9c9299866bf (diff) |
Add support for ES6 template strings
This requires a bit of bookeeping in the lexer, as we can have
arbitrary expressions inside the ${...}. To make this work, keep
a stack of template states, in which we count the unclosed braces
to match up with the correct closing brace.
Implements support for `...`. Expressions of the type Foo`...`
and Foo()`...` will come in follow-up commits.
Change-Id: Ia332796cfb77895583d0093732e6f56c8b0662c9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r-- | src/qml/parser/qqmljsast_p.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index ed3c83badf..5f094ad4f5 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -188,6 +188,7 @@ public: Kind_StringLiteral, Kind_StringLiteralPropertyName, Kind_SwitchStatement, + Kind_TemplateLiteral, Kind_ThisExpression, Kind_ThrowStatement, Kind_TildeExpression, @@ -428,6 +429,29 @@ public: SourceLocation literalToken; }; +class QML_PARSER_EXPORT TemplateLiteral : public ExpressionNode +{ +public: + QQMLJS_DECLARE_AST_NODE(TemplateLiteral) + + TemplateLiteral(const QStringRef &str, ExpressionNode *e) + : value(str), expression(e), next(nullptr) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : literalToken; } + + void accept0(Visitor *visitor) override; + + QStringRef value; + ExpressionNode *expression; + SourceLocation literalToken; + TemplateLiteral *next; +}; + class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode { public: |