diff options
author | Adam Strzelecki <ono@java.pl> | 2014-11-02 14:42:23 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-02-17 09:45:34 +0000 |
commit | 425811291dfd41782cc91f6c1293d41af7b0e4d8 (patch) | |
tree | c730fb107d9b040248230d688790b45a08741be8 /src/libs/3rdparty/cplusplus/Token.h | |
parent | 5699991a2fd4ef35d24720249692612d069d391b (diff) |
C++: Basic support for C++11 user-defined literals
1. Extends lexer so digit or string can be followed by underscore '_' and
alphanumeric defining literal.
2. Extends parser so it accepts operator"" _abc(...) user-defined literal
definition.
3. Adds Token::Flags.userDefinedLiteral bool flag field representing if token
carries user-defined literal.
4. Adds C++11 auto tests case with: 12_km, 0.5_Pa, 'c'_X, "abd"_L, u"xyz"_M
5. All optional suffix scanning methods now return boolean if the suffix was
found.
6. Adds C++ Lexer tests for user-defined literals with C++11 feature enabled.
This change however does not make QtCreator understand user-defined literal
semantics, e.g. properly resolve type when applying custom literal operator.
Change-Id: I30e62f025ec9fb11c39261985ea4d772b1a80949
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Token.h')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Token.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index c3c6b37b6d..1f18c652c9 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -302,6 +302,7 @@ public: inline bool joined() const { return f.joined; } inline bool expanded() const { return f.expanded; } inline bool generated() const { return f.generated; } + inline bool userDefinedLiteral() const { return f.userDefinedLiteral; } inline unsigned bytes() const { return f.bytes; } inline unsigned bytesBegin() const { return byteOffset; } @@ -363,8 +364,11 @@ public: // Tokens '1', '+', '2', and ';' are all expanded. However only tokens '+' and ';' // are generated. unsigned generated : 1; + // The token is C++11 user-defined literal such as: + // 12_km, 0.5_Pa, 'c'_X, "abd"_L, u16"xyz"_M + unsigned userDefinedLiteral : 1; // Unused... - unsigned pad : 3; + unsigned pad : 2; // The token length in bytes and UTF16 chars. unsigned bytes : 16; unsigned utf16chars : 16; |