UNPKG

tm-grammars

Version:
403 lines (402 loc) 10.1 kB
{ "displayName": "MoonBit", "fileTypes": [ "mbt" ], "name": "moonbit", "patterns": [ { "include": "#strings" }, { "include": "#comments" }, { "include": "#constants" }, { "include": "#keywords" }, { "include": "#functions" }, { "include": "#support" }, { "include": "#attribute" }, { "include": "#types" }, { "include": "#modules" }, { "include": "#variables" } ], "repository": { "attribute": { "patterns": [ { "captures": { "1": { "name": "keyword.control.directive" }, "2": { "patterns": [ { "include": "#strings" }, { "match": "[ .0-9A-Z_a-z]+", "name": "entity.name.tag" }, { "match": "=", "name": "keyword.operator.attribute.moonbit" } ] } }, "match": "(#[a-z][ .0-9A-Z_a-z]*)(.*)" } ] }, "comments": { "patterns": [ { "match": "//[^/].*", "name": "comment.line" }, { "begin": "///", "name": "comment.block.documentation.moonbit", "patterns": [ { "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(mbt\\s+test|mbt\\s+test(async)|mbt|moonbit\\s+test|moonbit\\s+test(async)|moonbit|)(\\s+[^`~]*)?$)", "beginCaptures": { "3": { "name": "punctuation.definition.markdown" }, "5": { "name": "fenced_code.block.language" }, "6": { "name": "fenced_code.block.language.attributes" } }, "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", "endCaptures": { "3": { "name": "punctuation.definition.markdown" } }, "name": "markup.fenced_code.block.markdown", "patterns": [ { "begin": "(^|\\G)(\\s*)(.*)", "contentName": "meta.embedded.block.moonbit", "patterns": [ { "include": "$self" } ], "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)" } ] } ], "while": "///" } ] }, "constants": { "patterns": [ { "match": "\\b\\d([_\\d])*(?!\\.)((U)?(L)?|N?)\\b", "name": "constant.numeric.moonbit" }, { "match": "(?<=\\.)\\d((?=\\.)|\\b)", "name": "constant.numeric.moonbit" }, { "match": "\\b\\d+(?=\\.\\.)", "name": "constant.numeric.moonbit" }, { "match": "\\b\\d[_\\d]*\\.[_\\d]*([Ee][-+]?\\d[_\\d]*\\b)?", "name": "constant.numeric.moonbit" }, { "match": "\\b0[Oo][0-7][0-7]*((U)?(L)?|N?)\\b", "name": "constant.numeric.moonbit" }, { "match": "\\b0[Xx][A-Fa-f\\d][A-F_a-f\\d]*(([LU]|UL|N)\\b|\\.[A-F_a-f\\d]*([Pp][-+]?[A-F_a-f\\d]+\\b)?)?", "name": "constant.numeric.moonbit" }, { "match": "\\b(true|false)\\b", "name": "constant.language.moonbit" } ] }, "escape": { "patterns": [ { "match": "\\\\[\"'0\\\\bnrt]", "name": "constant.character.escape.moonbit" }, { "match": "\\\\x\\h{2}", "name": "constant.character.escape.moonbit" }, { "match": "\\\\o[0-3][0-7]{2}", "name": "constant.character.escape.moonbit" }, { "match": "\\\\u\\h{4}", "name": "constant.character.escape.unicode.moonbit" }, { "match": "\\\\u\\{\\h*}", "name": "constant.character.escape.unicode.moonbit" } ] }, "functions": { "patterns": [ { "captures": { "1": { "name": "keyword.moonbit" }, "2": { "name": "entity.name.type.moonbit" }, "3": { "name": "entity.name.function.moonbit" } }, "match": "\\b(fn)\\b\\s*(?:([A-Z][0-9A-Z_a-z]*)::)?([0-9_a-z][0-9A-Z_a-z]*)?\\b" }, { "begin": "(?!\\bfn\\s+)(?:\\.|::)?([0-9_a-z][0-9A-Z_a-z]*([!?]|!!)?)\\s*(\\()", "beginCaptures": { "1": { "name": "entity.name.function.moonbit" }, "2": { "name": "punctuation.brackets.round.moonbit" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.brackets.round.moonbit" } }, "name": "meta.function.call.moonbit", "patterns": [ { "include": "#comments" }, { "include": "#constants" }, { "include": "#keywords" }, { "include": "#functions" }, { "include": "#support" }, { "include": "#types" }, { "include": "#modules" }, { "include": "#strings" }, { "include": "#variables" } ] } ] }, "interpolation": { "patterns": [ { "begin": "\\\\\\{", "beginCaptures": { "0": { "name": "punctuation.section.embedded.begin.moonbit" } }, "contentName": "source.moonbit", "end": "}", "endCaptures": { "0": { "name": "punctuation.section.embedded.end.moonbit" } }, "name": "meta.embedded.line.moonbit", "patterns": [ { "include": "$self" } ] } ] }, "keywords": { "patterns": [ { "match": "\\b(async)\\b", "name": "keyword.control.moonbit.async" }, { "match": "\\b(guard|if|while|break|continue|return|try|catch|except|raise|noraise|match|lexmatch|using|else|as|in|is|loop|for|async|defer)\\b", "name": "keyword.control.moonbit" }, { "match": "\\b(type!|lexmatch\\?|(type|typealias|let|const|enum|struct|import|trait|traitalias|derive|test|impl|with|fnalias|recur|suberror|letrec|and|where|declare)\\b)", "name": "keyword.moonbit" }, { "match": "\\b(mut|pub|priv|readonly|extern)\\b", "name": "storage.modifier.moonbit" }, { "match": "->", "name": "storage.type.function.arrow.moonbit" }, { "match": "=>", "name": "storage.type.function.arrow.moonbit" }, { "match": "=", "name": "keyword.operator.assignment.moonbit" }, { "match": "\\|>", "name": "keyword.operator.other.moonbit" }, { "match": "(===?|!=|>=|<=|(?<!-)(?<!\\|)>(?!>)|<(?!<))", "name": "keyword.operator.comparison.moonbit" }, { "match": "(\\bnot\\b|&&|\\|\\|)", "name": "keyword.operator.logical.moonbit" }, { "match": "(\\|(?!\\|)(?!>)|&(?!&)|\\^|<<|>>)", "name": "keyword.operator.bitwise.moonbit" }, { "match": "(\\+|-(?!>)|[%*/])", "name": "keyword.operator.math.moonbit" } ] }, "modules": { "patterns": [ { "match": "@[A-Za-z][/-9A-Z_a-z]*", "name": "entity.name.namespace.moonbit" } ] }, "strings": { "patterns": [ { "captures": { "1": { "name": "keyword.operator.other.moonbit" } }, "match": "(#\\|).*", "name": "string.line" }, { "captures": { "1": { "name": "keyword.operator.other.moonbit" }, "2": { "patterns": [ { "include": "#escape" }, { "include": "#interpolation" } ] } }, "match": "(\\$\\|)(.*)", "name": "string.line" }, { "begin": "'", "end": "'", "name": "string.quoted.single.moonbit", "patterns": [ { "include": "#escape" } ] }, { "begin": "\"", "end": "\"", "name": "string.quoted.double.moonbit", "patterns": [ { "include": "#escape" }, { "include": "#interpolation" } ] } ] }, "support": { "patterns": [ { "match": "\\b(Eq|Compare|Hash|Show|Default|ToJson|FromJson)\\b", "name": "support.class.moonbit" } ] }, "types": { "patterns": [ { "match": "\\b(?<!@)[A-Z][0-9A-Z_a-z]*((\\?)+|\\b)", "name": "entity.name.type.moonbit" } ] }, "variables": { "patterns": [ { "match": "\\b(?<!\\.|::)[_a-z][0-9A-Z_a-z]*\\b", "name": "variable.other.moonbit" } ] } }, "scopeName": "source.moonbit" }