|
| 1 | +{ |
| 2 | + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", |
| 3 | + "name": "Redcode", |
| 4 | + "scopeName": "source.redcode", |
| 5 | + "patterns": [ |
| 6 | + { |
| 7 | + "include": "#directive" |
| 8 | + }, |
| 9 | + { |
| 10 | + "include": "#opcode" |
| 11 | + }, |
| 12 | + { |
| 13 | + "include": "#field" |
| 14 | + }, |
| 15 | + { |
| 16 | + "include": "#label" |
| 17 | + } |
| 18 | + ], |
| 19 | + "repository": { |
| 20 | + "opcode": { |
| 21 | + "patterns": [ |
| 22 | + { |
| 23 | + "name": "keyword.operator.control.opcode.88.redcode", |
| 24 | + "match": "(?i)\\b(DAT|MOV|ADD|SUB|JMP|JMZ|JMN|DJN|SLT|CMP|SPL)\\b" |
| 25 | + }, |
| 26 | + { |
| 27 | + "name": "keyword.operator.control.opcode.94.redcode", |
| 28 | + "match": "(?i)\\b(MUL|DIV|MOD|SEQ|SNE|NOP)\\b" |
| 29 | + }, |
| 30 | + { |
| 31 | + "name": "keyword.operator.control.opcode.p-space.redcode", |
| 32 | + "match": "(?i)\\b(LDP|STP)\\b" |
| 33 | + }, |
| 34 | + { |
| 35 | + "name": "keyword.operator.control.psuedo-opcode.88.redcode", |
| 36 | + "match": "(?i)\\b(EQU|END|FOR|ROF)\\b" |
| 37 | + }, |
| 38 | + { |
| 39 | + "name": "keyword.operator.control.psuedo-opcode.94.redcode", |
| 40 | + "match": "(?i)\\b(ORG)\\b" |
| 41 | + }, |
| 42 | + { |
| 43 | + "name": "keyword.operator.control.psuedo-opcode.p-space.redcode", |
| 44 | + "match": "(?i)\\b(PIN)\\b" |
| 45 | + } |
| 46 | + ] |
| 47 | + }, |
| 48 | + "builtin": { |
| 49 | + "patterns": [ |
| 50 | + { |
| 51 | + "name": "constant.language.88.redcode", |
| 52 | + "match": "\\b(CORESIZE|MAXPROCESSES|MAXCYCLES|MAXLENGTH)\\b" |
| 53 | + }, |
| 54 | + { |
| 55 | + "name": "constant.language.94.redcode", |
| 56 | + "match": "\\b(MINDISTANCE|ROUNDS|CURLINE|VERSION|WARRIORS)\\b" |
| 57 | + }, |
| 58 | + { |
| 59 | + "name": "constant.language.p-space.redcode", |
| 60 | + "match": "\\b(PSPACESIZE)\\b" |
| 61 | + } |
| 62 | + ] |
| 63 | + }, |
| 64 | + "directive": { |
| 65 | + "begin": "(;)", |
| 66 | + "beginCaptures": { |
| 67 | + "1": { |
| 68 | + "name": "comment.line.semicolon.redcode" |
| 69 | + } |
| 70 | + }, |
| 71 | + "end": "$", |
| 72 | + "patterns": [ |
| 73 | + { |
| 74 | + "include": "#directive_with_argument" |
| 75 | + }, |
| 76 | + { |
| 77 | + "name": "keyword.operator.directive.main.redcode", |
| 78 | + "match": "(?i)(redcode)(?!-)" |
| 79 | + }, |
| 80 | + { |
| 81 | + "name": "keyword.operator.directive.koth.main.redcode", |
| 82 | + "match": "(?i)(redcode-[a-zA-Z0-9]+)" |
| 83 | + }, |
| 84 | + { |
| 85 | + "name": "keyword.operator.directive.debug.redcode", |
| 86 | + "match": "(?i)(debug)[[:blank:]]+(off|static)" |
| 87 | + }, |
| 88 | + { |
| 89 | + "name": "keyword.operator.directive.trace.redcode", |
| 90 | + "match": "(?i)(trace)[[:blank:]]+(off)" |
| 91 | + }, |
| 92 | + { |
| 93 | + "name": "comment.line.semicolon.redcode", |
| 94 | + "match": ".*" |
| 95 | + } |
| 96 | + ] |
| 97 | + }, |
| 98 | + "directive_with_argument": { |
| 99 | + "patterns": [ |
| 100 | + { |
| 101 | + "match": "(?i)(assert)\\b(.*)", |
| 102 | + "captures": { |
| 103 | + "1": { |
| 104 | + "name": "keyword.operator.directive.redcode" |
| 105 | + }, |
| 106 | + "2": { |
| 107 | + "patterns": [ |
| 108 | + { |
| 109 | + "include": "#expression" |
| 110 | + } |
| 111 | + ] |
| 112 | + } |
| 113 | + } |
| 114 | + }, |
| 115 | + { |
| 116 | + "match": "(?i)(author|break|name)\\b(.*)", |
| 117 | + "captures": { |
| 118 | + "1": { |
| 119 | + "name": "keyword.operator.directive.redcode" |
| 120 | + }, |
| 121 | + "2": { |
| 122 | + "name": "string.unquoted.directive.argument.redcode" |
| 123 | + } |
| 124 | + } |
| 125 | + }, |
| 126 | + { |
| 127 | + "match": "(?i)(help|kill|status|strategy|test|password|newpasswd|newredcode|url|version|date)\\b(.*)", |
| 128 | + "name": "keyword.operator.directive.koth.redcode", |
| 129 | + "captures": { |
| 130 | + "2": { |
| 131 | + "name": "string.unquoted.directive.koth.argument.redcode" |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + ] |
| 136 | + }, |
| 137 | + "label": { |
| 138 | + "patterns": [ |
| 139 | + { |
| 140 | + "name": "variable.redcode", |
| 141 | + "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*[:]?)\\b" |
| 142 | + } |
| 143 | + ] |
| 144 | + }, |
| 145 | + "field": { |
| 146 | + "patterns": [ |
| 147 | + { |
| 148 | + "name": "keyword.operator.address-mode.88.redcode", |
| 149 | + "match": "[#$@<]" |
| 150 | + }, |
| 151 | + { |
| 152 | + "name": "keyword.operator.address-mode.94.redcode", |
| 153 | + "match": "[>*{}]" |
| 154 | + }, |
| 155 | + { |
| 156 | + "name": "keyword.operator.modifier.redcode", |
| 157 | + "match": "(?i)\\b(\\.([ABFXI]|AB|BA))\\b" |
| 158 | + }, |
| 159 | + { |
| 160 | + "include": "#expression" |
| 161 | + } |
| 162 | + ] |
| 163 | + }, |
| 164 | + "expression": { |
| 165 | + "name": "expression", |
| 166 | + "patterns": [ |
| 167 | + { |
| 168 | + "name": "keyword.operator.math.redcode", |
| 169 | + "match": "[+\\-*/%]" |
| 170 | + }, |
| 171 | + { |
| 172 | + "name": "keyword.operator.logical.redcode", |
| 173 | + "match": "[=<>&|!]" |
| 174 | + }, |
| 175 | + { |
| 176 | + "name": "constant.numeric.redcode", |
| 177 | + "match": "\\b\\d+\\b" |
| 178 | + }, |
| 179 | + { |
| 180 | + "include": "#builtin" |
| 181 | + }, |
| 182 | + { |
| 183 | + "include": "#label" |
| 184 | + }, |
| 185 | + { |
| 186 | + "include": "#paren_expression" |
| 187 | + } |
| 188 | + ] |
| 189 | + }, |
| 190 | + "paren_expression": { |
| 191 | + "begin": "\\(", |
| 192 | + "beginCaptures": { |
| 193 | + "0": { |
| 194 | + "name": "punctuation.paren.open.redcode" |
| 195 | + } |
| 196 | + }, |
| 197 | + "end": "\\)", |
| 198 | + "endCaptures": { |
| 199 | + "0": { |
| 200 | + "name": "punctuation.paren.open.redcode" |
| 201 | + } |
| 202 | + }, |
| 203 | + "name": "expression.group", |
| 204 | + "patterns": [ |
| 205 | + { |
| 206 | + "include": "#expression" |
| 207 | + } |
| 208 | + ] |
| 209 | + } |
| 210 | + } |
| 211 | +} |
0 commit comments