[clang] 7f99e18 - [pseudo] Add a print-grammar option in the tool

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 2 01:06:06 PST 2022


Author: Haojian Wu
Date: 2022-03-02T10:05:49+01:00
New Revision: 7f99e1870f776a25e03526e3190105c094750d98

URL: https://github.com/llvm/llvm-project/commit/7f99e1870f776a25e03526e3190105c094750d98
DIFF: https://github.com/llvm/llvm-project/commit/7f99e1870f776a25e03526e3190105c094750d98.diff

LOG: [pseudo] Add a print-grammar option in the tool

This is helpful for debugging purposes.

Differential Revision: https://reviews.llvm.org/D120724

Added: 
    

Modified: 
    clang/tools/clang-pseudo/ClangPseudo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-pseudo/ClangPseudo.cpp b/clang/tools/clang-pseudo/ClangPseudo.cpp
index 2d6fbdb83944c..59db927d8e081 100644
--- a/clang/tools/clang-pseudo/ClangPseudo.cpp
+++ b/clang/tools/clang-pseudo/ClangPseudo.cpp
@@ -24,6 +24,7 @@ using llvm::cl::opt;
 
 static opt<std::string>
     Grammar("grammar", desc("Parse and check a BNF grammar file."), init(""));
+static opt<bool> PrintGrammar("print-grammar", desc("Print the grammar."));
 static opt<bool> PrintGraph("print-graph",
                             desc("Print the LR graph for the grammar"));
 static opt<bool> PrintTable("print-table",
@@ -60,6 +61,8 @@ int main(int argc, char *argv[]) {
     }
     llvm::outs() << llvm::formatv("grammar file {0} is parsed successfully\n",
                                   Grammar);
+    if (PrintGrammar)
+      llvm::outs() << G->dump();
     if (PrintGraph)
       llvm::outs() << clang::syntax::pseudo::LRGraph::buildLR0(*G).dumpForTests(
           *G);


        


More information about the cfe-commits mailing list