3 ms·
> You are complaining about a lot of things simultaneously, and it's hard to tell exactly which point you want to tackle. Thanks, that's exactly how I felt abo
by debugnik 3y ago
> You are complaining about a lot of things simultaneously, and it's hard to tell exactly which point you want to tackle.
Thanks, that's exactly how I felt about your first reply.
> tree-sitter does actually have "magic tech" unavailable to most compilers
No, not using it doesn't mean it's unavailable, at best it means the toolchain is up for an upgrade.
> the magic tech is that
I too have written compilers and language servers, even tested novel parsing techniques. I don't need tree-sitter explained to me, I understand the theory behind it perfectly well and, as I already said, understand what they're going for in terms of ecosystem. I just don't think it's the sweet-spot you think it is.
In any case, making incremental edits is not novel, it's easy even with good old recursive descent by simply traversing the ast, skipping the prefix of the change, reparsing the inner node and checking that the edit was well-bounded (hopefully your language doesn't have multiline strings, or you'll have to accept that some incremental changes consume the whole file in the worst case anyway). I've done this, and again, if some toolchain doesn't then it's up for an upgrade.
The actually interesting parts of tree-sitter, to me, are the error recovery and the shared parse tree interface. The latter is orthogonal to the parsing technique, yet with tree-sitter it's all or nothing. The former would be great if it actually marked the error in the parse tree, which it didn't when I checked and it wasn't deemed important.
> most cannot real time semantic highlight even a 100k file on every keystroke
Even you concede that the bottleneck here is not usually parsing, and even then I just said it can be made incremental easily, but all the other work that the compiler is choosing to do before answering back to the editor. When this work is unnecessary (at this step anyway), then sure, you can speed past them by doing the work yourself on the tree-sitter parse tree.
> you could make a compiler for every language which supports a mode that does what tree-sitter does
Yes, we could. Maintaining and testing tree-sitter grammars also has a cost, maybe the difference is that compiler maintainers are externalising this cost right now.
> and then pay the cost of integrating 50 language specific ways of transforming these to work with the editor
No! We went through this with LSP. We can have any number of parsers with a shared driver interface, maybe like tree-sitter's, but we don't need to push every grammar through a single parser toolkit that isn't good enough to replace the existing parser in the toolchain.
In fact, tree-sitter grammars are shipped precompiled to editors, so that's kinda the situation already, but their current interface AFAIK expects a particular implementation on the parser (theirs).
> You seem to really otherwise be complaining that you believe it does always generate correct parsers
I guess you mean doesn't. Then yes, but that's not an "otherwise", that's a big deal, because if tree-sitter parse trees were actually sound I could just maintain a single tree-sitter grammar for the entire toolchain, compiler and editor, and this debate would be redundant.