Skip to content

Problem with as_keyword in one_of #554

Closed
@theroucken

Description

@theroucken

The problem occurs if you insert special characters

In the first case everything works as expected, the output is “+case2”

CASE = "+case2"
A = Or([CaselessKeyword("+case1"), CaselessKeyword("+case2")])
print(A.parse_string(CASE))

But in the second one, when the as_keyword parameter in one_of is used, an error occurs

CASE = "+case2"
B = one_of(["+case1", "+case2"], caseless=True, as_keyword=True)
print(B.parse_string(CASE))
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected +case1 | +case2, found '+'  (at char 0), (line:1, col:1)

I'm using pyparsing version 3.1.2

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