Skip to content

No error reported when infix encounters duplicate operator #404

@mueller55

Description

@mueller55

I am using pyparsing to build a simple formula parser. The grammar is:

constant = TRUE | FALSE
ident = ~keyword + Word(alphas, alphanums + "_")
unit = constant | ident
UNARY, BINARY = 1, 2
formula = infixNotation(
unit,
[
(AND, BINARY, opAssoc.LEFT, ast.make_and),
(OR, BINARY, opAssoc.LEFT, ast.make_or),
]
)

When I try to parse a string in which the operator occurs twice, I get not error message. For instance,
formula.parseString('a or or b')
parses without error, but the resulting result contains only 'b'. Note that the action ast.make_or is NOT called.

Is this a bug or an error in my code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions