@eniko @nikodemus yep, those are referred to as synchronization points; when you encounter them, you just pop all the state from the stack until you're back at parsing top level functions, and report an error.
The semi-colon is a very common one, too. You don't tend to see it mid-expression, only at the end of a statement, so if you encounter one and expect more expression tokens, you get to close the expression and report an error.
@eniko
error recovery (and reporting) and also SOMEHOW the possibility of incremental parsing has eaten years of my life.
i don’t know if your parser is incremental but it’s a pretty big leap to try to find just the ast nodes associated with a certain character or source code edit.
@eniko
and on the topic of error recovery, thank goodness most IDEs automation insert a closing brace on typing ‘(‘ because otherwise the rest of your program is now a function argument.
i guess ive been looking at this from the perspective of interactive parsing for intellisense/ code completion. i suppose for more well formed documents the challenge is less severe.
@dgregor79 I had not seen this. This is magnificent.
Is there any thought of splitting the parser primitives into a separate library? I assume much more maintenance than the team cares to take on, but seems like it could be an amazing resource for other projects.
@dgregor79 Fair, and as expected. And I would totally volunteer to do the library extraction if I didn’t have a family or a job.
Always love these windows into the work you all are doing.