MatthewKosloski / torrey

The Torrey Programming Language

Home Page:https://torrey.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refine error handling and debugger/diagnostics

MatthewKosloski opened this issue · comments

I'm not too happy with how error handling and diagnostic messages are created/managed/displayed.

For example, there's this in X8664PCLinuxBackend:

debug("x86-64 program (output from Generator): %s\n", 
            x86Program.toString());

And this in Generator:

throw new Error("Cannot generate x86 instruction");

And finally this in the Grammar:

reporter.throwSyntaxError(peek(), ErrorMessages.ExpectedExpr,
            peek().rawText());

We should look at how existing compilers (e.g., TypeScript) handle such mechanisms and refine how we do it in the Torrey compiler so it's more consistent and the API is easy to understand.