QuTech-Delft / libqasm

libQASM: Library to parse cQASM files
https://arxiv.org/abs/1805.09607
Other
15 stars 16 forks source link

Return diagnostic data as object from JSON methods #197

Closed rturrado closed 5 months ago

rturrado commented 5 months ago

API methods returning a JSON now follow the Diagnostic structure of the Language Server Protocol (LSP) specification.

We've taken the opportunity to refactor the libqasm's "error handling". Every ParseResult and AnalysisResult manages a vector of Error objects, instead of a vector of strings. This way, the formatting of an error object is delayed right until the API implementation.

All the syntactic error messages start with Error: or Error at <location>:'. And many of them include a <last column> field. This change should fix issue #178.

Refactor error::AnalysisError:

Refactor annotations::SourceLocation:

Refactor CustomErrorListener::syntaxError:

Refactor v1x::Analyzer:

Update references to error::AnalysisError in the code.

Add .gitattributes file.

Add cmake-build-* folders to .gitignore.

rturrado commented 5 months ago

Many thanks for the review, Pablo.

I may not have gone the whole way with the use of optional, but it has indeed made the API clearer now. I don't like at all default arguments.

Thanks for this kind of review suggestions.