nextNot函数在SonarQube的库中到底做什么?

2024-10-03 09:17:41 发布

您现在位置:Python中文网/ 问答频道 /正文

您可以在这里看到函数的定义:

* Creates parsing expression - "next not".
* During execution of this expression parser will execute sub-expression once.
* This expression succeeds only if sub-expression fails.
*
* @param e  sub-expression
* @throws IllegalArgumentException if given argument is not a parsing expression
*/
public final Object nextNot(Object e) {
return new NextNotExpression(convertToExpression(e));
}

如果我理解正确,如果看到对象e,它将失败

然而,我正在研究SonarQube的Python语法,并且PRINT_EXP是这样的:

b.rule(PRINT_STMT).is("print", b.nextNot("("), b.firstOf( 
  b.sequence(">>", TEST, b.optional(b.oneOrMore(",", TEST), b.optional(","))), 
  b.optional(TEST, b.zeroOrMore(",", TEST), b.optional(","))));

这是否意味着,如果看到括号,将被视为失败? 因为在python3.x中,print是一个函数


Tags: 函数testif定义objectisnotoptional
1条回答
网友
1楼 · 发布于 2024-10-03 09:17:41

nextNot是一种负匹配。在您突出显示的示例中,PRINT_STMTprint后跟(时不匹配

对python3中print函数的调用应该匹配EXPRESSION_STMT

注:nextNotSSLR library的一部分,它独立于SonarQube

相关问题 更多 >