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

Bug in the string literal parser? #42

Open
gallais opened this issue Jun 22, 2021 · 1 comment
Open

Bug in the string literal parser? #42

gallais opened this issue Jun 22, 2021 · 1 comment
Labels

Comments

@gallais
Copy link
Owner

gallais commented Jun 22, 2021

While I was porting the JSON parser to Agda yesterday I think I have
found a bug in the string literal parser:

$ rand (char '\\')
$ box $ andoptbind anyTok $ \ c =>
if c /= into 'u' then fail else unicode

After having read a \ we will only accept a u followed by 4 hexadecimal
digits aka. a unicode character. Shouldn't we also accept:

  • another \
  • a "
  • a r, n, or t
    ?
@gallais gallais added the bug label Jun 22, 2021
@gallais
Copy link
Owner Author

gallais commented Jun 22, 2021

Ok this is pretty sneaky: andoptbind anyTok $ \ c => ... means we'll consume
any token and succeed even if the continuation fails (in which case we return
(c, Nothing)). This means that we accept any character following a \, and
only have a special behaviour if it happens to be u aka the start of a unicode
character.

Not sure how I feel about that.

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

No branches or pull requests

1 participant