Update grammars (#239483)

Fixes #239353
This commit is contained in:
Alex Ross
2025-02-04 10:29:01 +01:00
committed by GitHub
parent 01e36597fe
commit c9948b69ee
13 changed files with 1564 additions and 400 deletions

View File

@@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/jtbandes/swift-tmlanguage/commit/860eface4241cf9f2174d5fa690bd34389ac8d26",
"version": "https://github.com/jtbandes/swift-tmlanguage/commit/b8d2889b4af1d8bad41578317a6adade642555a3",
"name": "Swift",
"scopeName": "source.swift",
"comment": "See swift.tmbundle/grammar-test.swift for test cases.",
@@ -3081,7 +3081,7 @@
{
"comment": "Single-line regular expression literals must be matched all in one go\n in order to avoid ambiguities with operators, and to adhere to certain\n parsing rules in SE-0354/SE-0355, such as:\n - A regex literal will not be parsed if it contains an unbalanced ).\n - A regex may end with a space only if it began with an escaped space",
"name": "string.regexp.line.swift",
"match": "(?x)\n(((\\#+)?)/) # (1) for captures, (2) for matching end, (3) for conditionals\n(?(3)|(?!/)) # is not a comment\n(?(3)|(?!\\s)) # does not start with a space or tab\n(\\\\\\s)? # (4) may start with an escaped space or tab\n(?<guts>\n (?> # no backtracking, avoids issues with negative lookbehind at end\n (?:\n \\\\Q\n (?:(?!\\\\E)(?!/\\2).)*+\n (?:\\\\E\n # A quoted sequence may not have a closing E, in which case it extends to the end of the regex\n | (?(3)|(?<!\\s))(?=/\\2)\n )\n | \\\\.\n | \\(\\?\\#[^)]*\\)\n | \\(\\?\n # we only support a fixed maximum number of braces because otherwise we can't balance the number of open and close braces\n \\{(?<g1>\\{)?+(?<g2>\\{)?+(?<g3>\\{)?+(?<g4>\\{)?+(?<g5>\\{)?+\n .+?\n \\}(?(<g1>)\\})(?(<g2>)\\})(?(<g3>)\\})(?(<g4>)\\})(?(<g5>)\\})\n (?:\\[(?!\\d)\\w+\\])?\n [X<>]?\n \\)\n | (?<class>\\[ (?:\\\\. | [^\\[\\]] | \\g<class>)+ \\])\n | \\(\\g<guts>?+\\)\n | (?:(?!/\\2)[^()\\[\\\\])+ # any character (until end)\n )+\n )\n)?+\n# may end with a space only if it is an extended literal or contains only a single escaped space\n(?(3)|(?(5)(?<!\\s)))\n(/\\2) # (12)\n| \\#+/.+(\\n)",
"match": "(?x)\n(?!/\\s) # non-extended regex literals may not start with a space or tab\n(?!//) # disambiguation with line comments (redundant since comment rules occur earlier)\n(((\\#+)?)/) # (1) for captures, (2) for matching end, (3) for conditionals\n(\\\\\\s)? # (4) may start with an escaped space or tab\n(?<guts>\n (?> # no backtracking, avoids issues with negative lookbehind at end\n (?:\n \\\\Q\n (?:(?!\\\\E)(?!/\\2).)*+\n (?:\\\\E\n # A quoted sequence may not have a closing E, in which case it extends to the end of the regex\n | (?(3)|(?<!\\s))(?=/\\2)\n )\n | \\\\.\n | \\(\\?\\#[^)]*\\)\n | \\(\\?\n # InterpolatedCallout\n (?>(\\{(?:\\g<-1>|(?!{).*?)\\}))\n (?:\\[(?!\\d)\\w+\\])?\n [X<>]?\n \\)\n | (?<class>\\[ (?:\\\\. | [^\\[\\]] | \\g<class>)+ \\])\n | \\(\\g<guts>?+\\)\n | (?:(?!/\\2)[^()\\[\\\\])+ # any character (until end)\n )+\n )\n)?+\n# may end with a space only if it is an extended literal or contains only a single escaped space\n(?(3)|(?(5)(?<!\\s)))\n(/\\2) # (12)\n| \\#+/.+(\\n)",
"captures": {
"0": {
"patterns": [
@@ -3093,10 +3093,10 @@
"1": {
"name": "punctuation.definition.string.begin.regexp.swift"
},
"12": {
"8": {
"name": "punctuation.definition.string.end.regexp.swift"
},
"13": {
"9": {
"name": "invalid.illegal.returns-not-allowed.regexp"
}
}
@@ -3155,31 +3155,61 @@
}
},
{
"comment": "'\\k<' NamedOrNumberRef '>'\n \"\\k'\" NamedOrNumberRef \"'\"\n '\\g<' NamedOrNumberRef '>'\n \"\\g'\" NamedOrNumberRef \"'\"",
"match": "(?x)(\\\\[gk](<)|\\\\[gk]') (?: ((?!\\d)\\w+) (?:([+-])(\\d+))? | ([+-]?\\d+) (?:([+-])(\\d+))? ) ((?(2)>|'))",
"comment": "'\\k<' NamedOrNumberRef '>'\n '\\g<' NamedOrNumberRef '>'",
"match": "(?x)(\\\\[gk]<) (?: ((?!\\d)\\w+) (?:([+-])(\\d+))? | ([+-]?\\d+) (?:([+-])(\\d+))? ) (>)",
"captures": {
"1": {
"name": "constant.character.escape.backslash.regexp"
},
"3": {
"2": {
"name": "variable.other.group-name.regexp"
},
"4": {
"3": {
"name": "keyword.operator.recursion-level.regexp"
},
"4": {
"name": "constant.numeric.integer.decimal.regexp"
},
"5": {
"name": "constant.numeric.integer.decimal.regexp"
},
"6": {
"name": "constant.numeric.integer.decimal.regexp"
},
"7": {
"name": "keyword.operator.recursion-level.regexp"
},
"8": {
"7": {
"name": "constant.numeric.integer.decimal.regexp"
},
"9": {
"8": {
"name": "constant.character.escape.backslash.regexp"
}
}
},
{
"comment": "\"\\k'\" NamedOrNumberRef \"'\"\n \"\\g'\" NamedOrNumberRef \"'\"",
"match": "(?x)(\\\\[gk]') (?: ((?!\\d)\\w+) (?:([+-])(\\d+))? | ([+-]?\\d+) (?:([+-])(\\d+))? ) (')",
"captures": {
"1": {
"name": "constant.character.escape.backslash.regexp"
},
"2": {
"name": "variable.other.group-name.regexp"
},
"3": {
"name": "keyword.operator.recursion-level.regexp"
},
"4": {
"name": "constant.numeric.integer.decimal.regexp"
},
"5": {
"name": "constant.numeric.integer.decimal.regexp"
},
"6": {
"name": "keyword.operator.recursion-level.regexp"
},
"7": {
"name": "constant.numeric.integer.decimal.regexp"
},
"8": {
"name": "constant.character.escape.backslash.regexp"
}
}
@@ -3291,7 +3321,7 @@
},
"literals-regular-expression-literal-callout": {
"name": "meta.callout.regexp",
"match": "(?x)\n# PCRECallout\n(\\()(?<keyw>\\?C)\n (?:\n (?<num>\\d+)\n | `(?<name>(?:[^`]|``)*)`\n | '(?<name>(?:[^']|'')*)'\n | \"(?<name>(?:[^\"]|\"\")*)\"\n | \\^(?<name>(?:[^\\^]|\\^\\^)*)\\^\n | %(?<name>(?:[^%]|%%)*)%\n | \\#(?<name>(?:[^#]|\\#\\#)*)\\#\n | \\$(?<name>(?:[^$]|\\$\\$)*)\\$\n | \\{(?<name>(?:[^}]|\\}\\})*)\\}\n )?\n(\\))\n# NamedCallout\n| (\\()(?<keyw>\\*)\n (?<name>(?!\\d)\\w+)\n (?:\\[(?<tag>(?!\\d)\\w+)\\])?\n (?:\\{ [^,}]+ (?:,[^,}]+)* \\})?\n (\\))\n# InterpolatedCallout\n| (\\()(?<keyw>\\?)\n # we only support a fixed maximum number of braces because otherwise we can't balance the number of open and close braces\n (\\{(?<g1>\\{)?+(?<g2>\\{)?+(?<g3>\\{)?+(?<g4>\\{)?+(?<g5>\\{)?+) .+? \\}(?(<g1>)\\})(?(<g2>)\\})(?(<g3>)\\})(?(<g4>)\\})(?(<g5>)\\})\n (?:\\[(?<tag>(?!\\d)\\w+)\\])?\n (?<keyw>[X<>]?)\n (\\))",
"match": "(?x)\n# PCRECallout\n(\\()(?<keyw>\\?C)\n (?:\n (?<num>\\d+)\n | `(?<name>(?:[^`]|``)*)`\n | '(?<name>(?:[^']|'')*)'\n | \"(?<name>(?:[^\"]|\"\")*)\"\n | \\^(?<name>(?:[^\\^]|\\^\\^)*)\\^\n | %(?<name>(?:[^%]|%%)*)%\n | \\#(?<name>(?:[^#]|\\#\\#)*)\\#\n | \\$(?<name>(?:[^$]|\\$\\$)*)\\$\n | \\{(?<name>(?:[^}]|\\}\\})*)\\}\n )?\n(\\))\n# NamedCallout\n| (\\()(?<keyw>\\*)\n (?<name>(?!\\d)\\w+)\n (?:\\[(?<tag>(?!\\d)\\w+)\\])?\n (?:\\{ [^,}]+ (?:,[^,}]+)* \\})?\n (\\))\n# InterpolatedCallout\n| (\\()(?<keyw>\\?)\n (?>(\\{(?:\\g<-1>|(?!{).*?)\\}))\n (?:\\[(?<tag>(?!\\d)\\w+)\\])?\n (?<keyw>[X<>]?)\n (\\))",
"captures": {
"1": {
"name": "punctuation.definition.group.regexp"
@@ -3350,13 +3380,13 @@
"19": {
"name": "keyword.control.callout.regexp"
},
"26": {
"21": {
"name": "variable.language.tag-name.regexp"
},
"27": {
"22": {
"name": "keyword.control.callout.regexp"
},
"28": {
"23": {
"name": "punctuation.definition.group.regexp"
}
}