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

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 15 06:06:42 PDT 2022


hokein added inline comments.


================
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;
----------------
sammccall wrote:
> I hope you mean kw_int? I'd like this to compile :-)
> 
> Can you also give the example for IDENTIFIER?
As discussed offline, we stick to the current version without `kw_` prefix. Added some comments for this decision.


================
Comment at: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp:48
 
+std::string Grammar::mangleSymbol(SymbolID SID) const {
+  static const char *const TokNames[] = {
----------------
sammccall wrote:
> 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?
Yeah, these functions are only used in the codegen. I'm inlined to the put it into the `Grammar`(it also has a `symbolName` definition, I'd prefer to have all naming functions in a single place). 


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