Refactor the syntax checker