Refactor parser with inheritance