rusty
rusty copied to clipboard
Improve parse-error messages
Currently our parser errors could do with some improvement. Take the follwing example, where I am trying to declare a variable with a reserved keyword as name:
FUNCTION main : DINT
VAR
by : BYTE;
to : DINT;
END_VAR
// do stuff
END_FUNCTION
Upon compilation, we print the following error:
error: Unexpected token: expected KeywordEndVar but found 'by : BYTE;
to : DINT;'
┌─ target/demo.st:3:5
│
3 │ ╭ by : BYTE;
4 │ │ to : DINT;
│ ╰──────────────^ Unexpected token: expected KeywordEndVar but found 'by : BYTE;
to : DINT;'
This message isn't really helpful for the end-user, since it in no way points them to the variable name being the issue. We should try to make our parser errors more user-friendly.