|
| 1 | +version: v0.6.0 |
| 2 | +scopeName: source.rhai |
| 3 | +uuid: 1e76f176-ee1c-4331-a781-eb21c0da77cf |
| 4 | +information_for_contributors: |
| 5 | + - 'aster: galaster@foxmail.com' |
| 6 | + - 'schungx: schungx@live.com' |
| 7 | +patterns: |
| 8 | + - include: '#comment' |
| 9 | + - include: '#literal' |
| 10 | + - include: '#operator' |
| 11 | +repository: |
| 12 | + comment: |
| 13 | + patterns: |
| 14 | + - name: comment.block.documentation.rhai |
| 15 | + begin: (/\*\*)[^\*] |
| 16 | + beginCaptures: |
| 17 | + '1': {name: punctuation.definition.comment.block.documentation.rhai} |
| 18 | + end: (\*/) |
| 19 | + endCaptures: |
| 20 | + '1': {name: punctuation.definition.comment.block.documentation.rhai} |
| 21 | + patterns: |
| 22 | + - include: '#comment' |
| 23 | + - name: comment.block.rhai |
| 24 | + begin: (/\*) |
| 25 | + beginCaptures: |
| 26 | + '1': {name: punctuation.definition.comment.block.rhai} |
| 27 | + end: (\*/) |
| 28 | + endCaptures: |
| 29 | + '1': {name: punctuation.definition.comment.block.rhai} |
| 30 | + patterns: |
| 31 | + - include: '#comment' |
| 32 | + - name: comment.line.documentation.rhai |
| 33 | + match: (///)[^/].*$\n? |
| 34 | + captures: |
| 35 | + '1': {name: punctuation.definition.comment.line.rhai} |
| 36 | + - name: comment.line.rhai |
| 37 | + match: (//).*$\n? |
| 38 | + captures: |
| 39 | + '1': {name: punctuation.definition.comment.line.rhai} |
| 40 | + |
| 41 | + literal: |
| 42 | + patterns: |
| 43 | + - include: '#keyword' |
| 44 | + - include: '#string' |
| 45 | + - include: '#number' |
| 46 | + - include: '#symbol' |
| 47 | + - include: '#variable' |
| 48 | + |
| 49 | + keyword: |
| 50 | + patterns: |
| 51 | + - match: \b(let|const)\b |
| 52 | + name: keyword.control.definition.rhai |
| 53 | + - match: \b(fn|Fn)\b |
| 54 | + name: keyword.control.definition.function.rhai storage.type.function.rhai keyword.declaration.function.rhai |
| 55 | + - match: \b(import|export|as|private)\b |
| 56 | + name: keyword.control.import.rhai keyword.control.export.rhai |
| 57 | + - match: \b(if|else)\b |
| 58 | + name: keyword.control.conditional.rhai |
| 59 | + - match: \b(switch|return|throw|try|catch)\b |
| 60 | + name: keyword.control.flow.rhai |
| 61 | + - match: \b(do|while|loop|until|for|in|break|continue)\b |
| 62 | + name: keyword.control.loop.rhai |
| 63 | + - match: \b(this)\b |
| 64 | + name: variable.language.rhai |
| 65 | + - match: \b(true|false)\b |
| 66 | + name: constant.language.rhai |
| 67 | + - match: \b(print|debug|call|curry|eval|type_of|is_def_var|is_def_fn|is_shared)\b |
| 68 | + name: keyword.other.rhai support.function.rhai |
| 69 | + - match: \b(var|static|begin|end|shared|each|then|goto|exit|unless|match|case|public|protected|new|use|with|module|package|super|thread|spawn|go|await|async|sync|yield|default|void|null|nil)\b |
| 70 | + name: invalid.illegal.rhai |
| 71 | + |
| 72 | + operator: |
| 73 | + patterns: |
| 74 | + - match: (==|!=|<=|>=|<|>) |
| 75 | + name: keyword.operator.comparison.rhai |
| 76 | + - match: (\+|-|\*|/|\*\*|%) |
| 77 | + name: keyword.operator.arithmetic.rhai |
| 78 | + - match: (\||&|>>|<<|\^) |
| 79 | + name: keyword.operator.bitwise.rhai |
| 80 | + - match: (=|\+=|-=|\*=|/=|\*\*=|%=|\|=|&=|\^=|>>=|<<=) |
| 81 | + name: keyword.operator.assignment.rhai |
| 82 | + - match: (!) |
| 83 | + name: keyword.operator.infix.rhai |
| 84 | + - match: (\|\||&&) |
| 85 | + name: keyword.operator.logical.rhai |
| 86 | + |
| 87 | + number: |
| 88 | + patterns: |
| 89 | + - match: (?<!\w)(0x\h[_0-9a-fA-F]*)(?!\w) |
| 90 | + name: constant.numeric.hex.rhai |
| 91 | + - match: (?<!\w)(0o[0-7][_0-7]*)(?!\w) |
| 92 | + name: constant.numeric.oct.rhai} |
| 93 | + - match: (?<!\w)(0b[01][_01]*)(?!\w) |
| 94 | + name: constant.numeric.bin.rhai |
| 95 | + - match: ([\+-]?[0-9][_0-9]*(\.[0-9][_0-9]*)?e[\+-]?[0-9][_0-9]*) |
| 96 | + name: constant.numeric.decimal.rhai |
| 97 | + - match: ([\+-]?[0-9][_0-9]*(\.([0-9][_0-9]*)?)) |
| 98 | + name: constant.numeric.decimal.rhai |
| 99 | + - match: ([\+-]?[0-9][_0-9]*) |
| 100 | + name: constant.numeric.integer.rhai |
| 101 | + |
| 102 | + literal-string: |
| 103 | + - match: '`' |
| 104 | + scope: punctuation.definition.string.begin.rhai |
| 105 | + set: |
| 106 | + - meta_include_prototype: false |
| 107 | + - meta_scope: meta.string.rhai string.quoted.other.rhai |
| 108 | + - match: "`" |
| 109 | + scope: punctuation.definition.string.end.rhai |
| 110 | + pop: true |
| 111 | + - match: '\$\{' |
| 112 | + scope: punctuation.section.interpolation.begin.rhai |
| 113 | + push: |
| 114 | + - clear_scopes: 1 |
| 115 | + - meta_scope: meta.interpolation.rhai |
| 116 | + - meta_content_scope: source.rhai.embedded |
| 117 | + - match: '\}' |
| 118 | + scope: punctuation.section.interpolation.end.rhai |
| 119 | + pop: true |
| 120 | + - match: (?=\S) |
| 121 | + push: expression |
| 122 | + - include: string-content |
| 123 | + |
| 124 | + string: |
| 125 | + patterns: |
| 126 | + - name: string.quoted.block.rhai meta.string.rhai |
| 127 | + begin: (`) |
| 128 | + beginCaptures: |
| 129 | + '1': {name: punctuation.definition.string.begin.rhai} |
| 130 | + end: (`) |
| 131 | + endCaptures: |
| 132 | + '1': {name: punctuation.definition.string.end.rhai} |
| 133 | + - match: ('([^'\\]|\\([tnr'\\]|x\h{2}|u\h{4}|U\h{8}))') |
| 134 | + name: string.quoted.single.rhai meta.string.rhai |
| 135 | + patterns: |
| 136 | + - match: \\([tnr'\\]|x\h{2}|u\h{4}|U\h{8}) |
| 137 | + name: constant.character.escape.rhai |
| 138 | + - match: ("[^"\\]*(?:\\.[^"\\]*)*") |
| 139 | + name: string.quoted.single.rhai meta.string.rhai |
| 140 | + patterns: |
| 141 | + - match: \\([tnr"\\\n]|x\h{2}|u\h{4}|U\h{8}) |
| 142 | + name: constant.character.escape.rhai |
| 143 | + |
| 144 | + symbol: |
| 145 | + patterns: |
| 146 | + - match: (\:\:) |
| 147 | + name: punctuation.accessor.rhai |
| 148 | + - match: (\:|=>|,) |
| 149 | + name: punctuation.separator.rhai |
| 150 | + - match: (;) |
| 151 | + name: punctuation.terminator.rhai |
| 152 | + - match: (\.) |
| 153 | + name: punctuation.accessor.rhai |
| 154 | + - match: (\{) |
| 155 | + name: punctuation.section.block.begin.rhai |
| 156 | + - match: (\}) |
| 157 | + name: punctuation.section.block.end.rhai |
| 158 | + - match: (\() |
| 159 | + name: punctuation.section.group.begin.rhai |
| 160 | + - match: (\)) |
| 161 | + name: punctuation.section.group.end.rhai |
| 162 | + - match: (\[) |
| 163 | + name: punctuation.section.brackets.begin.rhai |
| 164 | + - match: (\]) |
| 165 | + name: punctuation.section.brackets.end.rhai |
| 166 | + - match: (\(\*|\*\)|#!|\+\+|--|\.\.|\.\.\.|~|#|@|\$|->|<-|===|!==|\:=|\:\:<) |
| 167 | + name: invalid.illegal.rhai |
| 168 | + |
| 169 | + variable: |
| 170 | + patterns: |
| 171 | + - match: (?<!\w)([A-Z][_0-9A-Z]*)(?!\w) |
| 172 | + name: entity.name.constant.rhai variable.other.constant.rhai |
| 173 | + - match: (?<!\w)([_a-zA-Z][_0-9a-zA-Z]*)(?=\(|\!\() |
| 174 | + name: variable.function |
| 175 | + - match: (?<!\w)([_a-zA-Z][_0-9a-zA-Z]*)(?!\w) |
| 176 | + name: variable.other.readwrite.rhai |
| 177 | + - match: (?<!\w)([_a-zA-Z][_0-9a-zA-Z]*\s*\:\:)+\s*(?=\w) |
| 178 | + name: entity.name.namespace.rhai meta.path.rhai |
0 commit comments