Can't get pyparsing Dict() to return nested dictionary
问题 I'm trying to parse strings of the form: 'foo(bar:baz;x:y)' I'd like the results to be returned in form of a nested dictionary, i.e. for the above string, the results should look like this: { 'foo' : { 'bar' : 'baz', 'x' : 'y' } } Despite numerous combinations of Dict() and Group() I can't get it to work. My (one of the versions of) grammar looks like this: import pyparsing as pp field_name = pp.Word( pp.alphanums ) field_value = pp.Word( pp.alphanums ) colon = pp.Suppress( pp.Literal( ':' )