簡體   English   中英

SonarQube的庫中的nextNot函數到底做什么?

[英]What does exactly the nextNot function do in SonarQube's library?

您可以在此處看到函數的定義:

* 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是一個函數。

nextNot是一種否定匹配。 在您突出顯示的示例中,當print后跟(時, PRINT_STMT不匹配。

在Python 3中對print函數的調用應匹配EXPRESSION_STMT

注意: nextNotSSLR庫的一部分,該獨立於SonarQube。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM