summaryrefslogtreecommitdiffhomepage
path: root/cpp.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-03-21 22:11:57 +0100
committerRoland Reichwein <mail@reichwein.it>2020-03-21 22:11:57 +0100
commit365183e243d164185bca6ad9fa4e0d75664800f4 (patch)
treee488e99f78551773518c2fb946cbd165bb6a8c90 /cpp.cpp
parentcdf001920fde6652b344775589b0524ff6529809 (diff)
C++ grammer (WIP)
Diffstat (limited to 'cpp.cpp')
-rw-r--r--cpp.cpp86
1 files changed, 81 insertions, 5 deletions
diff --git a/cpp.cpp b/cpp.cpp
index d877564..69ca847 100644
--- a/cpp.cpp
+++ b/cpp.cpp
@@ -99,7 +99,85 @@ namespace {
std::unordered_set<std::string> keywords {
"alignas",
"alignof",
- // ... Keywords table, p.15
+ "asm",
+ "auto",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "char8_t",
+ "char16_t",
+ "char32_t",
+ "class",
+ "concept",
+ "const",
+ "consteval",
+ "constexpr",
+ "constinit",
+ "const_cast",
+ "continue",
+ "co_await",
+ "co_return",
+ "co_yield",
+ "decltype",
+ "default",
+ "delete",
+ "do",
+ "double",
+ "dynamic_cast",
+ "else",
+ "enum",
+ "explicit",
+ "export",
+ "extern",
+ "false",
+ "float",
+ "for",
+ "friend",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "noexcept",
+ "nullptr",
+ "operator",
+ "private",
+ "protected",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "requires",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "static_assert",
+ "static_cast",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "thread_local",
+ "throw",
+ "true",
+ "try",
+ "typedef",
+ "typeid",
+ "typename",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
};
}
@@ -119,12 +197,10 @@ std::vector<Token> CPP::tokens_from_pptokens(std::vector<Token> pp_tokens)
for (auto& token: pp_tokens) {
if (pp_types.find(token.type) != pp_types.end()) {
if (token.type == "identifier") {
-#if 0
if (keywords.find(token.value) != keywords.end())
- result.emplace_back("keyword", token.value);
+ result.emplace_back(token.value, token.value);
else
-#endif
- result.emplace_back(Token{"identifier"s, token.value});
+ result.emplace_back(Token{"identifier"s, token.value});
}
else if (token.type == "preprocessing-op-or-punc")
result.emplace_back(Token{token.value, token.value});