Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backslashes break gore's scanner #17

Closed
samertm opened this issue Mar 13, 2015 · 6 comments · Fixed by #120
Closed

backslashes break gore's scanner #17

samertm opened this issue Mar 13, 2015 · 6 comments · Fixed by #120
Assignees

Comments

@samertm
Copy link

samertm commented Mar 13, 2015

gore> h\ello<enter>
..... <enter>
..... <ctrl-d>
gore> hello\t<enter>
..... <enter>
..... <ctrl-d>
gore> he\\llo<enter>
..... <enter>
.....

Only a couple escape sequences are valid: https://golang.org/ref/spec#Rune_literals

@motemen motemen self-assigned this Mar 13, 2015
@motemen
Copy link
Member

motemen commented Mar 15, 2015

It's because gore enters line-continuation mode if it fails to parse input. What is your expected behavior?

As you may already know, for string literals you must surround them by "s:

gore> "hello\t"
"hello\t"

@samertm
Copy link
Author

samertm commented Mar 15, 2015

It's because gore enters line-continuation mode if it fails to parse input. What is your expected behavior?

That explains it :P I was expecting an error.

@motemen
Copy link
Member

motemen commented Mar 16, 2015

Got the point. I have currently no idea with this problem.

@samertm
Copy link
Author

samertm commented Mar 16, 2015

The reason I ask is because I'm writing a CLI app too, and I wanted to see how you handle backslashes. For my app, all backslashes outside of quotes are literals, and backslashes within quotes always escape the character after, which you can see here. Where do you parse CLI input? I'd like to take a look.

@motemen
Copy link
Member

motemen commented Mar 17, 2015

One night passed and I think we can use go/scanner to detect illegal characters in the source, though I have not tested it.

FYI, I'm parsing input using go/parser.ParseFile here and if the error was go/scanner.ErrorList, gore prompts to continue line here.

@itchyny
Copy link
Collaborator

itchyny commented Feb 23, 2019

This issue is resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants