Replaces ifs in the parser with polymorphism