[PATCH] D125911: [pseudo] (trivial) bracket-matching
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 20 14:19:34 PDT 2022
sammccall added inline comments.
================
Comment at: clang-tools-extra/pseudo/unittests/BracketTest.cpp:103
+TEST(Bracket, SimplePair) {
+ verifyBrackets("^{ ^[ ^( ^) ^( ^) ^] ^}");
+ verifyBrackets(") ^{ ^[ ^] ^} (");
----------------
hokein wrote:
> 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^)`?)
> I think in the near future, we would need more to verify that e.g. which two brackets are paired.
I thought about the simplest way to specify these tests, and I think the `^` is sufficient.
The combination of:
a) the set of brackets that are paired
b) for each bracket, knowing whether it is paired forwards or backwards
c) certainty that brackets are well-nested
fully determines the bracket pairing.
The test specifies a) and we check it, and b) and c) can be verified with no extra information.
Does this make sense? It's a little implicit, but makes the testcases much more readable than having to specifiy `$1^` etc.
If so, I'll explain this in a comment.
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