George Sakkis wrote:
The S-expression parser below works, but I wonder if it can be simplified; it's
not as short and
straightforward as I would expect given the simplicity of S-expressions. Can
you see a simpler
non-recursive solution ?
How about this (minus your error checking)?
def parseS(expr
The S-expression parser below works, but I wonder if it can be simplified; it's
not as short and
straightforward as I would expect given the simplicity of S-expressions. Can
you see a simpler
non-recursive solution ?
George
# usage
>>> parseSexpression("(a (b c) (d))")
['a', ['b', 'c'], ['d']]