// This is a TextMate grammar distributed by `starry-night`. // This grammar is developed at // // and licensed `mpl-2.0`. // See for more info. /** * @import {Grammar} from '@wooorm/starry-night' */ /** @type {Grammar} */ const grammar = { extensions: ['.rhai'], names: ['rhai'], patterns: [{include: '#core'}], repository: { brackets: { patterns: [ {include: '#round-brackets'}, {include: '#square-brackets'}, {include: '#curly-brackets'} ] }, comments: { patterns: [ { begin: '/\\*\\*(?![/|\\*])', captures: { 0: {name: 'punctuation.definition.comment.block.documentation.rhai'} }, end: '\\*/', name: 'comment.block.documentation.rhai', patterns: [{include: '#comments'}] }, { begin: '/\\*', captures: {0: {name: 'punctuation.definition.comment.block.rhai'}}, end: '\\*/', name: 'comment.block.rhai', patterns: [{include: '#comments'}] }, { captures: { 1: {name: 'punctuation.definition.comment.documentation.rhai'} }, match: '(///)[^/].*$\\n?', name: 'comment.line.documentation.rhai' }, { captures: { 1: {name: 'punctuation.definition.comment.double-slash.rhai'} }, match: '(//).*$\\n?', name: 'comment.line.double-slash.rhai' }, { captures: {1: {name: 'punctuation.definition.comment.rhai'}}, match: '^(#!).*$\\n?', name: 'comment.line.shebang.rhai' } ] }, core: {patterns: [{include: '#expression'}]}, 'curly-brackets': { patterns: [ { begin: '\\{', beginCaptures: {0: {name: 'meta.brace.curly.rhai'}}, end: '\\}', endCaptures: {0: {name: 'meta.brace.curly.rhai'}}, name: 'meta.group.braces.curly', patterns: [{include: '$self'}] } ] }, expression: { patterns: [ {include: '#literal-closure-labels'}, {include: '#literal-labels'}, {include: '#literal-keywords'}, {include: '#support'}, {include: '#literal-function'}, {include: '#literal-closure'}, {include: '#literal-constant'}, {include: '#literal-template-string'}, {include: '#literal-language-variable'}, {include: '#literal-module'}, {include: '#literal-method-call'}, {include: '#literal-function-call'}, {include: '#comments'}, {include: '#brackets'}, {include: '#literal-operators'}, {include: '#literal-namespace'}, {include: '#literal-variable'}, {include: '#literal-punctuation'} ] }, 'function-declaration-parameters': { patterns: [ { begin: '\\(', beginCaptures: { 0: {name: 'punctuation.definition.parameters.begin.rhai'} }, end: '\\)', endCaptures: { 0: {name: 'punctuation.definition.parameters.end.rhai'} }, patterns: [ {match: '[_a-zA-Z]\\w*', name: 'variable.parameter.function.rhai'}, { match: '\\,', name: 'punctuation.separator.parameter.function.rhai' }, {include: '#parameters-list'} ] } ] }, 'literal-closure': { patterns: [ { begin: '(\\|)(?=\\s*[_a-zA-Z\\|])', beginCaptures: { 1: {name: 'punctuation.definition.parameters.closure.begin.rhai'} }, end: '(\\|)', endCaptures: { 1: {name: 'punctuation.definition.parameters.closure.end.rhai'} }, name: 'meta.function.closure.rhai', patterns: [{include: '#parameters-list'}] }, { begin: '(\\b[_a-zA-Z]\\w*)\\s*(=)\\s*(\\|)(?=\\s*[_a-zA-Z\\|])', beginCaptures: { 1: {name: 'entity.name.function.closure.rhai'}, 2: {name: 'keyword.operator.assignment.rhai'}, 3: {name: 'punctuation.definition.parameters.closure.begin.rhai'} }, end: '(\\|)', endCaptures: { 1: {name: 'punctuation.definition.parameters.closure.end.rhai'} }, name: 'meta.function.closure.rhai', patterns: [{include: '#parameters-list'}] }, { begin: '(=>)\\s*(\\|)(?=\\s*[_a-zA-Z\\|])', beginCaptures: { 1: {name: 'punctuation.separator.switch.case.rhai'}, 2: {name: 'punctuation.definition.parameters.closure.begin.rhai'} }, end: '(\\|)', endCaptures: { 1: {name: 'punctuation.definition.parameters.closure.end.rhai'} }, name: 'meta.function.closure.rhai', patterns: [{include: '#parameters-list'}] } ] }, 'literal-closure-labels': { patterns: [ { begin: '(\\b[_a-zA-Z]\\w*)\\s*(\\:)\\s*(\\|)(?=\\s*[_a-zA-Z\\|])', beginCaptures: { 1: { name: 'string.unquoted.label.rhai entity.name.function.method.rhai' }, 2: {name: 'punctuation.separator.key-value.rhai'}, 3: {name: 'punctuation.definition.parameters.closure.begin.rhai'} }, end: '(\\|)', endCaptures: { 1: {name: 'punctuation.definition.parameters.closure.end.rhai'} }, name: 'meta.function.closure.rhai', patterns: [{include: '#parameters-list'}] }, { begin: '((\\")((?:[^"]|\\\\")*)(\\"))\\s*(:)\\s*(\\|)(?=\\s*[_a-zA-Z\\|])', beginCaptures: { 1: {name: 'string.quoted.double.rhai'}, 2: {name: 'punctuation.definition.string.begin.rhai'}, 3: {name: 'entity.name.function.method.rhai'}, 4: {name: 'punctuation.definition.string.end.rhai'}, 5: {name: 'punctuation.separator.key-value.rhai'}, 6: {name: 'punctuation.definition.parameters.closure.begin.rhai'} }, end: '(\\|)', endCaptures: { 1: {name: 'punctuation.definition.parameters.closure.end.rhai'} }, name: 'meta.function.closure.rhai', patterns: [{include: '#parameters-list'}] } ] }, 'literal-constant': { patterns: [ {include: '#literal-number'}, {include: '#literal-string'}, {include: '#literal-language-constant'} ] }, 'literal-function': { patterns: [ { begin: '(?x)\n (?:\\b(private)\\s+)?\n \\s*(fn)\n \\s*([_a-zA-Z]\\w*)\\s*', beginCaptures: { 1: {name: 'storage.modifier.rhai'}, 2: {name: 'storage.type.function.rhai'}, 3: {name: 'entity.name.function.rhai'} }, end: '(?<=\\))', name: 'meta.function.rhai', patterns: [{include: '#parameters-list'}] }, {match: '\\b(fn)\\b', name: 'keyword.other.function.rhai'}, {match: '\\b(private)\\b', name: 'keyword.other.modifier.rhai'} ] }, 'literal-function-call': { patterns: [ { captures: { 1: {name: 'entity.name.function.rhai'}, 2: {name: 'punctuation.function-call.capture.rhai'}, 3: {name: 'meta.group.braces.round.function.arguments.rhai'} }, match: '(?x)\n ([_a-zA-Z]\\w*)(!)?\\s*\n (\\(\\s*\\))', name: 'meta.function-call.without-arguments.rhai' }, { captures: { 1: {name: 'entity.name.function.rhai'}, 2: {name: 'punctuation.function-call.capture.rhai'} }, match: '(?x)\n ([_a-zA-Z]\\w*)(!)?\\s*\n (?=\\()', name: 'meta.function-call.with-arguments.rhai' } ] }, 'literal-keyword-storage': { patterns: [{match: '\\b(const|let)\\b', name: 'storage.type.rhai'}] }, 'literal-keywords': { patterns: [ {include: '#literal-keyword-storage'}, {match: '\\b(return)\\b', name: 'keyword.control.flow.rhai'}, { match: '\\b(if|else|switch)\\b', name: 'keyword.control.conditional.rhai' }, { match: '\\b(throw|try|catch)\\b', name: 'keyword.control.trycatch.rhai' }, { match: '\\b(for|in|loop|do|while|until|break|continue)\\b', name: 'keyword.control.loop.rhai' } ] }, 'literal-labels': { patterns: [ { begin: '(?x)\n (?]) # assignment right-to-left both', name: 'keyword.operator.assignment.rhai' }, { match: '(?x)\n %= | # assignment right-to-left both\n &= | # assignment right-to-left both\n \\*\\*=| # assignment right-to-left both\n (?>= # assignment right-to-left both', name: 'keyword.operator.assignment.augmented.rhai' }, { match: '(?x)\n << | # bitwise-shift left-to-right both\n >> | # bitwise-shift left-to-right both\n & | # bitwise-and left-to-right both\n \\^ | # bitwise-xor left-to-right both\n \\| # bitwise-or left-to-right both', name: 'keyword.operator.bitwise.rhai' }, { match: '(?x)\n <= | # relational left-to-right both\n >= | # relational left-to-right both\n <(?!-) | # relational left-to-right both\n (? # relational left-to-right both', name: 'keyword.operator.relational.rhai' }, { match: '(?x)\n ==(?!=) | # equality left-to-right both\n !=(?!=) # equality left-to-right both', name: 'keyword.operator.comparison.rhai' }, { match: '(?x)\n / | # division left-to-right both\n % | # modulus left-to-right both\n \\*\\* | # power left-to-right both\n \\*(?!\\)) | # multiplication left-to-right both\n \\+(?!\\+) | # addition left-to-right both\n -(?![>-]) # subtraction left-to-right both', name: 'keyword.operator.arithmetic.rhai' }, { match: '\\.\\.(?![\\.=])', name: 'keyword.operator.range.exclusive.rhai' }, {match: '\\.\\.=', name: 'keyword.operator.range.inclusive.rhai'}, { match: '\\.(?!\\.)|\\?\\.', name: 'keyword.operator.accessor.rhai punctuation.accessor.rhai' }, {match: '=>', name: 'punctuation.separator.switch.case.rhai'}, { match: '(\\(\\*|\\*\\)|\\+\\+|--|\\.\\.\\.+|~|#(?!{)|@|\\?|\\$(?!{)|->|<-|===|!==|\\:=|\\:\\:<)', name: 'invalid.illegal.operator.rhai' } ] }, 'literal-punctuation': { patterns: [ {match: '\\;', name: 'punctuation.terminator.statement.rhai'}, {match: '\\,', name: 'meta.delimiter.comma.rhai'} ] }, 'literal-string': { patterns: [ { match: "('([^'\\\\]|\\\\([tnr'\\\\]|x[[:xdigit:]]{2}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}))')", name: 'string.quoted.single.rhai', patterns: [ { match: "\\\\([tnr'\\\\]|x[[:xdigit:]]{2}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8})", name: 'constant.character.escape.rhai' } ] }, { begin: '(")', beginCaptures: { 1: {name: 'punctuation.definition.string.begin.rhai'} }, end: '(")', endCaptures: {1: {name: 'punctuation.definition.string.end.rhai'}}, name: 'string.quoted.double.rhai', patterns: [ {include: '#string-content'}, {match: '(?