aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljslexer_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-03-02 10:21:12 +0100
committerLars Knoll <lars.knoll@qt.io>2018-04-25 17:49:52 +0000
commit4e18d38f164c215b24acdbe610d60b1c95eb4d3b (patch)
tree9e654e59940a9a745b2bd82b2ba5d65b462b7ec3 /src/qml/parser/qqmljslexer_p.h
parentf6754300e2fa9cd508d64a06879b9202d8e06730 (diff)
Add yield as a keyword
It's not a keyword outside of generator functions, so extend the qmlmode boolean on the lexer to become a more general parsemode that we can use to also turn the yield keyword on and of. The parser can then set the flag when it enters the body of a generator function. Change-Id: Ibf792d4c7c567d825c6706f7b4997362c87fc575 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljslexer_p.h')
-rw-r--r--src/qml/parser/qqmljslexer_p.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/qml/parser/qqmljslexer_p.h b/src/qml/parser/qqmljslexer_p.h
index 75afdf0e02..112f3b169a 100644
--- a/src/qml/parser/qqmljslexer_p.h
+++ b/src/qml/parser/qqmljslexer_p.h
@@ -121,10 +121,25 @@ public:
RegExp_Multiline = 0x04
};
+ enum ParseModeFlags {
+ QmlMode = 0x1,
+ YieldIsKeyword = 0x2
+ };
+
public:
Lexer(Engine *engine);
+ int parseModeFlags() const {
+ int flags = 0;
+ if (qmlMode())
+ flags |= QmlMode;
+ if (yieldIsKeyWord())
+ flags |= YieldIsKeyword;
+ return flags;
+ }
+
bool qmlMode() const;
+ bool yieldIsKeyWord() const { return _generatorLevel != 0; }
QString code() const;
void setCode(const QString &code, int lineno, bool qmlMode = true);
@@ -161,8 +176,11 @@ public:
BalancedParentheses
};
+ void enterGeneratorBody() { ++_generatorLevel; }
+ void leaveGeneratorBody() { --_generatorLevel; }
+
protected:
- int classify(const QChar *s, int n, bool qmlMode);
+ static int classify(const QChar *s, int n, int parseModeFlags);
private:
inline void scanChar();
@@ -229,6 +247,7 @@ private:
bool _followsClosingBrace;
bool _delimited;
bool _qmlMode;
+ int _generatorLevel = 0;
};
} // end of namespace QQmlJS