terml: Improve parser and pretty-printing.