3 ms·
Any thoughts on how to handle parsing for the IDE use case where a document is being edited that might have errors in it. I would usually expect an area around
by dman 9y ago
Any thoughts on how to handle parsing for the IDE use case where a document is being edited that might have errors in it. I would usually expect an area around the cursor that is an area that receives edita and hence contains errors. I would also expect a header and footer surrounding the edited area that would be okay structurally since its unchanged from a previously sound definition of the file.
- pdubroy 9y agoYou might be interested in Ohm's incremental parsing support. I'll be presenting a paper on this at SPLASH next week: https://ohmlang.github.io/pubs/sle2017/incremental-packrat-parsing.pdf https://ohmlang.github.io/pubs/sle2017/incremental-packrat-p.... In theory, what you're suggesting should be possible to implement with our incremental packrat parsing algorithm. But we haven't tried it yet, so I can't say for sure.
- dman 9y agoThanks!
- bd82 9y agoOne option would be to use a Parser that supports fault tolerance and error recovery. In hand crafted parsers this error recovery may be added manually (but resulting in a-lot of work...) For example: search for the word "recovery" in the TypeScript parser which is used to provide Language Services for the VSCode IDE. https://github.com/Microsoft/TypeScript/blob/master/src/compiler/parser.ts https://github.com/Microsoft/TypeScript/blob/master/src/comp... Automatic Error Recovery using heuristics can also be implemented by parsing Libraries. In the world of JavaScript I'm familiar with two libraries that support Error Recovery: Antlr4 - https://github.com/antlr/antlr4 https://github.com/antlr/antlr4 Chevrotain - https://github.com/SAP/chevrotain https://github.com/SAP/chevrotain (disclaimer - I'm the author of Chevrotain)