Skip to content

Commit

Permalink
🔨 Unicode codepoint escaped characters in strings (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrob authored Oct 5, 2024
1 parent f487b72 commit 48d8e41
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 69 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- Unicode codepoint escaped characters in strings from `just` release 1.36.0

## [0.5.3] - 2024-08-14

### Changed
Expand Down
4 changes: 2 additions & 2 deletions syntaxes/just.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
{
"comment": "Escaped characters",
"name": "constant.character.escape.just",
"match": "\\\\."
"match": "\\\\.(?:(?<=u)\\{.+?\\})?"
},
{
"include": "#escaping"
Expand All @@ -402,7 +402,7 @@
{
"comment": "Escaped characters",
"name": "constant.character.escape.just",
"match": "\\\\."
"match": "\\\\.(?:(?<=u)\\{.+?\\})?"
},
{
"include": "#escaping"
Expand Down
4 changes: 2 additions & 2 deletions syntaxes/just.tmLanguage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ repository:
patterns:
- comment: Escaped characters
name: constant.character.escape.just
match: "\\\\."
match: "\\\\.(?:(?<=u)\\{.+?\\})?"
- include: '#escaping'
- comment: String
name: string.quoted.double.just
Expand All @@ -281,7 +281,7 @@ repository:
patterns:
- comment: Escaped characters
name: constant.character.escape.just
match: "\\\\."
match: "\\\\.(?:(?<=u)\\{.+?\\})?"
- include: '#escaping'
- comment: Indented raw string
name: string.quoted.single.indented.just
Expand Down
22 changes: 12 additions & 10 deletions syntaxes/tests/statements/strings.just
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ single-quote := "don't be afraid of contractions"

# Escaping sequences

string-with-tab := "\t"
string-with-newline := "\n"
string-with-carriage-return := "\r"
string-with-double-quote := "\""
string-with-slash := "\\"
string-with-no-newline := "\
carriage-return := "\r"
double-quote := "\""
newline := "\n"
no-newline := "\
"

escapes := """\t\n\r\"\\"""
escapes := '\t\n\r\"\\'
escapes := '''\t\n\r\"\\'''
slash := "\\"
tab := "\t"
unicode-codepoint := "\u{1F916}"
non-unicode-not-escaped := "\a{1F916}"

escapes := """\t\n\r\"\u{123}\\"""
escapes := '\t\n\r\"\u{123}\\'
escapes := '''\t\n\r\"\u{123}\\'''

# Multi-line

Expand Down
128 changes: 73 additions & 55 deletions syntaxes/tests/statements/strings.just.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,74 @@
># Escaping sequences
#^^^^^^^^^^^^^^^^^^^^ source.just comment.line.number-sign.just
>
>string-with-tab := "\t"
>carriage-return := "\r"
#^^^^^^^^^^^^^^^ source.just variable.other.just
# ^^^^^^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>string-with-newline := "\n"
#^^^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>string-with-carriage-return := "\r"
#^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>string-with-double-quote := "\""
#^^^^^^^^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>string-with-slash := "\\"
#^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^^^^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>string-with-no-newline := "\
#^^^^^^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just
# ^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>double-quote := "\""
#^^^^^^^^^^^^ source.just variable.other.just
# ^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>newline := "\n"
#^^^^^^^ source.just variable.other.just
# ^^^^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>no-newline := "\
#^^^^^^^^^^ source.just variable.other.just
# ^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just
>"
#^ source.just string.quoted.double.just
>slash := "\\"
#^^^^^ source.just variable.other.just
# ^^^^^^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>tab := "\t"
#^^^ source.just variable.other.just
# ^^^^^^^^^^^^^^^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>unicode-codepoint := "\u{1F916}"
#^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
>non-unicode-not-escaped := "\a{1F916}"
#^^^^^^^^^^^^^^^^^^^^^^^ source.just variable.other.just
# ^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^^^^^^^ source.just string.quoted.double.just
# ^ source.just string.quoted.double.just
>
>escapes := """\t\n\r\"\\"""
>escapes := """\t\n\r\"\u{123}\\"""
#^^^^^^^ source.just variable.other.just
# ^ source.just
# ^^ source.just keyword.operator.assignment.just
Expand All @@ -76,24 +93,25 @@
# ^^ source.just string.quoted.double.indented.just constant.character.escape.just
# ^^ source.just string.quoted.double.indented.just constant.character.escape.just
# ^^ source.just string.quoted.double.indented.just constant.character.escape.just
# ^^ source.just string.quoted.double.indented.just constant.character.escape.just
# ^^^ source.just string.quoted.double.indented.just
>escapes := '\t\n\r\"\\'
# ^^^^^^^ source.just string.quoted.double.indented.just constant.character.escape.just
# ^^ source.just string.quoted.double.indented.just constant.character.escape.just
# ^^^ source.just string.quoted.double.indented.just
>escapes := '\t\n\r\"\u{123}\\'
#^^^^^^^ source.just variable.other.just
# ^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
>escapes := '''\t\n\r\"\\'''
# ^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
>escapes := '''\t\n\r\"\u{123}\\'''
#^^^^^^^ source.just variable.other.just
# ^ source.just
# ^^ source.just keyword.operator.assignment.just
# ^ source.just
# ^^^ source.just string.quoted.single.indented.just string.quoted.single.indented.just
# ^^^^^^^^^^ source.just string.quoted.single.indented.just
# ^^^ source.just string.quoted.single.indented.just
# ^^^^^^^^^^^^^^^^^ source.just string.quoted.single.indented.just
# ^^^ source.just string.quoted.single.indented.just
>
># Multi-line
#^^^^^^^^^^^^ source.just comment.line.number-sign.just
Expand Down

0 comments on commit 48d8e41

Please sign in to comment.