implements the parser to some extent