corth-lang / Corth

A self-hosted stack based language like Forth
MIT License
7 stars 1 forks source link

Improving the debug system #57

Closed HuseyinSimsek7904 closed 3 months ago

HuseyinSimsek7904 commented 3 months ago

Closes #27 , closes #35

In the old debug system, the error messages were directly dumped to the log stream and then the procedure would just exit the program with an error code. This meant that the error messages were somewhat simple and not very helpful.

In the new system, the error information is RETURNED from the called procedure to the caller procedure. This allows the caller procedure to improve the error messages by adding new layers of information about the error.

This is accomplished by creating a log-item structure. Any log item has a log type which contains information about what this log item represents, and log arguments which explain the log entry further. Procedures and macros for creating, managing and handling these log entries are defined inside compiler/debug.corth file.

These improvements also has a lovely side effect: The compiler now compiles itself much faster than it did before. The compiler used to take ~3 seconds to compile itself. It now takes ~1.15 seconds.

However, some of the error messages are not as useful as they could. These require future updates to make them more informative.