-
-
Notifications
You must be signed in to change notification settings - Fork 296
Open
Description
When I define a named element inside another named element (e.g. pronoun inside sentence in the example below), I suppose I would be able to access the named elements recursively as shown in the example (parsed.sentence.verb).
Documentation does not describe this kind of situation, thus I am not sure whether this is a bug or a feature?
Thanks in advance for the answer!
Example below
from pyparsing import Word, alphas
# Define tokens
verb = Word(alphas).setResultsName("verb")
pronoun = Word(alphas).setResultsName("pronoun")
sentence = (pronoun + verb).setResultsName("sentence")
# Input string
input_str = "You are"
# Parse input
parsed = sentence.parseString(input_str)
# parsed.pprint()
# Access individual components
print(parsed.sentence.pronoun) # Expected result: You, actual result: ' '
print(parsed.sentence.verb) # Expected result: are, actual result: ' '
Metadata
Metadata
Assignees
Labels
No labels