|
| 1 | +{ |
| 2 | + "name": "AWK", |
| 3 | + "scope": "source.awk", |
| 4 | + "file_extensions": ["awk"], |
| 5 | + "variables": { |
| 6 | + "NAME": "[A-Za-z_][A-Za-z_0-9]*" |
| 7 | + }, |
| 8 | + "contexts": { |
| 9 | + "main": [ |
| 10 | + { |
| 11 | + "include": "comment" |
| 12 | + }, |
| 13 | + { |
| 14 | + "include": "procedure" |
| 15 | + }, |
| 16 | + { |
| 17 | + "include": "pattern" |
| 18 | + } |
| 19 | + ], |
| 20 | + "comment": [ |
| 21 | + { |
| 22 | + "match": "(?<!\\S)(#)(?!\\{).*$\\n?", |
| 23 | + "scope": "comment.line.number-sign.awk", |
| 24 | + "captures": { |
| 25 | + "1": "punctuation.definition.comment.awk" |
| 26 | + } |
| 27 | + } |
| 28 | + ], |
| 29 | + "procedure": [ |
| 30 | + { |
| 31 | + "match": "{", |
| 32 | + "scope": "meta.brace.curly.awk", |
| 33 | + "push": [ |
| 34 | + { |
| 35 | + "match": "}", |
| 36 | + "scope": "meta.brace.curly.awk", |
| 37 | + "pop": true |
| 38 | + }, |
| 39 | + { |
| 40 | + "include": "comment" |
| 41 | + }, |
| 42 | + { |
| 43 | + "include": "procedure" |
| 44 | + }, |
| 45 | + { |
| 46 | + "include": "keyword" |
| 47 | + }, |
| 48 | + { |
| 49 | + "include": "expression" |
| 50 | + } |
| 51 | + ] |
| 52 | + } |
| 53 | + ], |
| 54 | + "pattern": [ |
| 55 | + { |
| 56 | + "include": "function-definition" |
| 57 | + }, |
| 58 | + { |
| 59 | + "include": "builtin-pattern" |
| 60 | + }, |
| 61 | + { |
| 62 | + "include": "expression" |
| 63 | + } |
| 64 | + ], |
| 65 | + "expression": [ |
| 66 | + { |
| 67 | + "include": "comment" |
| 68 | + }, |
| 69 | + { |
| 70 | + "include": "command" |
| 71 | + }, |
| 72 | + { |
| 73 | + "include": "function" |
| 74 | + }, |
| 75 | + { |
| 76 | + "include": "constant" |
| 77 | + }, |
| 78 | + { |
| 79 | + "include": "variable" |
| 80 | + }, |
| 81 | + { |
| 82 | + "include": "groupings" |
| 83 | + }, |
| 84 | + { |
| 85 | + "include": "prefix-operator" |
| 86 | + }, |
| 87 | + { |
| 88 | + "include": "regexp" |
| 89 | + }, |
| 90 | + { |
| 91 | + "match": "(?=[\\S])", |
| 92 | + "pop": true |
| 93 | + } |
| 94 | + ], |
| 95 | + "groupings": [ |
| 96 | + { |
| 97 | + "match": "\\(", |
| 98 | + "scope": "meta.brace.round.awk" |
| 99 | + }, |
| 100 | + { |
| 101 | + "match": "\\)(?=\\s*{)", |
| 102 | + "scope": "meta.brace.round.awk" |
| 103 | + }, |
| 104 | + { |
| 105 | + "match": "\\)", |
| 106 | + "scope": "meta.brace.round.awk", |
| 107 | + "push": "infix-operator" |
| 108 | + }, |
| 109 | + { |
| 110 | + "match": "\\,", |
| 111 | + "scope": "punctuation.separator.parameters.awk" |
| 112 | + } |
| 113 | + ], |
| 114 | + "builtin-pattern": [ |
| 115 | + { |
| 116 | + "match": "\\b(BEGINFILE|BEGIN|ENDFILE|END)\\b", |
| 117 | + "scope": "constant.language.awk" |
| 118 | + } |
| 119 | + ], |
| 120 | + "function-definition": [ |
| 121 | + { |
| 122 | + "match": "\\b(function)\\s+({{NAME}})(\\()", |
| 123 | + "captures": { |
| 124 | + "1": "storage.type.function.awk", |
| 125 | + "2": "entity.name.function.awk", |
| 126 | + "3": "punctuation.definition.parameters.begin.awk" |
| 127 | + }, |
| 128 | + "push": [ |
| 129 | + { |
| 130 | + "match": "\\)", |
| 131 | + "captures": { |
| 132 | + "0": "punctuation.definition.parameters.end.awk" |
| 133 | + }, |
| 134 | + "pop": true |
| 135 | + }, |
| 136 | + { |
| 137 | + "match": "\\b(\\w+)\\b", |
| 138 | + "scope": "variable.parameter.function.awk" |
| 139 | + }, |
| 140 | + { |
| 141 | + "match": "\\b(,)\\b", |
| 142 | + "scope": "punctuation.separator.parameters.awk" |
| 143 | + } |
| 144 | + ] |
| 145 | + } |
| 146 | + ], |
| 147 | + "constant": [ |
| 148 | + { |
| 149 | + "include": "numeric-constant" |
| 150 | + }, |
| 151 | + { |
| 152 | + "include": "string-constant" |
| 153 | + } |
| 154 | + ], |
| 155 | + "numeric-constant": [ |
| 156 | + { |
| 157 | + "match": "\\b[0-9]+(?:\\.[0-9]+)?(?:e[+-][0-9]+)?\\b", |
| 158 | + "scope": "constant.numeric.awk", |
| 159 | + "push": "infix-operator" |
| 160 | + } |
| 161 | + ], |
| 162 | + "string-constant": [ |
| 163 | + { |
| 164 | + "match": "\"", |
| 165 | + "scope": "punctuation.definition.string.begin.awk", |
| 166 | + "push": [ |
| 167 | + { |
| 168 | + "meta_scope": "string.quoted.double.awk" |
| 169 | + }, |
| 170 | + { |
| 171 | + "match": "\"", |
| 172 | + "scope": "punctuation.definition.string.end.awk", |
| 173 | + "pop": true |
| 174 | + }, |
| 175 | + { |
| 176 | + "include": "escaped-char" |
| 177 | + } |
| 178 | + ] |
| 179 | + } |
| 180 | + ], |
| 181 | + "escaped-char": [ |
| 182 | + { |
| 183 | + "match": "\\\\(?:[\\\\abfnrtv/\"]|x[0-9A-Fa-f]{2}|[0-7]{3})", |
| 184 | + "scope": "constant.character.escape.awk" |
| 185 | + } |
| 186 | + ], |
| 187 | + "regexp": [ |
| 188 | + { |
| 189 | + "match": "/", |
| 190 | + "scope": "punctuation.definition.regex.begin.awk", |
| 191 | + "push": [ |
| 192 | + { |
| 193 | + "meta_scope": "string.regexp" |
| 194 | + }, |
| 195 | + { |
| 196 | + "match": "(/)([gimy]*)", |
| 197 | + "captures": { |
| 198 | + "1": "punctuation.definition.regex.end.awk", |
| 199 | + "2": "keyword.other.awk" |
| 200 | + }, |
| 201 | + "set": "infix-operator" |
| 202 | + }, |
| 203 | + { |
| 204 | + "match": "(?=.|\\n)", |
| 205 | + "with_prototype": [ |
| 206 | + { |
| 207 | + "match": "(?=/)", |
| 208 | + "pop": true |
| 209 | + } |
| 210 | + ], |
| 211 | + "push": [ |
| 212 | + { |
| 213 | + "include": "scope:source.regexp" |
| 214 | + } |
| 215 | + ] |
| 216 | + } |
| 217 | + ] |
| 218 | + } |
| 219 | + ], |
| 220 | + "variable": [ |
| 221 | + { |
| 222 | + "match": "\\$[0-9]+", |
| 223 | + "scope": "variable.language.awk", |
| 224 | + "push": "infix-operator" |
| 225 | + }, |
| 226 | + { |
| 227 | + "match": "\\b(?:FILENAME|FS|NF|NR|OFMT|OFS|ORS|RS)\\b", |
| 228 | + "scope": "variable.language.awk", |
| 229 | + "push": "infix-operator" |
| 230 | + }, |
| 231 | + { |
| 232 | + "match": "\\b(?:ARGC|ARGV|CONVFMT|ENVIRON|FNR|RLENGTH|RSTART|SUBSEP)\\b", |
| 233 | + "scope": "variable.language.nawk", |
| 234 | + "push": "infix-operator" |
| 235 | + }, |
| 236 | + { |
| 237 | + "match": "\\b(?:ARGIND|ERRNO|FIELDWIDTHS|IGNORECASE|RT)\\b", |
| 238 | + "scope": "variable.language.gawk", |
| 239 | + "push": "infix-operator" |
| 240 | + }, |
| 241 | + { |
| 242 | + "match": "\\b{{NAME}}\\b", |
| 243 | + "scope": "variable.other.readwrite.awk", |
| 244 | + "push": "infix-operator" |
| 245 | + } |
| 246 | + ], |
| 247 | + "keyword": [ |
| 248 | + { |
| 249 | + "match": "\\b(?:break|continue|do|while|exit|for|if|else|return)\\b", |
| 250 | + "scope": "keyword.control.awk" |
| 251 | + } |
| 252 | + ], |
| 253 | + "command": [ |
| 254 | + { |
| 255 | + "match": "\\b(?:next|print|printf)\\b", |
| 256 | + "scope": "keyword.other.command.awk" |
| 257 | + }, |
| 258 | + { |
| 259 | + "match": "\\b(?:close|getline|delete|system)\\b", |
| 260 | + "scope": "keyword.other.command.nawk" |
| 261 | + }, |
| 262 | + { |
| 263 | + "match": "\\b(?:fflush|nextfile)\\b", |
| 264 | + "scope": "keyword.other.command.bell-awk" |
| 265 | + } |
| 266 | + ], |
| 267 | + "function": [ |
| 268 | + { |
| 269 | + "match": "\\b(?:exp|int|log|sqrt|index|length|split|sprintf|substr)\\b", |
| 270 | + "scope": "support.function.awk" |
| 271 | + }, |
| 272 | + { |
| 273 | + "match": "\\b(?:atan2|cos|rand|sin|srand|gsub|match|sub|tolower|toupper)\\b", |
| 274 | + "scope": "support.function.nawk" |
| 275 | + }, |
| 276 | + { |
| 277 | + "match": "\\b(?:gensub|strftime|systime)\\b", |
| 278 | + "scope": "support.function.gawk" |
| 279 | + }, |
| 280 | + { |
| 281 | + "match": "\\b{{NAME}}(?=\\s*\\()", |
| 282 | + "scope": "entity.name.function.awk" |
| 283 | + } |
| 284 | + ], |
| 285 | + "prefix-operator": [ |
| 286 | + { |
| 287 | + "match": "[+-]", |
| 288 | + "scope": "keyword.operator.arithmetic.awk", |
| 289 | + "set": "expression" |
| 290 | + } |
| 291 | + ], |
| 292 | + "infix-operator": [ |
| 293 | + { |
| 294 | + "match": "!?~|[=<>!]=|[<>]", |
| 295 | + "scope": "keyword.operator.comparison.awk", |
| 296 | + "set": "expression" |
| 297 | + }, |
| 298 | + { |
| 299 | + "match": "\\b(in)\\b", |
| 300 | + "scope": "keyword.operator.comparison.awk", |
| 301 | + "set": "expression" |
| 302 | + }, |
| 303 | + { |
| 304 | + "match": "[+\\-*/%^]=|\\+\\+|--|>>|=", |
| 305 | + "scope": "keyword.operator.assignment.awk", |
| 306 | + "set": "expression" |
| 307 | + }, |
| 308 | + { |
| 309 | + "match": "\\|\\||&&|!", |
| 310 | + "scope": "keyword.operator.boolean.awk", |
| 311 | + "set": "expression" |
| 312 | + }, |
| 313 | + { |
| 314 | + "match": "[+\\-*/%^]", |
| 315 | + "scope": "keyword.operator.arithmetic.awk", |
| 316 | + "set": "expression" |
| 317 | + }, |
| 318 | + { |
| 319 | + "match": "[?:]", |
| 320 | + "scope": "keyword.operator.trinary.awk", |
| 321 | + "set": "expression" |
| 322 | + }, |
| 323 | + { |
| 324 | + "match": "\\[", |
| 325 | + "scope": "keyword.operator.index.awk", |
| 326 | + "push": [ |
| 327 | + { |
| 328 | + "match": "\\]", |
| 329 | + "scope": "keyword.operator.index.awk", |
| 330 | + "pop": true |
| 331 | + }, |
| 332 | + { |
| 333 | + "match": ",", |
| 334 | + "scope": "punctuation.separator.index.awk" |
| 335 | + }, |
| 336 | + { |
| 337 | + "include": "expression" |
| 338 | + } |
| 339 | + ] |
| 340 | + }, |
| 341 | + { |
| 342 | + "match": "(?=[\\S])", |
| 343 | + "pop": true |
| 344 | + } |
| 345 | + ] |
| 346 | + } |
| 347 | +} |
0 commit comments