Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Better error reporting #12

@toroidal-code

Description

@toroidal-code

This issue corresponds to an item on the current To-Do list in README.md.

From my experiences, there's going to be quite a bit going into this:

  • A location type, that contains information including, but not limited to:
    1. Current file
    2. Beginning of the location
    3. End of the location
  • An error type. The OCaml compiler uses exception, but this has the problem that only one error can be raised per parse. Keeping track of multiple errors and discarding malformed expressions (or even adding a node to the AST that notes an error) is more ideal.
  • Error recovery (some way of sanely handling errors, and continuing to lex/parse). In Kiln, I'm doing this via a Queue that contain errors in the Lexer/Parser modules , and ensuring that they are empty before proceeding to the next stage of compilation.
  • A way to pretty print errors. A suggested way to do this is with an open sum type in an Errors module. This leads to being able to handle both specific errors and more generic errors in same match statement

The OCaml compiler is a fantastic example for some of these things.
The work I'm doing in Kiln is also relevant.

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