[PATCH] D129359: [pseudo] Generate an enum type for identifying grammar rules.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 8 05:54:24 PDT 2022


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h:172
+  //   terminal `,` becomes `comma`;
+  //   terminal `INT` becomes `int`;
+  std::string mangleSymbol(SymbolID) const;
----------------
I hope you mean kw_int? I'd like this to compile :-)

Can you also give the example for IDENTIFIER?


================
Comment at: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp:48
 
+std::string Grammar::mangleSymbol(SymbolID SID) const {
+  static const char *const TokNames[] = {
----------------
I'm not sure exposing these from `Grammar` is an improvement, i think even in principle we'd only want to use these for codegen.

The need for testing is real, but i guess you can add a test that uses the CXX generated grammar, assert the elements of Rule::whatever, and the name of Symbol::whatever?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129359/new/

https://reviews.llvm.org/D129359



More information about the cfe-commits mailing list