hedy icon indicating copy to clipboard operation
hedy copied to clipboard

Escape quotes or give error in wrongly quoted ask

Open Felienne opened this issue 3 years ago • 5 comments

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

Felienne avatar Jan 28 '22 09:01 Felienne

Print gives an error message, ask should too:

image

Felienne avatar Jan 28 '22 09:01 Felienne

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!

lexcov avatar Mar 22 '22 22:03 lexcov

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!

Felienne avatar Mar 23 '22 05:03 Felienne

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

lexcov avatar Mar 26 '22 18:03 lexcov

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 user what'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.

Felienne avatar Mar 29 '22 06:03 Felienne