Re: S-exression parsing

2005-03-11 Thread Michael Spencer
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

S-exression parsing

2005-03-11 Thread George Sakkis
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']]