[PATCH] D125911: [pseudo] (trivial) bracket-matching

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 13:46:03 PDT 2022


hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, this looks a good start version!



================
Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Bracket.h:9
+//
+// Bracket structure (particularly brackes) is key to isolating broken regions
+// of code and preventing parsing from going "off the rails".
----------------
brackes => braces


================
Comment at: clang-tools-extra/pseudo/lib/Bracket.cpp:84
+// Find brackets in the stream and convert to Bracket struct.
+std::vector<Bracket> parseBrackets(const TokenStream &Stream) {
+  std::vector<Bracket> Brackets;
----------------
this is not really parsing, maybe `findBrackets`?


================
Comment at: clang-tools-extra/pseudo/unittests/BracketTest.cpp:103
+TEST(Bracket, SimplePair) {
+  verifyBrackets("^{ ^[ ^( ^)  ^( ^) ^] ^}");
+  verifyBrackets(") ^{ ^[ ^] ^} (");
----------------
For this simple case, just using `^` is fine.

I think in the near future, we would need more to verify that e.g. which two brackets are paired. And since we're defining some  some common functions used by the tests, I wonder what's the plan here (using something like `{ $1^( $1^)`?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125911



More information about the cfe-commits mailing list