fabianschuiki / Maxwell

Modern, statically typed, duck typed, generic, imperative programming language, inspired by C++, Go, and Scala.
GNU General Public License v2.0
9 stars 1 forks source link

Implement error reporting #2

Open fabianschuiki opened 10 years ago

fabianschuiki commented 10 years ago

At the moment, errors are reported by throwing an exception somewhere in the compiler. The resulting message in the output is really not helpful, as it usually refers to entries in the AST rather than the original source file.

fabianschuiki commented 10 years ago

Clang uses a nice system for diagnostics. The DiagnosticsEngine collects all diagnostics, which can be notes, remarks, warnings, errors, and fatal errors. Notes and warnings may be mapped to any of the diagnostic types mentioned before. The DiagnosticBuilder helper class is used to assemble one message from source ranges, AST nodes, code snippets, types, and other pieces of information.

fabianschuiki commented 10 years ago

See LLHD's implementation of diagnostics! That works fairly well, to say the least!

fabianschuiki commented 9 years ago

Commit 027501cb5f49acd60093eb2ca4d4bbdd407ee853 adds location tracking using the SourceId, SourceLocation, and SourceRange classes. Upon compile, the source files now need to be fed into a source repository in order to assign them a unique ID. This will then allow to resolve locations and ranges to the exact wording in the source file upon compilation.