hedy
hedy copied to clipboard
Escape quotes or give error in wrongly quoted ask
Use of single quote in level 5 creates assign:
name is ask 'what's your name?'
print name
Originally posted by @Felienne in https://github.com/Felienne/hedy/pull/1826#r794338097
Print gives an error message, ask should too:
Hi @Felienne! Is it possible if @Robernc and I work on this issue? Since #1227 might be closed. Additionally, if you have any possible pointers, let us know!
Yes that would be fantastic, this is very annoying for kids.
The best approach is to start by adding a failing test with the above code. You can just copy-paste an existing test and change the input.
You could change the grammar to allow quotes in a string but that might have some unwanted side effects, f.e.
name is ask 'what's your name?'
might parse as
name is ask 'what'
and then say, unexpected character s.
Another option that we use in other places in the code is to replace '
by \'
so that it is simply printed in the output.
Let me know if that helps!
Just to confirm, if someone runs name is ask 'what's your name?'
should the website:
a) show the error message that's in the screenshot, or
b) run normally and ask the user what's your name?
I assumed based on issue #2293 that maybe an error might confuse kids since it would involve explaining the \
escape character, so I was planning on implementing option b
Sorry to be slow with a reply, I was traveling last week and still catching up on email
Just to confirm, if someone runs
name is ask 'what's your name?'
should the website: a) show the error message that's in the screenshot, or b) run normally and ask the userwhat's your name?
If possible b) If that is not easily possible, we could allow kids to escape the '
with a slash: \'
but I think that is kinda hard so if it can be avoided, I prefer that!
I assumed based on issue #2293 that maybe an error might confuse kids since it would involve explaining the
\
escape character, so I was planning on implementing option b
Sound good!! If you need more help, let us know.