gpt4 book ai didi

regex - clang 格式正则表达式语法引用

转载 作者:行者123 更新时间:2023-12-05 00:54:26 24 4
gpt4 key购买 nike

我希望 clang-format 不修改我用来将函数彼此分开的注释行。我想 commentPragmas是正确的选择,但我找不到有关 clang-format regex 格式的信息。

我试过 commentPragmas: '^/\*-.*'捕获我的分隔线,看起来像这样
/*------------------------------------------------------------------*/
但是上面的正则表达式不起作用......我在哪里可以查找 clang-format 的正则表达式的语法?

最佳答案

TL/DR: The flavor is POSIX ERE



据我所知,正则表达式的味道没有记录在 ClangFormat docs 中。 ,这非常没有帮助。

让我们深入研究源代码以找出答案。

有一个名为 ContinuationIndenter 的类,其中有一个 CommentPragmasRegex字段,类型... llvm::Regex right here .好吧,这也不是很有帮助,但也许它只是一个包装器......

原来 llvm::Regex is a wrapper周围... llvm_regex .标题包括 this comment尽管:

This file implements a POSIX regular expression matcher. Both Basic and Extended POSIX regular expressions (ERE) are supported. EREs were extended to support backreferences in matches. This implementation also supports matching strings with embedded NUL chars.



header that defines llvm_regex 我们还可以找到这个评论:

This code is derived from OpenBSD's libc/regex

关于regex - clang 格式正则表达式语法引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39986368/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com