Refactor parser: Change parser from function to class