From d9a3f2114c4c67d28cd62eb3d6560ea3ab66f972 Mon Sep 17 00:00:00 2001 From: Davy Landman Date: Tue, 9 Jul 2024 14:14:57 +0200 Subject: [PATCH] Now escaping all regular characters --- .../main/rascal/lang/oniguruma/Conversion.rsc | 35 +++++++++++++++++-- .../syntaxes/rascal.tmLanguage.json | 26 +++++++------- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/rascal-textmate-core/src/main/rascal/lang/oniguruma/Conversion.rsc b/rascal-textmate-core/src/main/rascal/lang/oniguruma/Conversion.rsc index 5b876db..2de88a4 100644 --- a/rascal-textmate-core/src/main/rascal/lang/oniguruma/Conversion.rsc +++ b/rascal-textmate-core/src/main/rascal/lang/oniguruma/Conversion.rsc @@ -187,9 +187,40 @@ str encode(int char) { map[int, str] shorthands = ( 0x09: "\\t", 0x0A: "\\n", - 0x0C: "\\f", 0x0D: "\\r", - 0x20: " " + 0x20: " ", + 0x21: "\\!", + 0x22: "\"", + 0x23: "\\#", + 0x24: "\\$", + 0x25: "\\%", + 0x26: "\\&", + 0x27: "\'", + 0x28: "\\(", + 0x29: "\\)", + 0x2A: "\\*", + 0x2B: "\\+", + 0x2C: "\\,", + 0x2D: "\\-", + 0x2E: "\\.", + 0x2F: "\\/", + 0x3A: "\\:", + 0x3B: "\\;", + 0x3C: "\\\<", + 0x3D: "\\=", + 0x3E: "\\\>", + 0x3F: "\\?", + 0x40: "\\@", + 0x5B: "\\[", + 0x5C: "\\\\", + 0x5D: "\\]", + 0x5E: "\\^", + 0x5F: "\\_", + 0x60: "\\`", + 0x7B: "\\{", + 0x7C: "\\|", + 0x7D: "\\{", + 0x7E: "\\~" ); diff --git a/vscode-extension/syntaxes/rascal.tmLanguage.json b/vscode-extension/syntaxes/rascal.tmLanguage.json index 3ca7207..4db3fcb 100644 --- a/vscode-extension/syntaxes/rascal.tmLanguage.json +++ b/vscode-extension/syntaxes/rascal.tmLanguage.json @@ -1,7 +1,7 @@ { "repository": { "prod(lex(\"Comment\"),[lit(\"//\"),conditional(\\iter-star(\\char-class([range(1,9),range(11,1114111)])),{\\not-follow(\\char-class([range(9,9),range(13,13),range(32,32),range(160,160),range(5760,5760),range(8192,8202),range(8239,8239),range(8287,8287),range(12288,12288)])),\\end-of-line()})],{tag(\"category\"(\"comment\"))})": { - "match": "((?:\\x2F\\x2F)(?:(?:[\\x01-\\t]|[\\x0B-\\x{10FFFF}])*?(?!(?:[\\t-\\t]|[\\r-\\r]|[ - ]|[\\xA0-\\xA0]|[\\x{1680}-\\x{1680}]|[\\x{2000}-\\x{200A}]|[\\x{202F}-\\x{202F}]|[\\x{205F}-\\x{205F}]|[\\x{3000}-\\x{3000}]))(?:$)))", + "match": "((?:\\/\\/)(?:(?:[\\x01-\\t]|[\\x0B-\\x{10FFFF}])*?(?!(?:[\\t-\\t]|[\\r-\\r]|[ - ]|[\\xA0-\\xA0]|[\\x{1680}-\\x{1680}]|[\\x{2000}-\\x{200A}]|[\\x{202F}-\\x{202F}]|[\\x{205F}-\\x{205F}]|[\\x{3000}-\\x{3000}]))(?:$)))", "name": "prod(lex(\"Comment\"),[lit(\"//\"),conditional(\\iter-star(\\char-class([range(1,9),range(11,1114111)])),{\\not-follow(\\char-class([range(9,9),range(13,13),range(32,32),range(160,160),range(5760,5760),range(8192,8202),range(8239,8239),range(8287,8287),range(12288,12288)])),\\end-of-line()})],{tag(\"category\"(\"comment\"))})", "captures": { "1": { @@ -19,16 +19,16 @@ } }, "prod(lex(\"delimiters\"),[alt({lit(\"bottom-up-break\"),lit(\")\"),lit(\"≫\"),lit(\"\\n\"),lit(\"!:=\"),lit(\"\\'\"),lit(\"!=\"),lit(\"\\>=\"),lit(\"://\"),lit(\"non-assoc\"),lit(\"&=\"),lit(\"\\<-\"),lit(\"*=\"),lit(\"+=\"),lit(\"top-down-break\"),lit(\",\"),lit(\"...\"),lit(\"/=\"),lit(\"⇨\"),lit(\"(\"),lit(\"*/\"),lit(\"%\"),lit(\"!\\<\\<\"),lit(\"=\\>\"),lit(\"!\\>\\>\"),lit(\"||\"),lit(\"\\>\\>\"),lit(\"::\"),lit(\"⚠\"),lit(\"&&\"),lit(\"@\"),lit(\":=\"),lit(\"#\"),lit(\"\\<==\\>\"),lit(\"\\\"\"),lit(\"\\<\\<=\"),lit(\"}\"),lit(\"?=\"),lit(\"\\<:\"),lit(\"==\\>\"),lit(\"^\"),lit(\"/*\"),lit(\";\"),lit(\"{\"),lit(\"-=\"),lit(\"$T\")})],{})": { - "match": "(?:(?:bottom\\x2Dup\\x2Dbreak)|(?:\\x29)|(?:\\x{226B})|(?:\\n)|(?:\\x21\\x3A\\x3D)|(?:\\x27)|(?:\\x21\\x3D)|(?:\\x3E\\x3D)|(?:\\x3A\\x2F\\x2F)|(?:non\\x2Dassoc)|(?:\\x26\\x3D)|(?:\\x3C\\x2D)|(?:\\x2A\\x3D)|(?:\\x2B\\x3D)|(?:top\\x2Ddown\\x2Dbreak)|(?:\\x2C)|(?:\\x2E\\x2E\\x2E)|(?:\\x2F\\x3D)|(?:\\x{21E8})|(?:\\x28)|(?:\\x2A\\x2F)|(?:\\x25)|(?:\\x21\\x3C\\x3C)|(?:\\x3D\\x3E)|(?:\\x21\\x3E\\x3E)|(?:\\x7C\\x7C)|(?:\\x3E\\x3E)|(?:\\x3A\\x3A)|(?:\\x{26A0})|(?:\\x26\\x26)|(?:\\x40)|(?:\\x3A\\x3D)|(?:\\x23)|(?:\\x3C\\x3D\\x3D\\x3E)|(?:\\x22)|(?:\\x3C\\x3C\\x3D)|(?:\\x7D)|(?:\\x3F\\x3D)|(?:\\x3C\\x3A)|(?:\\x3D\\x3D\\x3E)|(?:\\x5E)|(?:\\x2F\\x2A)|(?:\\x3B)|(?:\\x7B)|(?:\\x2D\\x3D)|(?:\\x24T))", + "match": "(?:(?:bottom\\-up\\-break)|(?:\\))|(?:\\x{226B})|(?:\\n)|(?:\\!\\:\\=)|(?:')|(?:\\!\\=)|(?:\\>\\=)|(?:\\:\\/\\/)|(?:non\\-assoc)|(?:\\&\\=)|(?:\\<\\-)|(?:\\*\\=)|(?:\\+\\=)|(?:top\\-down\\-break)|(?:\\,)|(?:\\.\\.\\.)|(?:\\/\\=)|(?:\\x{21E8})|(?:\\()|(?:\\*\\/)|(?:\\%)|(?:\\!\\<\\<)|(?:\\=\\>)|(?:\\!\\>\\>)|(?:\\|\\|)|(?:\\>\\>)|(?:\\:\\:)|(?:\\x{26A0})|(?:\\&\\&)|(?:\\@)|(?:\\:\\=)|(?:\\#)|(?:\\<\\=\\=\\>)|(?:\")|(?:\\<\\<\\=)|(?:\\{)|(?:\\?\\=)|(?:\\<\\:)|(?:\\=\\=\\>)|(?:\\^)|(?:\\/\\*)|(?:\\;)|(?:\\{)|(?:\\-\\=)|(?:\\$T))", "name": "prod(lex(\"delimiters\"),[alt({lit(\"bottom-up-break\"),lit(\")\"),lit(\"≫\"),lit(\"\\n\"),lit(\"!:=\"),lit(\"\\'\"),lit(\"!=\"),lit(\"\\>=\"),lit(\"://\"),lit(\"non-assoc\"),lit(\"&=\"),lit(\"\\<-\"),lit(\"*=\"),lit(\"+=\"),lit(\"top-down-break\"),lit(\",\"),lit(\"...\"),lit(\"/=\"),lit(\"⇨\"),lit(\"(\"),lit(\"*/\"),lit(\"%\"),lit(\"!\\<\\<\"),lit(\"=\\>\"),lit(\"!\\>\\>\"),lit(\"||\"),lit(\"\\>\\>\"),lit(\"::\"),lit(\"⚠\"),lit(\"&&\"),lit(\"@\"),lit(\":=\"),lit(\"#\"),lit(\"\\<==\\>\"),lit(\"\\\"\"),lit(\"\\<\\<=\"),lit(\"}\"),lit(\"?=\"),lit(\"\\<:\"),lit(\"==\\>\"),lit(\"^\"),lit(\"/*\"),lit(\";\"),lit(\"{\"),lit(\"-=\"),lit(\"$T\")})],{})", "captures": {} }, "lit(\"`\"):lit(\"`\")": { - "begin": "(?:\\x60)", - "end": "(?:\\x60)", + "begin": "(?:\\`)", + "end": "(?:\\`)", "patterns": [ { - "match": "(\\x5C\\x5C)", + "match": "(\\\\\\\\)", "name": "prod(label(\"bs\",lex(\"ConcretePart\")),[lit(\"\\\\\\\\\")],{tag(\"category\"(\"string\"))})", "captures": { "1": { @@ -37,7 +37,7 @@ } }, { - "match": "(\\x5C\\x3E)", + "match": "(\\\\\\>)", "name": "prod(label(\"gt\",lex(\"ConcretePart\")),[lit(\"\\\\\\>\")],{tag(\"category\"(\"string\"))})", "captures": { "1": { @@ -46,7 +46,7 @@ } }, { - "match": "((?:[\\x01-\\t]|[\\x0B-\\x3B]|[\\x3D-\\x3D]|[\\x3F-\\x5B]|[\\x5D-\\x5F]|[a-\\x{10FFFF}])+?(?!(?:[\\x01-\\t]|[\\x0B-\\x3B]|[\\x3D-\\x3D]|[\\x3F-\\x5B]|[\\x5D-\\x5F]|[a-\\x{10FFFF}])))", + "match": "((?:[\\x01-\\t]|[\\x0B-\\;]|[\\=-\\=]|[\\?-\\[]|[\\]-\\_]|[a-\\x{10FFFF}])+?(?!(?:[\\x01-\\t]|[\\x0B-\\;]|[\\=-\\=]|[\\?-\\[]|[\\]-\\_]|[a-\\x{10FFFF}])))", "name": "prod(label(\"text\",lex(\"ConcretePart\")),[conditional(iter(\\char-class([range(1,9),range(11,59),range(61,61),range(63,91),range(93,95),range(97,1114111)])),{\\not-follow(\\char-class([range(1,9),range(11,59),range(61,61),range(63,91),range(93,95),range(97,1114111)]))})],{tag(\"category\"(\"string\"))})", "captures": { "1": { @@ -55,7 +55,7 @@ } }, { - "match": "(\\x5C\\x3C)", + "match": "(\\\\\\<)", "name": "prod(label(\"lt\",lex(\"ConcretePart\")),[lit(\"\\\\\\<\")],{tag(\"category\"(\"string\"))})", "captures": { "1": { @@ -64,7 +64,7 @@ } }, { - "match": "(\\x5C\\x60)", + "match": "(\\\\\\`)", "name": "prod(label(\"bq\",lex(\"ConcretePart\")),[lit(\"\\\\`\")],{tag(\"category\"(\"string\"))})", "captures": { "1": { @@ -76,11 +76,11 @@ "name": "lit(\"`\"):lit(\"`\")" }, "lit(\"[\"):lit(\"]\")": { - "begin": "(?:\\x5B)", - "end": "(?:\\x5D)", + "begin": "(?:\\[)", + "end": "(?:\\])", "patterns": [ { - "match": "((?:\\x5C)(?:[ - ]|[\\x22-\\x22]|[\\x27-\\x27]|[\\x2D-\\x2D]|[\\x3C-\\x3C]|[\\x3E-\\x3E]|[\\x5B-\\x5D]|[b-b]|[f-f]|[n-n]|[r-r]|[t-t]))", + "match": "((?:\\\\)(?:[ - ]|[\"-\"]|['-']|[\\--\\-]|[\\<-\\<]|[\\>-\\>]|[\\[-\\]]|[b-b]|[f-f]|[n-n]|[r-r]|[t-t]))", "name": "prod(lex(\"Char\"),[lit(\"\\\\\"),\\char-class([range(32,32),range(34,34),range(39,39),range(45,45),range(60,60),range(62,62),range(91,93),range(98,98),range(102,102),range(110,110),range(114,114),range(116,116)])],{tag(\"category\"(\"constant\"))})", "captures": { "1": { @@ -89,7 +89,7 @@ } }, { - "match": "((?:(?:\\x5C)[U-U](?:(?:\\b10\\b)|(?:(?:\\b0\\b)(?:[0-9]|[A-F]|[a-f])))(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f]))|(?:(?:\\x5C)[u-u](?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f]))|(?:(?:\\x5C)[a-a][0-7](?:[0-9]|[A-F]|[a-f])))", + "match": "((?:(?:\\\\)[U-U](?:(?:\\b10\\b)|(?:(?:\\b0\\b)(?:[0-9]|[A-F]|[a-f])))(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f]))|(?:(?:\\\\)[u-u](?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f])(?:[0-9]|[A-F]|[a-f]))|(?:(?:\\\\)[a-a][0-7](?:[0-9]|[A-F]|[a-f])))", "name": "prod(lex(\"Char\"),[lex(\"UnicodeEscape\")],{tag(\"category\"(\"constant\"))})", "captures": { "1": {