Skip to content

Commit

Permalink
Refactor escapes, highlight invalid escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
jiribenes committed Jul 20, 2024
1 parent 7dc2c36 commit e00c154
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions syntaxes/effekt.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,42 @@
"begin": "'",
"end": "'",
"patterns": [{
"name": "constant.character.escape.effekt",
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
"include": "#escapes"
}, {
"include": "#invalidEscapes"
}]
},
"strings": {
"patterns": [{
"name": "string.quoted.triple.effekt",
"begin": "\"\"\"",
"end": "\"\"\"",
"comment": "Important: only single-line strings can have escapes!",
"patterns": [{
"name": "constant.character.escape.effekt",
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
}, {
"include": "#stringTemplates"
}]
}, {
"name": "string.quoted.double.effekt",
"begin": "\"",
"end": "\"",
"patterns": [{
"name": "constant.character.escape.effekt",
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
"include": "#escapes"
}, {
"include": "#invalidEscapes"
}, {
"include": "#stringTemplates"
}]
}]
},
"escapes": {
"match": "\\\\([btnfr\\\\\"']|u[0-9A-Fa-f]{4})",
"name": "constant.character.escape.effekt"
},
"invalidEscapes": {
"match": "\\\\.",
"name": "invalid.illegal.unknown-escape.effekt",
"comment": "Represents any possible escape, therefore should always be used _after_ #escapes!"
},
"names": {
"patterns": [{
"match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]",
Expand Down

0 comments on commit e00c154

Please sign in to comment.