-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jou Langserver #556
Comments
Ideally, the compiler internals would be used as is (you can That said, I would rather have "first error blocks the rest" langserver than no langserver at all... :) Langservers also need sockets and JSON. Sockets will be a bunch of platform-specific |
(This comment assumes that Jou files only contain functions and imports. I will think more about classes etc later.) I've thought about this more. The error handling of the Jou compiler is bad in at least the following two scenarios:
This is difficult, because I don't want to change how error handling works in the compiler. The "first error stops compiling" error handling style makes the compiler simple and nice to work on. Specifically, the compiler exits the whole process whenever there is an error, so I don't need to e.g. return special values that indicate an error has occurred (such as I think I will instead invoke the compiler as a subprocess (as suggested by Moosems). The idea is to trick the compiler to report multiple errors by running it multiple times. When the langserver runs the compiler for a second time, it tells it to ignore the first error, so that it can get a new error. To do this, it will need to have some sort of minimalistic version of the Jou tokenizer, only enough to figure out where functions start and end. The compiler still needs to be modified, for example by adding the following command-line flags:
Next, let's walk through how this would actually work. Suppose import "./does_not_exist.jou"
def foo() -> itn:
printf("foo\n")
reutrn 123
def bar() -> None:
foo() User opens the file, so the langserver runs the compiler with
Or maybe more like this:
The langserver knows that lines 2, 3 and 4 belong to function import "./does_not_exist.jou"
def bar() -> None:
foo() Now there is an error on line 1 because the imported file doesn't exist. The langserver compiles again with |
I'm no longer sure if invoking the compiler multiple times is a good idea. Launching a new process is slow on Windows, so that may get annoying if you have a large file. A couple days ago, I started refactoring the compiler to emit multiple errors instead of stopping on the first one (nothing pushed to github yet). For most of the code, this has turned out to be surprisingly easy, but not for the parser. If an error occurs, the parser needs to somehow skip the bad tokens before trying again, so that it parses the rest of the file instead of getting stuck on the error. |
No description provided.
The text was updated successfully, but these errors were encountered: