grammar and parser for text type defs