[clang-tools-extra] fa0c763 - [pseudo] Add guards for module contextual keywords
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 18 13:39:50 PDT 2022
Author: Sam McCall
Date: 2022-07-18T22:38:41+02:00
New Revision: fa0c7639e91fa1cd0cf2ff0445a1634a90fe850a
URL: https://github.com/llvm/llvm-project/commit/fa0c7639e91fa1cd0cf2ff0445a1634a90fe850a
DIFF: https://github.com/llvm/llvm-project/commit/fa0c7639e91fa1cd0cf2ff0445a1634a90fe850a.diff
LOG: [pseudo] Add guards for module contextual keywords
Added:
Modified:
clang-tools-extra/pseudo/lib/cxx/CXX.cpp
clang-tools-extra/pseudo/lib/cxx/cxx.bnf
Removed:
################################################################################
diff --git a/clang-tools-extra/pseudo/lib/cxx/CXX.cpp b/clang-tools-extra/pseudo/lib/cxx/CXX.cpp
index e8de6821a05f5..9a03422153f06 100644
--- a/clang-tools-extra/pseudo/lib/cxx/CXX.cpp
+++ b/clang-tools-extra/pseudo/lib/cxx/CXX.cpp
@@ -33,11 +33,26 @@ bool guardFinal(llvm::ArrayRef<const ForestNode *> RHS,
RHS.front()->symbol() == tokenSymbol(clang::tok::identifier));
return Tokens.tokens()[RHS.front()->startTokenIndex()].text() == "final";
}
+bool guardModule(llvm::ArrayRef<const ForestNode *> RHS,
+ const TokenStream &Tokens) {
+ return Tokens.tokens()[RHS.front()->startTokenIndex()].text() == "module";
+}
+bool guardImport(llvm::ArrayRef<const ForestNode *> RHS,
+ const TokenStream &Tokens) {
+ return Tokens.tokens()[RHS.front()->startTokenIndex()].text() == "import";
+}
+bool guardExport(llvm::ArrayRef<const ForestNode *> RHS,
+ const TokenStream &Tokens) {
+ return Tokens.tokens()[RHS.front()->startTokenIndex()].text() == "export";
+}
llvm::DenseMap<ExtensionID, RuleGuard> buildGuards() {
return {
{(ExtensionID)Extension::Override, guardOverride},
{(ExtensionID)Extension::Final, guardFinal},
+ {(ExtensionID)Extension::Import, guardImport},
+ {(ExtensionID)Extension::Export, guardExport},
+ {(ExtensionID)Extension::Module, guardModule},
};
}
diff --git a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
index b80dfd928f2b4..08384af9d9399 100644
--- a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -748,10 +748,10 @@ pointer-literal := NULLPTR
#! Placeholders for literal text in the grammar that lex as other things.
contextual-override := IDENTIFIER [guard=Override]
contextual-final := IDENTIFIER [guard=Final]
-contextual-zero := NUMERIC_CONSTANT
-module-keyword := IDENTIFIER
-import-keyword := IDENTIFIER
-export-keyword := IDENTIFIER
+contextual-zero := NUMERIC_CONSTANT [guard=Zero]
+module-keyword := IDENTIFIER [guard=Module]
+import-keyword := IDENTIFIER [guard=Import]
+export-keyword := IDENTIFIER [guard=Export]
#! greatergreater token -- clang lexer always lexes it as a single token, we
#! split it into two tokens to make the GLR parser aware of the nested-template
More information about the cfe-commits
mailing list