And here's the slightly cleaned up version: http://pastie.caboo.se/9667 I was going to take it further but it quickly became "string means the begin/end of a string", so I stopped with that. :)