Open thoelze1 opened 4 years ago
Yep, this is very much an issue. Thank you for creating one on Github, now it doesn't have to live only in my head.
The issue is very simple, config-file reading happens in 2 steps:
The second step already has relatively clear errors that make sense. The first part currently just reports the raw errors thrown by the parser. In your concrete example, it reads 'tap-hold', it knows that now it has to read some kind of number, it encounters an 'a', which is not a number, and reports that issue.
Basically, we have to go through the Parser.hs code and add better error reporting.
For example, for this particular issue, I think we can change the lexeme numP
(line 239 a.t.m.) into a new Parser, like timeP
, and use the <?>
operator to specify correct error reporting.
The reason is currently reports button
is because that is the first <?>
it encounters (at the end of buttonP
, basically saying, "I was expecting you to give me a valid button, I encountered a weird a
, you didn't give me a button".
In addition to more informative error messages in general, it would be nice if all error messages included the filename, line and column, and were in a standard format, to enable jumping directly to the source of the error when checking for syntax errors with kmonad -d
in your editor (e.g. emacs M-x compile
).
When the number of seconds is omitted from the definition of any of the variations of
tap-hold
, the error reporting is unclear. For example, with the following config:The following error is reported:
I would expect this to say "expecting int" or something along those lines. I think I've noticed some other issues with the error reporting but I just wanted to start a thread for this issue while I'm thinking of it.