complete parser rework (still a bit unpolished)