3 ms·
One thing I'll add, because I think it's an interesting insight about the priorities of code parsing for text editors: Tree-sitter is specifically designed to b
by robenkleene 4y ago
One thing I'll add, because I think it's an interesting insight about the priorities of code parsing for text editors: Tree-sitter is specifically designed to be very effective at parsing code that's in an invalid state. E.g., think about adding a new line to a program, the new line you're adding is typically invalid for the majority of time until you've finished typing it out.
- thaumasiotes 4y ago> E.g., think about adding a new line to a program, the new line you're adding is typically invalid for the majority of time until you've finished typing it out. That doesn't really bother me. The line of code you're currently typing is generally so invalid that there's not much point trying to color it. But what does bother me is the code below where you're typing changing its color as the IDE tries to make your partial line fit.
- d-us-vb 4y agoThe point is trying to make sure that the parser doesn't choke on the entire file just because one line is incorrect.
- srcreigh 4y agoThat and very fast incremental parsing as you type. Slow parsing is why emacs used regexps for syntax highlighting instead of parsers in the first place.
- armchairhacker 4y agoUnfortunately this is a really hard problem, and I’ve used projects with tree-sitter and it actually chokes up on invalid syntax lines. Granted, maybe the projects weren’t using tree-sitter correctly. But regex parsing is surprisingly practical, so despite being really amazing at its goals, tree-sitter may not have a definitive advantage