Replacing antlr with hand-written parser