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

Evaluate single-quoted strings #117

Open
evinism opened this issue Apr 14, 2022 · 0 comments
Open

Evaluate single-quoted strings #117

evinism opened this issue Apr 14, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@evinism
Copy link
Owner

evinism commented Apr 14, 2022

Strings in MistQL are encoded using JSON's standard for escaping:

https://tools.ietf.org/id/draft-ietf-json-rfc4627bis-09.html#rfc.section.7

This leaves a grammar as follows:

  string = quotation-mark *char quotation-mark

   char = unescaped /
       escape (
           %x22 /          ; "    quotation mark  U+0022
           %x5C /          ; \    reverse solidus U+005C
           %x2F /          ; /    solidus         U+002F
           %x62 /          ; b    backspace       U+0008
           %x66 /          ; f    form feed       U+000C
           %x6E /          ; n    line feed       U+000A
           %x72 /          ; r    carriage return U+000D
           %x74 /          ; t    tab             U+0009
           %x75 4HEXDIG )  ; uXXXX                U+XXXX

   escape = %x5C              ; \

   quotation-mark = %x22      ; "

   unescaped = %x20-21 / %x23-5B / %x5D-10FFFF

Because MistQL is often embedded in JSON (or stringified in some way) it can get annoying to work with string constants, because you HAVE to escape them, e.g. the mistql query @ + "hi" becomes "@ + \"hi\"". On the surface that's not too bad, but it does hurt readability substantially. It doesn't hurt language size dramatically to allow for single-quoted strings, such that queries encoded in JSON look like "@ + 'hi'". Therefore, we should assess, track, and perhaps execute on adding this to the language.

The grammar for that would be VERY similar to the grammar above, with a very small modification:

   single-quote-string = single-quotation-mark *char single-quotation-mark

   char = unescaped /
       escape (
           %x22 /          ; '    single-quotation-mark  U+0027
           %x5C /          ; \    reverse solidus U+005C
           %x2F /          ; /    solidus         U+002F
           %x62 /          ; b    backspace       U+0008
           %x66 /          ; f    form feed       U+000C
           %x6E /          ; n    line feed       U+000A
           %x72 /          ; r    carriage return U+000D
           %x74 /          ; t    tab             U+0009
           %x75 4HEXDIG )  ; uXXXX                U+XXXX

   escape = %x5C              ; \

   single-quotation-mark = %x27      ; '

   unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
@evinism evinism added the enhancement New feature or request label Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant