In short, I’m wondering whether it is possible to get a machine-readable structured error output (e.g., JSON, XML, etc) from the current
stanc or a future version (
I’m currently trying to update the emacs
stan-mode to the 2019 standards. One of the new feature is on-the-fly syntax check using
flycheck-stan. The example picture is a code with a single syntax error in
cauchy_lpdf, which the on-the-fly syntax checker underlined.
But I’m having a difficulty parsing
stanc error output for this. When there is only one error or info, it is fine. But when there are multiple info like deprecated syntax and an error, parsing them separately becomes little trickier.
- Info’s do not have associated line numbers, making it difficulty to indicate it live
- An error typically starts with " error" with associated line and column (some times just line). But in this case, the explanation “Probability function…” comes before “error…” making it difficult to capture its beginning unless all possible messages are encoded in the parser.
- Machine-readable format (e.g., --json option gives the errors in json)
- Data elements include: line, column, severity (error, warning, info, etc), one-liner error/info message, long error/info body for full description
- If machine-readable format is too far-fetched, a consistent beginning (Error: in addition to Info:), consistent line number, one liner summary before the multi-line message body can make parsing much easier.