Basically I want to parse the string with nested brackets/parantheses.
opening = oneOf("( { [")
closing = oneOf(") } ]")
scanner = originalTextFor(nestedExpr(opening, closing))
data = 'a b c [(xx), (yyy) zz)'
However, firstly, it gives me
ValueError Traceback (most recent call last)
<ipython-input-106-f6f023bf4229> in <module>
1 opening = oneOf("( { [")
2 closing = oneOf(") } ]")
----> 3 scanner = originalTextFor(nestedExpr(opening, closing))
/anaconda3/envs/myenv/lib/python3.6/site-packages/pyparsing.py in nestedExpr(opener, closer, content, ignoreExpr)
6201 ).setParseAction(lambda t: t[0].strip()))
6202 else:
-> 6203 raise ValueError("opening and closing arguments must be strings if no content expression is given")
6204 ret = Forward()
6205 if ignoreExpr is not None:
ValueError: opening and closing arguments must be strings if no content expression is given
Secondly, I am trying to get the nested structure(list) as output like this:
[['xx'], ',', ['yyy'], 'zz']
But I get a whole string instead of a nested structure.