我正在使用pyparsing.OperatorReceidence解析中缀表示法查询。代码是
filterExpr = pp.quotedString.setParseAction(pp.removeQuotes) |\
pp.Word(pp.printables, excludeChars="()")
searchTerm = (~and_ + ~or_ + ~not_) + filterExpr
searchExpr = pp.operatorPrecedence(
searchTerm,
[
(not_, 1, pp.opAssoc.RIGHT, SearchNotOperation),
(pp.Optional(and_, default="AND"), 2, pp.opAssoc.LEFT, SearchAndOperation),
(or_, 2, pp.opAssoc.LEFT, SearchOrOperation),
])
这将解析诸如'(foo bar)或baz'之类的表达式,但在边缘大小写时失败,其中提供了空字符串或空方括号“()”。 我如何解决这个问题?在
目前没有回答
相关问题 更多 >
编程相关推荐