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

时间:2019-07-05 12:28:45

标签: python sonarqube

您可以在此处看到函数的定义:

* 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(","))));

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

1 个答案:

答案 0 :(得分:0)

nextNot是一种否定匹配。在您突出显示的示例中,当PRINT_STMT后跟print时,(不匹配。

在Python 3中对print函数的调用应与EXPRESSION_STMT相匹配。

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