Update shellscript grammar (#176491)

This commit is contained in:
Alex Ross 2023-03-08 11:18:43 +01:00 committed by GitHub
parent 815295b041
commit 8ca37ee70f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 41 deletions

View file

@ -6,11 +6,11 @@
"git": {
"name": "jeff-hykin/better-shell-syntax",
"repositoryUrl": "https://github.com/jeff-hykin/better-shell-syntax",
"commitHash": "cad030fa5eb8cdfa35ea417b04d11552057557d4"
"commitHash": "02e55c164ef9a5b1754ba1caa184b966e7a69a44"
}
},
"license": "MIT",
"version": "1.4.1"
"version": "1.4.4"
}
],
"version": 1

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/jeff-hykin/better-shell-syntax/commit/cad030fa5eb8cdfa35ea417b04d11552057557d4",
"version": "https://github.com/jeff-hykin/better-shell-syntax/commit/02e55c164ef9a5b1754ba1caa184b966e7a69a44",
"name": "Shell Script",
"scopeName": "source.shell",
"patterns": [
@ -14,8 +14,8 @@
],
"repository": {
"alias_statement": {
"begin": "(alias)[ \\t]*+[ \\t]*+(?:((?<=^|;|&|\\s)(?:export|declare|typeset|local|readonly)(?=\\s|;|&|$))[ \\t]*+)?((?<!\\w)[a-zA-Z_0-9-]+(?!\\w))(?:(\\[)((?:(?:(?:\\$)?(?<!\\w)[a-zA-Z_0-9-]+(?!\\w)|@)|\\*))(\\]))?(?:(?:(\\=)|(\\+\\=))|(\\-\\=))",
"end": "(?:(?= |$)|(?:(?:(?:(?:(;)|(&&))|(\\|\\|))|(&))|\\n))",
"begin": "(alias)[ \\t]*+[ \\t]*+(?:((?<=^|;|&|[ \\t])(?:export|declare|typeset|local|readonly)(?=[ \\t]|;|&|$))[ \\t]*+)?((?<!\\w)[a-zA-Z_0-9-]+(?!\\w))(?:(\\[)((?:(?:(?:\\$)?(?<!\\w)[a-zA-Z_0-9-]+(?!\\w)|@)|\\*))(\\]))?(?:(?:(\\=)|(\\+\\=))|(\\-\\=))",
"end": "(?:(?= |\\t|$)|(?:(?:(?:(?:(;)|(&&))|(\\|\\|))|(&))|\\n))",
"beginCaptures": {
"1": {
"name": "storage.type.alias.shell"
@ -67,8 +67,8 @@
]
},
"argument": {
"begin": "\\s++(?!(?:%|&|\\||\\(|\\[|#|\\n|$|;))",
"end": "(?=\\s|;|\\||&|$|\\n|\\)|\\`)",
"begin": "[ \\t]++(?!(?:%|&|\\||\\(|\\[|#|\\n|$|;))",
"end": "(?= |\\t|;|\\||&|$|\\n|\\)|\\`)",
"beginCaptures": {},
"endCaptures": {},
"name": "meta.argument.shell",
@ -84,7 +84,7 @@
"argument_context": {
"patterns": [
{
"match": "[ \\t]*+([^ \n'&;<>\\(\\)\\$`\\\\\"\\|]+(?!>))",
"match": "[ \\t]*+([^ \t\n'&;<>\\(\\)\\$`\\\\\"\\|]+(?!>))",
"captures": {
"1": {
"name": "string.unquoted.argument.shell",
@ -119,7 +119,7 @@
"assignment": {
"patterns": [
{
"begin": "[ \\t]*+(?:((?<=^|;|&|\\s)(?:export|declare|typeset|local|readonly)(?=\\s|;|&|$))[ \\t]*+)?((?<!\\w)[a-zA-Z_0-9-]+(?!\\w))(?:(\\[)((?:(?:(?:\\$)?(?<!\\w)[a-zA-Z_0-9-]+(?!\\w)|@)|\\*))(\\]))?(?:(?:(\\=)|(\\+\\=))|(\\-\\=))[ \\t]*+(\\()",
"begin": "[ \\t]*+(?:((?<=^|;|&|[ \\t])(?:export|declare|typeset|local|readonly)(?=[ \\t]|;|&|$))[ \\t]*+)?((?<!\\w)[a-zA-Z_0-9-]+(?!\\w))(?:(\\[)((?:(?:(?:\\$)?(?<!\\w)[a-zA-Z_0-9-]+(?!\\w)|@)|\\*))(\\]))?(?:(?:(\\=)|(\\+\\=))|(\\-\\=))[ \\t]*+(\\()",
"end": "\\)",
"beginCaptures": {
"1": {
@ -166,8 +166,8 @@
]
},
{
"begin": "[ \\t]*+(?:((?<=^|;|&|\\s)(?:export|declare|typeset|local|readonly)(?=\\s|;|&|$))[ \\t]*+)?((?<!\\w)[a-zA-Z_0-9-]+(?!\\w))(?:(\\[)((?:(?:(?:\\$)?(?<!\\w)[a-zA-Z_0-9-]+(?!\\w)|@)|\\*))(\\]))?(?:(?:(\\=)|(\\+\\=))|(\\-\\=))",
"end": "(?:(?= |$)|(?:(?:(?:(?:(;)|(&&))|(\\|\\|))|(&))|\\n))",
"begin": "[ \\t]*+(?:((?<=^|;|&|[ \\t])(?:export|declare|typeset|local|readonly)(?=[ \\t]|;|&|$))[ \\t]*+)?((?<!\\w)[a-zA-Z_0-9-]+(?!\\w))(?:(\\[)((?:(?:(?:\\$)?(?<!\\w)[a-zA-Z_0-9-]+(?!\\w)|@)|\\*))(\\]))?(?:(?:(\\=)|(\\+\\=))|(\\-\\=))",
"end": "(?:(?= |\\t|$)|(?:(?:(?:(?:(;)|(&&))|(\\|\\|))|(&))|\\n))",
"beginCaptures": {
"1": {
"name": "storage.modifier.$1.shell"
@ -221,7 +221,7 @@
]
},
"basic_command_name": {
"match": "(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|\\s))(?!foreach\\b(?!\\/)|select\\b(?!\\/)|repeat\\b(?!\\/)|until\\b(?!\\/)|while\\b(?!\\/)|case\\b(?!\\/)|done\\b(?!\\/)|elif\\b(?!\\/)|else\\b(?!\\/)|esac\\b(?!\\/)|then\\b(?!\\/)|for\\b(?!\\/)|end\\b(?!\\/)|in\\b(?!\\/)|fi\\b(?!\\/)|do\\b(?!\\/)|if\\b(?!\\/))(?:((?<=^|;|&|\\s)(?:export|declare|typeset|local|readonly)(?=\\s|;|&|$))|((?!\"|'|\\\\\\n?$)[^!'\" \\t\\n\\r]+?))(?:(?=\\s)|(?=;|\\||&|\\n|\\)|\\`|\\{|\\}| *#|\\])(?<!\\\\))",
"match": "(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|[ \\t]))(?!foreach\\b(?!\\/)|select\\b(?!\\/)|repeat\\b(?!\\/)|until\\b(?!\\/)|while\\b(?!\\/)|case\\b(?!\\/)|done\\b(?!\\/)|elif\\b(?!\\/)|else\\b(?!\\/)|esac\\b(?!\\/)|then\\b(?!\\/)|for\\b(?!\\/)|end\\b(?!\\/)|in\\b(?!\\/)|fi\\b(?!\\/)|do\\b(?!\\/)|if\\b(?!\\/))(?:((?<=^|;|&|[ \\t])(?:export|declare|typeset|local|readonly)(?=[ \\t]|;|&|$))|((?!\"|'|\\\\\\n?$)[^!'\" \\t\\n\\r]+?))(?:(?= |\\t)|(?=;|\\||&|\\n|\\)|\\`|\\{|\\}|[ \\t]*#|\\])(?<!\\\\))",
"captures": {
"1": {
"name": "storage.modifier.$1.shell"
@ -234,7 +234,7 @@
"name": "keyword.control.$0.shell"
},
{
"match": "(?<!\\w)(?:unfunction|unsetopt|autoload|unlimit|bindkey|builtin|command|getopts|history|declare|unalias|typeset|suspend|return|source|ulimit|unhash|disown|which|alias|break|false|print|shift|times|umask|umask|unset|read|type|exec|eval|wait|echo|dirs|hash|jobs|kill|stat|exit|test|trap|true|pwd|let|set|cd|fg|bg|fc|:|\\.)(?!\\/)(?!\\w)",
"match": "(?<!\\w)(?:unfunction|unsetopt|autoload|suspend|bindkey|builtin|getopts|command|declare|unalias|history|unlimit|typeset|source|printf|unhash|disown|ulimit|return|which|alias|break|false|print|shift|times|umask|umask|unset|read|type|exec|eval|wait|echo|dirs|jobs|kill|hash|stat|exit|test|trap|true|let|set|pwd|cd|fg|bg|fc|:|\\.)(?!\\/)(?!\\w)",
"name": "support.function.builtin.shell"
},
{
@ -324,7 +324,7 @@
]
},
"comment": {
"match": "(?:^|\\s++)(?:((#!).*)|((#).*))",
"match": "(?:^|[ \\t]++)(?:((#!).*)|((#).*))",
"captures": {
"1": {
"name": "comment.line.number-sign.shell meta.shebang.shell"
@ -496,8 +496,8 @@
"name": "constant.character.escape.shell"
},
"function_definition": {
"begin": "[ \\t]*+(?:(\\bfunction )[ \\t]*+([^ \\t\\n\\r\\(\\)=]+)(?:(\\()[ \\t]*+(\\)))?|([^ \\t\\n\\r\\(\\)=]+)[ \\t]*+(\\()[ \\t]*+(\\)))",
"end": "(?<=\\})",
"begin": "[ \\t]*+(?:(\\bfunction\\b)[ \\t]*+([^ \\t\\n\\r\\(\\)=]+)(?:(\\()[ \\t]*+(\\)))?|([^ \\t\\n\\r\\(\\)=]+)[ \\t]*+(\\()[ \\t]*+(\\)))",
"end": "(?<=\\}|\\))",
"beginCaptures": {
"1": {
"name": "storage.type.function.shell"
@ -524,6 +524,9 @@
"endCaptures": {},
"name": "meta.function.shell",
"patterns": [
{
"match": "\\G(?:\\t| |\\n)"
},
{
"begin": "\\{",
"end": "\\}",
@ -543,8 +546,29 @@
"include": "#initial_context"
}
]
},
{
"begin": "\\(",
"end": "\\)",
"beginCaptures": {
"0": {
"name": "punctuation.definition.group.shell punctuation.section.function.definition.shell"
}
},
"endCaptures": {
"0": {
"name": "punctuation.definition.group.shell punctuation.section.function.definition.shell"
}
},
"name": "meta.function.body.shell",
"patterns": [
{
"include": "#initial_context"
}
]
}
]
],
"applyEndPatternLast": 1
},
"heredoc": {
"patterns": [
@ -928,7 +952,7 @@
"keyword": {
"patterns": [
{
"match": "(?<=^|;|&|\\s)(?:then|else|elif|fi|for|in|do|done|select|case|continue|esac|while|until|return)(?=\\s|;|&|$)",
"match": "(?<=^|;|&| |\\t)(?:then|else|elif|fi|for|in|do|done|select|case|continue|esac|while|until|return)(?= |\\t|;|&|$)",
"name": "keyword.control.$0.shell"
}
]
@ -1318,12 +1342,12 @@
]
},
"modifiers": {
"match": "(?<=^|;|&|\\s)(?:export|declare|typeset|local|readonly)(?=\\s|;|&|$)",
"match": "(?<=^|;|&|[ \\t])(?:export|declare|typeset|local|readonly)(?=[ \\t]|;|&|$)",
"name": "storage.modifier.$0.shell"
},
"normal_statement": {
"begin": "(?!^[ \\t]*+$)(?:(?<=^if | if |\\tif |^elif | elif |\\telif |^then | then |\\tthen |^else | else |\\telse |^while | while |\\twhile |^do | do |\\tdo )|(?<=(?:^|;|\\||&|!|\\(|\\{|\\`)))[ \\t]*+(?!nocorrect\\W|nocorrect\\$|function\\W|function\\$|foreach\\W|foreach\\$|repeat\\W|repeat\\$|logout\\W|logout\\$|coproc\\W|coproc\\$|select\\W|select\\$|while\\W|while\\$|pushd\\W|pushd\\$|until\\W|until\\$|case\\W|case\\$|done\\W|done\\$|elif\\W|elif\\$|else\\W|else\\$|esac\\W|esac\\$|popd\\W|popd\\$|then\\W|then\\$|time\\W|time\\$|for\\W|for\\$|end\\W|end\\$|fi\\W|fi\\$|do\\W|do\\$|in\\W|in\\$|if\\W|if\\$)",
"end": "(?=;|\\||&|\\n|\\)|\\`|\\{|\\}| *#|\\])(?<!\\\\)",
"end": "(?=;|\\||&|\\n|\\)|\\`|\\{|\\}|[ \\t]*#|\\])(?<!\\\\)",
"beginCaptures": {},
"endCaptures": {},
"name": "meta.statement.shell",
@ -1335,15 +1359,15 @@
"include": "#assignment"
},
{
"begin": "[ \\t]*+(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|\\s))(?!foreach\\b(?!\\/)|select\\b(?!\\/)|repeat\\b(?!\\/)|until\\b(?!\\/)|while\\b(?!\\/)|case\\b(?!\\/)|done\\b(?!\\/)|elif\\b(?!\\/)|else\\b(?!\\/)|esac\\b(?!\\/)|then\\b(?!\\/)|for\\b(?!\\/)|end\\b(?!\\/)|in\\b(?!\\/)|fi\\b(?!\\/)|do\\b(?!\\/)|if\\b(?!\\/))(?!\\\\\\n?$)",
"end": "(?=;|\\||&|\\n|\\)|\\`|\\{|\\}| *#|\\])(?<!\\\\)",
"begin": "[ \\t]*+(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|[ \\t]))(?!foreach\\b(?!\\/)|select\\b(?!\\/)|repeat\\b(?!\\/)|until\\b(?!\\/)|while\\b(?!\\/)|case\\b(?!\\/)|done\\b(?!\\/)|elif\\b(?!\\/)|else\\b(?!\\/)|esac\\b(?!\\/)|then\\b(?!\\/)|for\\b(?!\\/)|end\\b(?!\\/)|in\\b(?!\\/)|fi\\b(?!\\/)|do\\b(?!\\/)|if\\b(?!\\/))(?!\\\\\\n?$)",
"end": "(?=;|\\||&|\\n|\\)|\\`|\\{|\\}|[ \\t]*#|\\])(?<!\\\\)",
"beginCaptures": {},
"endCaptures": {},
"name": "meta.command.shell",
"patterns": [
{
"begin": "\\G",
"end": "(?=\\s|;|\\||&|$|\\n|\\)|\\`)",
"end": "(?= |\\t|;|\\||&|$|\\n|\\)|\\`)",
"beginCaptures": {},
"endCaptures": {},
"name": "meta.statement.command.name.shell",
@ -1356,7 +1380,7 @@
"name": "entity.name.command.shell keyword.control.$0.shell"
},
{
"match": "(?<!\\w)(?:unfunction|unsetopt|autoload|unlimit|bindkey|builtin|command|getopts|history|declare|unalias|typeset|suspend|return|source|ulimit|unhash|disown|which|alias|break|false|print|shift|times|umask|umask|unset|read|type|exec|eval|wait|echo|dirs|hash|jobs|kill|stat|exit|test|trap|true|pwd|let|set|cd|fg|bg|fc|:|\\.)(?!\\/)(?!\\w)",
"match": "(?<!\\w)(?:unfunction|unsetopt|autoload|suspend|bindkey|builtin|getopts|command|declare|unalias|history|unlimit|typeset|source|printf|unhash|disown|ulimit|return|which|alias|break|false|print|shift|times|umask|umask|unset|read|type|exec|eval|wait|echo|dirs|jobs|kill|hash|stat|exit|test|trap|true|let|set|pwd|cd|fg|bg|fc|:|\\.)(?!\\/)(?!\\w)",
"name": "entity.name.command.shell support.function.builtin.shell"
},
{
@ -1492,7 +1516,7 @@
}
},
"numeric_literal": {
"match": "((?<!\\w-)(?<!\\w)\\.?\\d(?:(?:[0-9a-zA-Z_\\.]|_)|(?<=[eEpP])[+-])*(?=\\s|$))",
"match": "((?<!\\w-)(?<!\\w)\\.?\\d(?:(?:[0-9a-zA-Z_\\.]|_)|(?<=[eEpP])[+-])*(?=[ \\t]|$))",
"captures": {
"1": {
"patterns": [
@ -1744,8 +1768,8 @@
"name": "constant.numeric.shell"
},
"option": {
"begin": "\\s++(-)((?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|\\s)))",
"end": "(?:(?=\\s)|(?=;|\\||&|\\n|\\)|\\`|\\{|\\}| *#|\\])(?<!\\\\))",
"begin": "[ \\t]++(-)((?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|[ \\t])))",
"end": "(?:(?=[ \\t])|(?=;|\\||&|\\n|\\)|\\`|\\{|\\}|[ \\t]*#|\\])(?<!\\\\))",
"beginCaptures": {
"1": {
"name": "string.unquoted.argument.shell constant.other.option.dash.shell"
@ -1844,7 +1868,7 @@
]
},
"redirect_number": {
"match": "(?<=\\s)(?:(1)|(2)|(\\d+))(?=>)",
"match": "(?<=[ \\t])(?:(1)|(2)|(\\d+))(?=>)",
"captures": {
"1": {
"name": "keyword.operator.redirect.stdout.shell"
@ -1897,12 +1921,12 @@
]
},
"simple_options": {
"match": "(?:\\s++\\-\\w+)*",
"match": "(?:[ \\t]++\\-\\w+)*",
"captures": {
"0": {
"patterns": [
{
"match": "\\s++(\\-)(\\w+)",
"match": "[ \\t]++(\\-)(\\w+)",
"captures": {
"1": {
"name": "string.unquoted.argument.shell constant.other.option.dash.shell"
@ -1917,10 +1941,10 @@
}
},
"start_of_command": {
"match": "[ \\t]*+(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|\\s))(?!foreach\\b(?!\\/)|select\\b(?!\\/)|repeat\\b(?!\\/)|until\\b(?!\\/)|while\\b(?!\\/)|case\\b(?!\\/)|done\\b(?!\\/)|elif\\b(?!\\/)|else\\b(?!\\/)|esac\\b(?!\\/)|then\\b(?!\\/)|for\\b(?!\\/)|end\\b(?!\\/)|in\\b(?!\\/)|fi\\b(?!\\/)|do\\b(?!\\/)|if\\b(?!\\/))(?!\\\\\\n?$)"
"match": "[ \\t]*+(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|[ \\t]))(?!foreach\\b(?!\\/)|select\\b(?!\\/)|repeat\\b(?!\\/)|until\\b(?!\\/)|while\\b(?!\\/)|case\\b(?!\\/)|done\\b(?!\\/)|elif\\b(?!\\/)|else\\b(?!\\/)|esac\\b(?!\\/)|then\\b(?!\\/)|for\\b(?!\\/)|end\\b(?!\\/)|in\\b(?!\\/)|fi\\b(?!\\/)|do\\b(?!\\/)|if\\b(?!\\/))(?!\\\\\\n?$)"
},
"start_of_double_quoted_command_name": {
"match": "(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|\\s))(?:[ \\t]*+([^ \n'&;<>\\(\\)\\$`\\\\\"\\|]+(?!>)))?(?:(?:\\$\")|\")",
"match": "(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|[ \\t]))(?:[ \\t]*+([^ \t\n'&;<>\\(\\)\\$`\\\\\"\\|]+(?!>)))?(?:(?:\\$\")|\")",
"captures": {
"1": {
"name": "entity.name.command.shell",
@ -1949,7 +1973,7 @@
"name": "meta.statement.command.name.quoted.shell string.quoted.double.shell punctuation.definition.string.begin.shell entity.name.command.shell"
},
"start_of_single_quoted_command_name": {
"match": "(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|\\s))(?:[ \\t]*+([^ \n'&;<>\\(\\)\\$`\\\\\"\\|]+(?!>)))?(?:(?:\\$')|')",
"match": "(?!(?:!|%|&|\\||\\(|\\)|\\{|\\[|<|>|#|\\n|$|;|[ \\t]))(?:[ \\t]*+([^ \t\n'&;<>\\(\\)\\$`\\\\\"\\|]+(?!>)))?(?:(?:\\$')|')",
"captures": {
"1": {
"name": "entity.name.command.shell",

View file

@ -603,16 +603,16 @@
},
{
"c": "printf",
"t": "source.shell meta.scope.if-block.shell meta.statement.shell meta.command.shell meta.statement.command.name.shell entity.name.command.shell",
"t": "source.shell meta.scope.if-block.shell meta.statement.shell meta.command.shell meta.statement.command.name.shell entity.name.command.shell support.function.builtin.shell",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_plus": "support.function: #DCDCAA",
"light_plus": "support.function: #795E26",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_plus_experimental": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_plus_experimental": "default: #3B3B3B"
"hc_black": "support.function: #DCDCAA",
"dark_plus_experimental": "support.function: #DCDCAA",
"hc_light": "support.function: #5E2CBC",
"light_plus_experimental": "support.function: #795E26"
}
},
{

View file

@ -2030,7 +2030,7 @@
}
},
{
"c": "function ",
"c": "function",
"t": "source.shell meta.function.shell storage.type.function.shell",
"r": {
"dark_plus": "storage.type: #569CD6",
@ -2043,6 +2043,20 @@
"light_plus_experimental": "storage.type: #0000FF"
}
},
{
"c": " ",
"t": "source.shell meta.function.shell",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_plus_experimental": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_plus_experimental": "default: #3B3B3B"
}
},
{
"c": "code",
"t": "source.shell meta.function.shell entity.name.function.shell",