mclangc/editor/vscode/syntaxes/mclang.tmLanguage.json

147 lines
5.0 KiB
JSON
Raw Normal View History

2023-04-13 10:43:53 +00:00
{
"name": "MCLang",
"fileTypes": [
"mcl"
],
"scopeName": "source.mcl",
"patterns": [
{
"include": "#errors"
},
{
"include": "#keywords"
},
{
"include": "#definitions"
},
{
"include": "#placeholders"
},
{
"include": "#strings"
},
{
"include": "#comments"
},
{
"include": "#intrinsics"
},
{
"include": "#constants-and-special-vars"
}
],
"repository": {
"errors": {
"patterns": [
{
"name": "invalid.illegal",
"match": "(?<=^|\\s)(?:const|memory)\\s+(end)(?:$|\\s)"
},
{
"name": "invalid.illegal",
"match": "(?<=^|\\s)(?:fn)\\s+(done)(?:$|\\s)"
},
{
"name": "invalid.illegal",
"match": "(?<=^|\\s)(memory|const)\\s+\\S*(\\s+|$)end(?:\n|\\s)"
},
{
"name": "invalid.illegal",
"match": "(?<=^|\\s)(inline)\\s+(?!fn(\\s|$))"
}
]
},
"keywords": {
"patterns": [
{
"name": "keyword.declaration.mclang",
"match": "(?<=\\s|^)(macro|memory|fn|const|in|inline|include|assert|offset|addr-of|call-like|reset|let|peek|with|returns)(?:\\s|$)"
},
{
"name": "keyword.control.mclang",
"match": "(?<=\\s|^)(if|else|elif|end|done|then|while|do|if\\*)(?:\\s|$)"
}
]
},
"definitions": {
"patterns": [
{
"name": "support.class.mclang",
"match": "(?<=(macro|memory|fn|const)\\s+)(\\S*)"
},
{
"name": "support.class.mclang",
"match": "(?<=(let|peek)\\s+)\\S+.*(?=\\s+(in))"
}
]
},
"placeholders": {
"patterns": [
{
"name": "markup.italic.mclang",
"match": "(?<=(\\s|^))_[\\S]*_(?:(\\s|$))"
}
]
},
"strings": {
"patterns": [
{
"name": "string.quoted.double.mclang",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.mclang",
"match": "\\\\."
}
]
},
{
"name": "string.quoted.single.mclang",
"begin": "'",
"end": "'",
"patterns": [
{
"name": "constant.character.escape.mclang",
"match": "\\\\."
}
]
}
]
},
"comments": {
"patterns": [
{
"name": "constant.other.character-class.regexp",
"match": "(?://\\s*)(TODO(O*)|FIXME).*"
},
{
"name": "comment.line.double-slash.mclang",
"match": "(//(?!\\s?(TODO(O*)|FIXME)(\\s|:|$)).*|//\\s*)"
}
]
},
"intrinsics": {
"patterns": [
{
"name": "variable.name.source.mclang",
"match": "(?<=^|\\s)(\\+|-|\\*|int|ptr|bool|addr|any|void|max|divmod|_dbg_print|=|>|<|>=|<=|!=|>>|<<|\\||&|not|dup|swap|drop|over|rot|argc|argv|here|syscall0|syscall1|syscall2|syscall3|syscall4|syscall5|syscall6|\\?\\?\\?)(?=>$|\\s)"
}
]
},
"constants-and-special-vars": {
"patterns": [
{
"name": "constant.numeric.mclang",
"match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b(?!\\$)"
},
{
"name": "entity.name.function.mclang",
"match": "(?<=^|\\s)(NULL|true|false|cast(ptr)|cast(int)|cast(bool)|sizeof\\(u64\\)|sizeof\\(u32\\)|sizeof\\(ptr\\)|sizeof\\(bool\\)|sizeof\\(int\\)|sizeof\\(addr\\)|STDIN|STDOUT|STDERR|@ptr|@@ptr|@bool|@int|@addr|!bool|!ptr|!int|!addr|AT_FDCWD|O_RDONLY|O_WRONLY|O_RDWR|O_CREAT|O_TRUNC|O_NONBLOCK|F_SETFL|F_GETFL|EAGAIN|CLOCK_MONOTONIC|TIMER_ABSTIME|MAP_PRIVATE|MAP_ANONYMOUS|PROT_READ|PROT_WRITE|SIGQUIT|timespec\\.tv_sec|timespec\\.tv_nsec|sizeof\\(timespec\\)|ptr\\+|ptr-|ptr!=|ptr=|ptr<|\\+ptr|ptr-diff|sizeof\\(stat\\)|stat\\.st_dev|stat\\.st_ino|stat\\.st_mode|stat\\.st_nlink|stat\\.st_uid|stat\\.st_gid|stat\\.st_rdev|stat\\.st_size|@stat\\.st_size|stat\\.st_blksize|stat\\.st_blocks|stat\\.st_atim|stat\\.st_mtim|stat\\.st_ctim|sizeof\\(stat\\.st_dev\\)|sizeof\\(stat\\.st_ino\\)|sizeof\\(stat\\.st_mode\\)|sizeof\\(stat\\.st_nlink\\)|sizeof\\(stat\\.st_uid\\)|sizeof\\(stat\\.st_gid\\)|sizeof\\(stat\\.st_rdev\\)|sizeof\\(stat\\.st_size\\)|sizeof\\(stat\\.st_blksize\\)|sizeof\\(stat\\.st_blocks\\)|sizeof\\(stat\\.st_atim\\)|sizeof\\(stat\\.st_mtim\\)|sizeof\\(stat\\.st_ctim\\)|write|read|openat|fstat|stat|close|exit|mmap|clock_nanosleep|clock_gettime|fork|getpid|execve|wait4|rename|fcntl|kill|dup2|/|%|mod|div|imod|idiv|emod|nth_argv|lnot|land|lor|inc64-by|inc64|dec64|inc32|dec32|inc8|dec8|swap64|cstrlen|cstreq|cstr-to-str|fputs|puts|eputs|WIFSTOPPED|WIFCONTINUED|WIFSIGNALED|WTERMSIG|WIFEXITED|WEXITSTATUS|offsetof\\(Str\\.count\\)|offsetof\\(Str\\.data\\)|sizeof\\(Str\\)|Str\\.count|Str\\.data|@Str\\.count|@Str\\.data|!Str\\.count|!Str\\.data|@Str|!Str|str-chop-one-left|str-chop-one-right|\\?space|str-trim-left|str-chop-by-predicate|str-chop-by-delim|str-starts-with|\\?str-empty|streq|\\?digit|isdigit|\\?alpha|isalpha|\\?alnum|isalnum|try-parse-int|PUTU_BUFFER_CAP|fputu|fput0u|putu|put0u|eputu|memcpy|memset|srand|RAND_A|RAND_C|rand|getenv|TMP_CAP|tmp-clean|tmp-end|tmp-rewind|tmp-alloc|tmp-str-to-cstr|tmp-append|tmp-append-ptr|execvp|append-item|tmp-utos|map-file|\\?file-exist|\\?shell-safe-char|\\?shell-safe-str|shell-escape|timeit/from-here|1e9|timeit/to-here|str-rfind|dirname|putch|remove-ext|cmd-echoed)(?:\\s|$)"
}
]
}
}
}