This commit is contained in:
Alex Dima 2018-11-12 14:01:28 +01:00
parent 9961f06110
commit ad77f86a8c
2 changed files with 31 additions and 5 deletions

View file

@ -279,4 +279,13 @@ testTokenization('shell', [
{ startIndex: 4, type: 'string.heredoc.shell' }
]
}],
[{
line: 'echo $( echo "hi" )',
tokens: [
{ startIndex: 0, type: 'type.identifier.shell' },
{ startIndex: 4, type: 'white.shell' },
{ startIndex: 5, type: 'variable.shell' }
]
}],
])

View file

@ -201,13 +201,30 @@ export const language = <ILanguage>{
[/\$\d+/, 'variable.predefined'],
[/\$\w+/, 'variable'],
[/\$[*@#?\-$!0_]/, 'variable'],
[/\$['"{(]/, 'variable', '@parameterBody']
[/\$'/, 'variable', '@parameterBodyQuote'],
[/\$"/, 'variable', '@parameterBodyDoubleQuote'],
[/\$\(/, 'variable', '@parameterBodyParen'],
[/\$\{/, 'variable', '@parameterBodyCurlyBrace'],
],
parameterBody: [
parameterBodyQuote: [
[/[^#:%*@\-!_']+/, 'variable'],
[/[#:%*@\-!_]/, 'delimiter'],
[/['"{(]/, 'variable', '@pop'],
[/./, 'variable']
[/[']/, 'variable', '@pop'],
],
parameterBodyDoubleQuote: [
[/[^#:%*@\-!_"]+/, 'variable'],
[/[#:%*@\-!_]/, 'delimiter'],
[/["]/, 'variable', '@pop'],
],
parameterBodyParen: [
[/[^#:%*@\-!_)]+/, 'variable'],
[/[#:%*@\-!_]/, 'delimiter'],
[/[)]/, 'variable', '@pop'],
],
parameterBodyCurlyBrace: [
[/[^#:%*@\-!_}]+/, 'variable'],
[/[#:%*@\-!_]/, 'delimiter'],
[/[}]/, 'variable', '@pop'],
],
}
};