alda-lang / alda-core

The core machinery of Alda
80 stars 26 forks source link

Include line/column information in error messages. #78

Closed truj closed 3 years ago

truj commented 4 years ago

I have decompiled a MIDI file to ALDA using Midica. In order to test this file, I tried to re-convert it to MIDI using ALDA. I got the following error message:

alda export -f in-file.alda -o out-file.mid
[27713] Parsing/evaluating...
[27713] ERROR No previous note with which to create a chord.

The file is quite large, so this error message is not very helpful to find the bug.

Proposed Solution: Error messages should contain the line number and column of the source file where the error occurred.

daveyarwood commented 4 years ago

You're right, that's a very good point.

I'd like to do some research into "standard"/common approaches to compiler error messages. I would think that parse errors should almost always include a line and column number, whenever it's possible to do so. There is probably some popular format that I should copy that would make it easier to use the Alda compiler as a linter and hook it up with text editors.

I'm adding a task to the Alda v2 project to make sure that I end up doing this in Alda v2. I did some testing just now, and the v2 parser is already in a state where we have at least the line number in hand, and I think it should be easy enough to add the column too.

Given a score like piano: /e, Alda v1's error message is:

[27713] ERROR No previous note with which to create a chord.

Alda v2's error message is:

/tmp/foo.alda:1 Unexpected Separator `/` at the top level

Which contains the filename and line number, and it'll be nice if I can add the column number too, like /tmp/foo.alda:1:8.

daveyarwood commented 4 years ago

I've fixed this in Alda v2. I'll leave this issue open just in case somebody feels like fixing it in Alda v1; will close when Alda v2 is released.

daveyarwood commented 3 years ago

On second thought, I'm going to go ahead and close this. Alda v2 is coming soon! :fireworks: