Hello there, I'm building a language server for ucode on top of my tree-sitter grammar. The LSP can lean on the grammar for parsing, scopes, symbols, etc., but for semantic compile-time diagnostics it could invoke ucode -c and surface the results in the
editor.
The current human-readable stderr is parseable with a regex but brittle, as the format mixes the message, an optional "Expecting X" hint after a \n, the optional filename clause (only present in multi-source mode), and a ^-- Near here block. Any minor formatting change in uc_compiler_syntax_error would silently break the LSP.
A machine-readable output mode would make this robust and is a small change given the current code structure.
My proposal is to add a flag (something like -J) that switches compile error reporting from the current human-readable text to JSON Lines, one diagnostic per line:
{"file":"x.uc","severity":"error","line":5,"col":12,"message":"Unexpected token","hint":"Expecting ')'"}
Do you think that the idea is valid? If so, I can work on a PR for it :)
Hello there, I'm building a language server for ucode on top of my tree-sitter grammar. The LSP can lean on the grammar for parsing, scopes, symbols, etc., but for semantic compile-time diagnostics it could invoke
ucode -cand surface the results in theeditor.
The current human-readable stderr is parseable with a regex but brittle, as the format mixes the message, an optional "Expecting X" hint after a
\n, the optional filename clause (only present in multi-source mode), and a^-- Near hereblock. Any minor formatting change inuc_compiler_syntax_errorwould silently break the LSP.A machine-readable output mode would make this robust and is a small change given the current code structure.
My proposal is to add a flag (something like
-J) that switches compile error reporting from the current human-readable text to JSON Lines, one diagnostic per line:{"file":"x.uc","severity":"error","line":5,"col":12,"message":"Unexpected token","hint":"Expecting ')'"}Do you think that the idea is valid? If so, I can work on a PR for it :)