Microsoft is writing a PHP parser that handles error recovery well, and the internals docs are really accessible.
It includes a discussion of handling trivia and even some sample parsing code.
miniblog.
Related Posts
Delighted to see that Typescript 7 is moving to conventional LSP for its IDE services!
In LSP, a position is represented as a line number and a column offset (in Unicode code units): https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
This is pretty elegant. You'll get the correct line regardless of encoding bugs, and the editor already knows the line number so it's cheap to compute.
A neat IDE feature from Typescript 5.2: it completes object field names even if the previous field doesn't end with a comma!
Syntax recovery is super helpful sometimes.
