parses TREX pattern into AGM.