evinism / evinism/mistql

Evaluate single-quoted strings

Open
#117 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
393
Forks
20
PR merge metrics
No merged PRs in 30d

Description

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:
```abnf
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:

```abnf
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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.