aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Keywords.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2023-02-08 17:18:13 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2023-02-09 13:19:53 +0000
commit207f2b216c5937c737f46bf2aacebaef93c3ffb3 (patch)
tree0532cad0e92a300fa48ae8755acf4e1d4145a0b8 /src/libs/3rdparty/cplusplus/Keywords.cpp
parentbb9e49274526a9b37207497af4f39b22132fa08f (diff)
CPlusPlus: Add lexer support for new C++20 keywords
Change-Id: I2b83deb0502ebf2cdca2af774fbb2ce26e947c11 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Keywords.cpp')
-rw-r--r--src/libs/3rdparty/cplusplus/Keywords.cpp104
1 files changed, 100 insertions, 4 deletions
diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp
index 1637333b42..a60ec24aec 100644
--- a/src/libs/3rdparty/cplusplus/Keywords.cpp
+++ b/src/libs/3rdparty/cplusplus/Keywords.cpp
@@ -603,6 +603,34 @@ static inline int classify7(const char *s, LanguageFeatures features)
}
}
}
+ else if (features.cxx20Enabled && s[0] == 'c') {
+ if (s[1] == 'h') {
+ if (s[2] == 'a') {
+ if (s[3] == 'r') {
+ if (s[4] == '8') {
+ if (s[5] == '_') {
+ if (s[6] == 't') {
+ return T_CHAR8_T;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[1] == 'o') {
+ if (s[2] == 'n') {
+ if (s[3] == 'c') {
+ if (s[4] == 'e') {
+ if (s[5] == 'p') {
+ if (s[6] == 't') {
+ return T_CONCEPT;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
else if (s[0] == 'd') {
if (s[1] == 'e') {
if (s[2] == 'f') {
@@ -847,7 +875,31 @@ static inline int classify8(const char *s, LanguageFeatures features)
}
}
else if (s[1] == 'o') {
- if (s[2] == 'n') {
+ if (features.cxx20Enabled && s[2] == '_') {
+ if (s[3] == 'a') {
+ if (s[4] == 'w') {
+ if (s[5] == 'a') {
+ if (s[6] == 'i') {
+ if (s[7] == 't') {
+ return T_CO_AWAIT;
+ }
+ }
+ }
+ }
+ }
+ else if (s[3] == 'y') {
+ if (s[4] == 'i') {
+ if (s[5] == 'e') {
+ if (s[6] == 'l') {
+ if (s[7] == 'd') {
+ return T_CO_YIELD;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[2] == 'n') {
if (s[3] == 't') {
if (s[4] == 'i') {
if (s[5] == 'n') {
@@ -945,6 +997,19 @@ static inline int classify8(const char *s, LanguageFeatures features)
}
}
}
+ else if (features.cxx20Enabled && s[2] == 'q') {
+ if (s[3] == 'u') {
+ if (s[4] == 'i') {
+ if (s[5] == 'r') {
+ if (s[6] == 'e') {
+ if (s[7] == 's') {
+ return T_REQUIRES;
+ }
+ }
+ }
+ }
+ }
+ }
}
}
else if (features.cxxEnabled && s[0] == 't') {
@@ -1097,13 +1162,35 @@ static inline int classify9(const char *s, LanguageFeatures features)
}
}
}
- else if (features.cxx11Enabled && s[0] == 'c') {
+ else if (s[0] == 'c') {
if (s[1] == 'o') {
- if (s[2] == 'n') {
+ if (features.cxx20Enabled && s[2] == '_') {
+ if (s[3] == 'r') {
+ if (s[4] == 'e') {
+ if (s[5] == 't') {
+ if (s[6] == 'u') {
+ if (s[7] == 'r') {
+ if (s[8] == 'n') {
+ return T_CO_RETURN;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (s[2] == 'n') {
if (s[3] == 's') {
if (s[4] == 't') {
if (s[5] == 'e') {
- if (s[6] == 'x') {
+ if (features.cxx20Enabled && s[6] == 'v') {
+ if (s[7] == 'a') {
+ if (s[8] == 'l') {
+ return T_CONSTEVAL;
+ }
+ }
+ }
+ else if (features.cxx11Enabled && s[6] == 'x') {
if (s[7] == 'p') {
if (s[8] == 'r') {
return T_CONSTEXPR;
@@ -1111,6 +1198,15 @@ static inline int classify9(const char *s, LanguageFeatures features)
}
}
}
+ else if (features.cxx20Enabled && s[5] == 'i') {
+ if (s[6] == 'n') {
+ if (s[7] == 'i') {
+ if (s[8] == 't') {
+ return T_CONSTINIT;
+ }
+ }
+ }
+ }
}
}
}