Merge "Clean imports in code"
This commit is contained in:
commit
695abbe53a
@ -17,9 +17,6 @@ import ast
|
|||||||
import operator
|
import operator
|
||||||
|
|
||||||
import pyparsing
|
import pyparsing
|
||||||
from pyparsing import Literal
|
|
||||||
from pyparsing import OneOrMore
|
|
||||||
from pyparsing import Regex
|
|
||||||
|
|
||||||
|
|
||||||
def _all_in(x, *y):
|
def _all_in(x, *y):
|
||||||
@ -104,25 +101,25 @@ Example operations:
|
|||||||
|
|
||||||
unary_ops = (
|
unary_ops = (
|
||||||
# Order matters here (so that '=' doesn't match before '==')
|
# Order matters here (so that '=' doesn't match before '==')
|
||||||
Literal("==") | Literal("=") |
|
pyparsing.Literal("==") | pyparsing.Literal("=") |
|
||||||
Literal("!=") | Literal("<in>") |
|
pyparsing.Literal("!=") | pyparsing.Literal("<in>") |
|
||||||
Literal(">=") | Literal("<=") |
|
pyparsing.Literal(">=") | pyparsing.Literal("<=") |
|
||||||
Literal(">") | Literal("<") |
|
pyparsing.Literal(">") | pyparsing.Literal("<") |
|
||||||
Literal("s==") | Literal("s!=") |
|
pyparsing.Literal("s==") | pyparsing.Literal("s!=") |
|
||||||
# Order matters here (so that '<' doesn't match before '<=')
|
# Order matters here (so that '<' doesn't match before '<=')
|
||||||
Literal("s<=") | Literal("s<") |
|
pyparsing.Literal("s<=") | pyparsing.Literal("s<") |
|
||||||
# Order matters here (so that '>' doesn't match before '>=')
|
# Order matters here (so that '>' doesn't match before '>=')
|
||||||
Literal("s>=") | Literal("s>"))
|
pyparsing.Literal("s>=") | pyparsing.Literal("s>"))
|
||||||
|
|
||||||
all_in_nary_op = Literal("<all-in>")
|
all_in_nary_op = pyparsing.Literal("<all-in>")
|
||||||
or_ = Literal("<or>")
|
or_ = pyparsing.Literal("<or>")
|
||||||
|
|
||||||
# An atom is anything not an keyword followed by anything but whitespace
|
# An atom is anything not an keyword followed by anything but whitespace
|
||||||
atom = ~(unary_ops | all_in_nary_op | or_) + Regex(r"\S+")
|
atom = ~(unary_ops | all_in_nary_op | or_) + pyparsing.Regex(r"\S+")
|
||||||
|
|
||||||
unary = unary_ops + atom
|
unary = unary_ops + atom
|
||||||
nary = all_in_nary_op + OneOrMore(atom)
|
nary = all_in_nary_op + pyparsing.OneOrMore(atom)
|
||||||
disjunction = OneOrMore(or_ + atom)
|
disjunction = pyparsing.OneOrMore(or_ + atom)
|
||||||
|
|
||||||
# Even-numbered tokens will be '<or>', so we drop them
|
# Even-numbered tokens will be '<or>', so we drop them
|
||||||
disjunction.setParseAction(lambda _s, _l, t: ["<or>"] + t[1::2])
|
disjunction.setParseAction(lambda _s, _l, t: ["<or>"] + t[1::2])
|
||||||
|
Loading…
Reference in New Issue
Block a user