Skip to content

How to resolve the conflict between OneOrMore and Keyword #558

@Gu-f

Description

@Gu-f
import pyparsing as pp

str_text = "get a b c from cup;"

content = pp.Word(pp.alphas)

content_pos = pp.OneOrMore(content).set_name("contents")

container = pp.Word(pp.alphas).set_name("container")
end_flag = ';'

get = pp.Keyword('get')
from_ = pp.Keyword('from')

pattern = get + content_pos + from_ + container + end_flag

print(pattern.parse_string(str_text))

I got an error pyparsing.exceptions.ParseException: Expected Keyword 'from', found ';' (at char 18), (line:1, col:19)
from is matched by content_pos
But I want from as a keyword to be matched by from_
How should I fix it, thanks

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