axiacore / py-expression-eval

MIT License
149 stars 54 forks source link

Parse 'in ' operator with space at the end so functions named 'in*' are supported #68

Closed octaviancorlade closed 3 years ago

octaviancorlade commented 3 years ago

Currently it's not possible to:

from py_expression_eval import Parser
parser = Parser()
parser.functions = {
    **parser.functions,
    "int": int
}
parser.evaluate("int(a)", {"a": "3"})

It would parse int as the string operator in t(a) and therefore raise

Exception: parse error [column 6]: parity, expression: int(a)

This fixes it so it behaves the same way as not, and, or and xor requiring these operators to be followed by a space. I don't think anyone would use the in operator without a space after it, but that could be a concern to keep in mind.

cansadadeserfeliz commented 3 years ago

Thank you!