Help with providing good error messages to the user #1012
Unanswered
Elias-Graf
asked this question in
Q&A
Replies: 1 comment 7 replies
-
I think I have a hard time understanding, even as humans, how one can distinguish between both cases. Let's say you remove the
But this can be interpreted as
Do you have one or more examples of the kind of errors that you'd like to catch (missing value for an argument) ? With the corresponding source? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to write a parser for the following code:
For that, I have the following parsers:
The main goal, I'm pursuing for the parser, is to provide rich error message, currently for the
WidgetCallArg
. I would like that almost any way an arg is provided, there should be a message, telling you, what you are missing. E.g. missing the colon, missing the argument name, or the value.Adding a rule like this:
It is problematic, because the program now can't decide if the next atom should be the argument, or the
WidgetCallChild
(which can also just be an atom).So I've tried to work around this, by saying "you can't have children if the value of the argument is missing". Translating to the following code:
The problem with this is obvious, first, the parser does not work if there are any children. Second, the missing value detection only works on the last argument.
I've tried working around this for quite a long time now, but I only get more issues with ambiguous grammars and multiple productions. What would be the best way to solve something like this?
Runnable code (including some tests): Elias-Graf/rotten-potato@45056f7
I've also considered making the error reporting part of a post-processing step. Although I'd really prefer not to, since it's syntax, and it would make interpreting the AST generally more complicated. But even then, as long as I make the atom in the argument optional, I will run into the same problem as far as I'm concerned.
Beta Was this translation helpful? Give feedback.
All reactions