working but ugly solution to parser
working but ugly solution to parser
much better factored, but not sure about how it will handle edge cases