I am using pyparsing, but I can not find how to solve this rather easy problem. I have (at the moment) a simple grammar, but I canโt find a way to recognize the result of parsing by the types defined in my grammar.
It may be easier to explain this with an example. Assume this item:
elem = foo | bar
When I call:
elem.parseString("...")
Suppose a string matches my grammar, how can I distinguish if it matches "foo" or "bar"? I get an instance of the ParseResults object without such metadata.
Thanks in advance.
wikier
source share