Skip to content

Add machine-readable compile error output for tooling (LSP) use #411

Description

@m00qek

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 :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions