Making a context-sensitive grammar

most languages need the extent of inner parses to be determined by the outer language

Mmm, I intend to add more flexibility to how the inner parses are executed and their extent determined. To A) give outer languages the option of taking more control and B) support embedding non-LR languages like Markdown. Haven’t figured the details out yet.

How does incremental re-parsing work with this?

Right now, it doesn’t. I think I’ll need to create a new implementation for the Parser interface. It will keep track of the ranges for nodes with the embedContext prop (the outermost non-overlapping ranges), and will need to re-parse whichever ranges overlap with those passed to createParse(). Which is a little bit scary from a performance perspective (could easily require re-parsing the whole document on every keystroke), but hopefully I’ll be able to make use of fragments in a way that makes this manageable. If that’s not enough I’ll probably need to make use of some escape hatch like, for example, debouncing the parses.