4 ms·
It seems to me that this is much more dependent on the language specification rather than on the implementation of anything. In case of a parse error, you may n
by jhgb 4y ago
It seems to me that this is much more dependent on the language specification rather than on the implementation of anything. In case of a parse error, you may not be able to recover correctly the parsing of any code beyond the error. Take for example the case of an omitted right brace/parenthesis/end keyword/whatever terminates the body of a function in your language. In a language that only allows top-level function definitions, upon encountering a beginning of another function definition, you could recover parsing from there since it couldn't possibly have been inside the body of a previous function. That function will then be recognized by your tools as a globally named object of the language (or, available in its respective module, should your language have modules). But in a language where local function definitions are allowed, you can't do that since that function could plausibly have been a local in the "previous" (actually, enclosing) function with the parse error. You simply don't know it it was supposed to be a local definition or a top-level one.
- zdragnar 4y ago> In case of a parse error, you may not be able to recover correctly the parsing of any code beyond the error. Of course, ambiguous syntax will obscure any information beyond what can be understood (short of having a compiler track changes between runs). Some languages / compilers can recover after a parse error. Going back to the ts language server, if you introduce a single quote, unclosed, nothing works until the end of the line (single quoted strings cannot be multiline) Both before the quote and after that line, however, features such as auto-importing and autocompletion still work as expected. This is an issue of where the boundaries of the ambiguity lie (what is possible) and the implementation (what actually happens). I suspect many language / compiler / IDE tools fall in different places on the spectrum of possible and works to possible but not implemented. My hunch is that more and more, tools are getting closer to the "possible and works" side of things.