You might find the existing Parser infrastructure for displaying precisely located diagnostics convenient. After all, it was intended for exactly this use case