Locally least-cost error correctors for context-free and context sensitive parsers