%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: Rhai file_extensions: - rhai scope: source.rhai contexts: main: - include: core brackets: - include: round-brackets - include: square-brackets - include: curly-brackets comments: - match: '/\*\*(?![/|\*])' captures: 0: punctuation.definition.comment.block.documentation.rhai push: - meta_scope: comment.block.documentation.rhai - match: \*/ captures: 0: punctuation.definition.comment.block.documentation.rhai pop: true - include: comments - match: /\* captures: 0: punctuation.definition.comment.block.rhai push: - meta_scope: comment.block.rhai - match: \*/ captures: 0: punctuation.definition.comment.block.rhai pop: true - include: comments - match: '(///)[^/].*$\n?' scope: comment.line.documentation.rhai captures: 1: punctuation.definition.comment.documentation.rhai - match: (//).*$\n? scope: comment.line.double-slash.rhai captures: 1: punctuation.definition.comment.double-slash.rhai - match: ^(#!).*$\n? scope: comment.line.shebang.rhai captures: 1: punctuation.definition.comment.rhai core: - include: expression curly-brackets: - match: '\{' captures: 0: meta.brace.curly.rhai push: - meta_scope: meta.group.braces.curly - match: '\}' captures: 0: meta.brace.curly.rhai pop: true - include: main expression: - 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: - match: \( captures: 0: punctuation.definition.parameters.begin.rhai push: - match: \) captures: 0: punctuation.definition.parameters.end.rhai pop: true - match: '[_a-zA-Z]\w*' scope: variable.parameter.function.rhai - match: \, scope: punctuation.separator.parameter.function.rhai - include: parameters-list literal-closure: - match: (\|) captures: 1: punctuation.definition.parameters.closure.begin.rhai push: - meta_scope: meta.function.closure.rhai - match: (\|) captures: 1: punctuation.definition.parameters.closure.end.rhai pop: true - include: parameters-list - match: '(\b[_a-zA-Z]\w*)\s*(=)\s*(\|)' captures: 1: entity.name.function.closure.rhai 2: keyword.operator.assignment.rhai 3: punctuation.definition.parameters.closure.begin.rhai push: - meta_scope: meta.function.closure.rhai - match: (\|) captures: 1: punctuation.definition.parameters.closure.end.rhai pop: true - include: parameters-list literal-closure-labels: - match: '(\b[_a-zA-Z]\w*)\s*(\:)\s*(\|)' captures: 1: string.unquoted.label.rhai entity.name.function.method.rhai 2: punctuation.separator.key-value.rhai 3: punctuation.definition.parameters.closure.begin.rhai push: - meta_scope: meta.function.closure.rhai - match: (\|) captures: 1: punctuation.definition.parameters.closure.end.rhai pop: true - include: parameters-list - match: '((\")((?:[^"]|\\")*)(\"))\s*(:)\s*(\|)' captures: 1: string.quoted.double.rhai 2: punctuation.definition.string.begin.rhai 3: entity.name.function.method.rhai 4: punctuation.definition.string.end.rhai 5: punctuation.separator.key-value.rhai 6: punctuation.definition.parameters.closure.begin.rhai push: - meta_scope: meta.function.closure.rhai - match: (\|) captures: 1: punctuation.definition.parameters.closure.end.rhai pop: true - include: parameters-list literal-constant: - include: literal-number - include: literal-string - include: literal-language-constant literal-function: - match: |- (?x) (?:\b(private)\s+)? \s*(fn) \s*([_a-zA-Z]\w*)\s* captures: 1: storage.modifier.rhai 2: storage.type.function.rhai 3: entity.name.function.rhai push: - meta_scope: meta.function.rhai - match: (?<=\)) pop: true - include: parameters-list literal-function-call: - match: |- (?x) ([_a-zA-Z]\w*)(!)?\s* (\(\s*\)) scope: meta.function-call.without-arguments.rhai captures: 1: entity.name.function.rhai 2: punctuation.function-call.capture.rhai 3: meta.group.braces.round.function.arguments.rhai - match: |- (?x) ([_a-zA-Z]\w*)(!)?\s* (?=\() scope: meta.function-call.with-arguments.rhai captures: 1: entity.name.function.rhai 2: punctuation.function-call.capture.rhai literal-keyword-storage: - match: \b(const|let)\b scope: storage.type.rhai literal-keywords: - include: literal-keyword-storage - match: \b(return)\b scope: keyword.control.flow.rhai - match: \b(if|else|switch)\b scope: keyword.control.conditional.rhai - match: \b(throw|try|catch)\b scope: keyword.control.trycatch.rhai - match: \b(for|in|loop|do|while|until|break|continue)\b scope: keyword.control.loop.rhai literal-labels: - match: |- (?x) (?]) # assignment right-to-left both" scope: keyword.operator.assignment.rhai - match: |- (?x) %= | # assignment right-to-left both &= | # assignment right-to-left both \*\*=| # assignment right-to-left both (?>= # assignment right-to-left both scope: keyword.operator.assignment.augmented.rhai - match: |- (?x) << | # bitwise-shift left-to-right both >> | # bitwise-shift left-to-right both & | # bitwise-and left-to-right both \^ | # bitwise-xor left-to-right both \| # bitwise-or left-to-right both scope: keyword.operator.bitwise.rhai - match: |- (?x) <= | # relational left-to-right both >= | # relational left-to-right both <(?!-) | # relational left-to-right both (? # relational left-to-right both scope: keyword.operator.relational.rhai - match: |- (?x) ==(?!=) | # equality left-to-right both !=(?!=) # equality left-to-right both scope: keyword.operator.comparison.rhai - match: |- (?x) / | # division left-to-right both % | # modulus left-to-right both \*\* | # power left-to-right both \*(?!\)) | # multiplication left-to-right both \+(?!\+) | # addition left-to-right both -(?![>-]) # subtraction left-to-right both scope: keyword.operator.arithmetic.rhai - match: \.(?!\.) scope: keyword.operator.accessor.rhai punctuation.accessor.rhai - match: "=>" scope: punctuation.separator.switch.case.rhai - match: '(\(\*|\*\)|\+\+|--|\.\.+|~|#(?!{)|@|\$(?!{)|->|<-|===|!==|\:=|\:\:<)' scope: invalid.illegal.operator.rhai literal-punctuation: - match: \; scope: punctuation.terminator.statement.rhai - match: \, scope: meta.delimiter.comma.rhai literal-string: - match: '(''([^''\\]|\\([tnr''\\]|x\h{2}|u\h{4}|U\h{8}))'')' scope: string.quoted.single.rhai - match: (") captures: 1: punctuation.definition.string.begin.rhai push: - meta_scope: string.quoted.double.rhai - match: (") captures: 1: punctuation.definition.string.end.rhai pop: true - include: string-content - match: (?