| 1 |
filetype: ATS |
| 2 |
|
| 3 |
detect: |
| 4 |
filename: "\\.(d|h|s)ats$" |
| 5 |
|
| 6 |
rules: |
| 7 |
- default: \b[[:alnum:]]+[^0-9A-Za-z] |
| 8 |
|
| 9 |
# Operators |
| 10 |
- symbol.operator: "[.:;+`|~<>?='\\&]|/|%|-|,|!|\\*|@|\\#" |
| 11 |
- symbol.operator: \^ |
| 12 |
|
| 13 |
# Types, abstract types and some predefined sorts |
| 14 |
- type: \b(addr|age?z|bool|char|cls|schar|uchar|double|ldouble|eff|exn|float|int(ptr)?|lincloptr|uint)\b |
| 15 |
- type: \b(lint|ulint|llint|ullint|nat|ptr|real|ref|size_t|ssize_t|sint|usint|string|tkind|viewt|v?t0p|vt|void)\b |
| 16 |
- type: \b(prop|t[@0]ype|type|viewt[@0]ype|viewtype|vt[@0]ype|vtype|view)\b |
| 17 |
- type: \b(prop[+-]|t[@0]ype[+-]|type[+-]|viewt[@0]ype[+-]|viewtype[+-]|vt[@0]ype[+-]|vtype[+-]|view[+-]) |
| 18 |
|
| 19 |
# Statements |
| 20 |
- statement: \b(abstype|abst|absprop|absviewt|absvt(ype)?|absview|and|andalso|as|(re)?assume|begin|(pr)?case|s?case)\b |
| 21 |
- statement: \b(classdec|dataprop|data(v|view)?type|dataview|datasort|do|dynload|else|end|exception|extype|extva(r|l)|s?if)\b |
| 22 |
- statement: \b(ifcase|import|for|in|infix(l|r)?|let|local|macrodef|macdef|not|of|op|or|orelse|overload|(pre|post|non)fix)\b |
| 23 |
- statement: \b(propdef|rec|sortdef|stacst|stadef|staload|stavar|sta(tic)?|symelim|symintr|tkindef|then|try|viewdef|v?typedef)\b |
| 24 |
- statement: \b(viewtypedef|(pr)?va(l|r)|when|where|while|with|withtype|withprop|withv(iew)?type|withview)\b |
| 25 |
- statement: \b(abst[@0]ype|absviewt[@0]?ype|absvt[@0]ype|abstbox|abstflat|absvtbox|absvtflat|absimpl|absreimpl|abs)\b |
| 26 |
- statement: \b(case[+-]|(pr)?va(l|r)[+-]|for\*|while\*) |
| 27 |
|
| 28 |
# Numbers |
| 29 |
- constant.number: \b[0-9.]+([eE][+-]?[0-9]+)?[fFlL]?\b |
| 30 |
- constant.number: \b0[xX][0-9A-Fa-f]*(\.[0-9A-Fa-f]*)?[pP][+-]?[0-9]+[fFlL]?\b |
| 31 |
- constant.number: \b([0-9]+|0[xX][0-9A-Fa-f]+)[lLuU]*\b |
| 32 |
|
| 33 |
# Function-related keywords, special functions and namespaces. Not really identifiers |
| 34 |
- identifier: \b(fix|(pr)?fu?n|fnx|castfn|praxi|extern|lam|llam|(pr)?implement|(pr)?implmnt)\b |
| 35 |
- identifier: \b(fix@|fold@|free@|lam@|llam@|addr@|view@|ref@|fn\*) |
| 36 |
- identifier: \$\w*\b |
| 37 |
|
| 38 |
# Other keywords, function effects... |
| 39 |
- special: (\$(arrpsz|arrptrsize|break|continue|d2ctype|delay|effmask_(ntm|exn|ref|wrt|all)))\b |
| 40 |
- special: (\$(effmask|extern|extype_struct|extype|extkind|extval|extfcall|extmcall|ldelay|literal))\b |
| 41 |
- special: (\$(li?st_vt|li?st_t|li?st|myfilename|myfunction|mylocation|raise|rec(ord)?_vt))\b |
| 42 |
- special: (\$(rec(ord)?_t|rec(ord)?|showtype|solver_assert|solver_verify|tempenver))\b |
| 43 |
- special: (\$(tup(le)?_vt|tup(le)?_t|tup(le)?|tyrep|vararg|vcopyenv_vt|vcopyenv_v))\b |
| 44 |
- special: \!(wrt|exnref|exnwrt|exn|refwrt|ref|all|ntm|laz)\b |
| 45 |
- special: \b(fun(0|1)|(lin)?cloptr(0|1)?|cloref(0|1)?|clo(0|1)?|lin|prf)\b |
| 46 |
- special: \b(f?print(ln)?!|prerr(ln)?!|tupz!) |
| 47 |
|
| 48 |
# Some C macros and other ATS macros |
| 49 |
- preproc: ^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error|assert)\b |
| 50 |
- preproc: ^[[:space:]]*#[[:space:]]*(codegen2|codegen3|elifdef|elifndef|prerr|print|require|then|staload|dynload)\b |
| 51 |
|
| 52 |
# Boolean values |
| 53 |
- constant.bool: \b(true|false|null)\b |
| 54 |
|
| 55 |
|
| 56 |
# The "%{ ... %}" block inserts foreign code into ATS at compile-time |
| 57 |
# Code inside of it is generally C or JavaScript |
| 58 |
- default: |
| 59 |
start: "%{[#^$]?" |
| 60 |
end: "%}" |
| 61 |
skip: "\\." |
| 62 |
limit-group: symbol.operator |
| 63 |
rules: |
| 64 |
- include: "c" |
| 65 |
- include: "javascript" |
| 66 |
|
| 67 |
|
| 68 |
# Strings and chars |
| 69 |
- constant.string: \"[^"]*\" |
| 70 |
- constant.string: \'[^']*\' |
| 71 |
|
| 72 |
|
| 73 |
# Comments |
| 74 |
# "////" comments everything until it reaches EOF |
| 75 |
- comment.block: |
| 76 |
start: //// |
| 77 |
end: $a |
| 78 |
rules: |
| 79 |
- todo: (TODO|XXX|FIXME) |
| 80 |
|
| 81 |
- comment.line: |
| 82 |
start: // |
| 83 |
end: $ |
| 84 |
rules: |
| 85 |
- todo: (TODO|XXX|FIXME) |
| 86 |
|
| 87 |
# ML-like block comment |
| 88 |
- comment.block: |
| 89 |
start: \(\* |
| 90 |
end: \*\) |
| 91 |
rules: |
| 92 |
- todo: (TODO|XXX|FIXME) |
| 93 |
|
| 94 |
# C-like block comment |
| 95 |
- comment.block: |
| 96 |
start: /\* |
| 97 |
end: \*\/ |
| 98 |
rules: |
| 99 |
- todo: (TODO|XXX|FIXME) |