Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyParsaging OperatorRecessence:能够将parseAction添加到括号块_Python_Pyparsing_Operator Precedence - Fatal编程技术网

Python PyParsaging OperatorRecessence:能够将parseAction添加到括号块

Python PyParsaging OperatorRecessence:能够将parseAction添加到括号块,python,pyparsing,operator-precedence,Python,Pyparsing,Operator Precedence,我有一个非常简单的解析器来实现布尔函数,其中我为不同的操作添加了类作为parseAction parseExpr = pp.operatorPrecedence(term, [ (not_, 1, pp.opAssoc.RIGHT, ClassNotOperation), (pp.Optional(and_, default="AND"), 2, pp.opAssoc.LEFT, ClassAndOperation),

我有一个非常简单的解析器来实现布尔函数,其中我为不同的操作添加了类作为parseAction

parseExpr = pp.operatorPrecedence(term,
           [
              (not_, 1, pp.opAssoc.RIGHT, ClassNotOperation),
              (pp.Optional(and_, default="AND"), 2, pp.opAssoc.LEFT, ClassAndOperation),
              (or_, 2, pp.opAssoc.LEFT, ClassOrOperation),
           ])
这有助于我按照正确的顺序分析以下内容

(A或B)及C


但是,如果我想在块级别添加一些操作,是否有任何方法可以将parseActions附加到圆括号块?

不使用标准API。如果您想执行一个特殊版本的
OperatorRecessence
(现在重命名为
infixNotation
),请将该例程从Python代码中复制到本地脚本中,并进行所需的任何修改