From 207f2b216c5937c737f46bf2aacebaef93c3ffb3 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 8 Feb 2023 17:18:13 +0100 Subject: CPlusPlus: Add lexer support for new C++20 keywords Change-Id: I2b83deb0502ebf2cdca2af774fbb2ce26e947c11 Reviewed-by: Christian Stenger --- src/libs/3rdparty/cplusplus/Keywords.cpp | 104 +++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-) (limited to 'src/libs/3rdparty/cplusplus/Keywords.cpp') diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp index 1637333b420..a60ec24aec9 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; + } + } + } + } } } } -- cgit v1.2.3