Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You need a fault tolerant parser, tree sitter is a good example on how it works in practice, your compiler should have the ability to run a few steps (parsing, symbol resolution, type checking, etc) with an incomplete/invalid AST.

> isn't it generally impossible to recovery syntactic errors

AFAIK Zig was designed in such way that, in most cases, you can parse each line independently, like their strings by default are single line, you need a special syntax for multiline strings that still are per line basis.



I doubt it's possible to perform proper syntax recovery without messing the result. My approach with usage of some previous valid program state is more reliable and easier to implement.

> AFAIK Zig was designed in such way that, in most cases, you can parse each line independently

It can't be true. Basic stuff like opening/closing braces introduces some global syntax state, so that line-by-line parsing isn't possible. Do you mean something like tokenization instead? It is in many cases possible. But for true LSP it's almost useless.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: