304 lines
6.7 KiB
JSON
304 lines
6.7 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "Nub",
|
|
"scopeName": "source.nub",
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#modifiers"
|
|
},
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#numbers"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"include": "#function-definition"
|
|
},
|
|
{
|
|
"include": "#struct-definition"
|
|
},
|
|
{
|
|
"include": "#function-call"
|
|
},
|
|
{
|
|
"include": "#identifiers"
|
|
}
|
|
],
|
|
"repository": {
|
|
"comments": {
|
|
"patterns": [
|
|
{
|
|
"name": "comment.line.double-slash.nub",
|
|
"begin": "//",
|
|
"end": "$"
|
|
},
|
|
{
|
|
"name": "comment.block.nub",
|
|
"begin": "/\\*",
|
|
"end": "\\*/"
|
|
}
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.control.nub",
|
|
"match": "\\b(if|else|while|break|continue|return|let|defer)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.other.nub",
|
|
"match": "\\b(func|struct|module|import)\\b"
|
|
}
|
|
]
|
|
},
|
|
"modifiers": {
|
|
"patterns": [
|
|
{
|
|
"name": "storage.modifier.nub",
|
|
"match": "\\b(export|extern)\\b"
|
|
}
|
|
]
|
|
},
|
|
"types": {
|
|
"patterns": [
|
|
{
|
|
"include": "#function-type"
|
|
},
|
|
{
|
|
"name": "storage.type.primitive.nub",
|
|
"match": "\\b(i8|i16|i32|i64|u8|u16|u32|u64|f32|f64|bool|string|cstring|void|any)\\b"
|
|
},
|
|
{
|
|
"name": "storage.type.array.nub",
|
|
"match": "\\[\\]"
|
|
},
|
|
{
|
|
"name": "storage.type.pointer.nub",
|
|
"match": "\\^"
|
|
}
|
|
]
|
|
},
|
|
"function-type": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\b(func)\\s*\\(",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "storage.type.function.nub"
|
|
}
|
|
},
|
|
"end": "(?<=\\))(?:\\s*:\\s*([^\\s,;{}()]+))?",
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "storage.type.nub"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#function-type-parameters"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"function-type-parameters": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\.\\.\\.",
|
|
"name": "keyword.operator.variadic.nub"
|
|
},
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"match": ",",
|
|
"name": "punctuation.separator.nub"
|
|
}
|
|
]
|
|
},
|
|
"strings": {
|
|
"patterns": [
|
|
{
|
|
"name": "string.quoted.double.nub",
|
|
"begin": "\"",
|
|
"end": "\"",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.nub",
|
|
"match": "\\\\(n|t|r|\\\\|\"|')"
|
|
},
|
|
{
|
|
"name": "constant.character.escape.nub",
|
|
"match": "\\\\[0-7]{1,3}"
|
|
},
|
|
{
|
|
"name": "constant.character.escape.nub",
|
|
"match": "\\\\x[0-9A-Fa-f]{1,2}"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "string.quoted.single.nub",
|
|
"begin": "'",
|
|
"end": "'",
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.nub",
|
|
"match": "\\\\(n|t|r|\\\\|\"|')"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"numbers": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.numeric.float.nub",
|
|
"match": "\\b\\d+\\.\\d*([eE][+-]?\\d+)?[fF]?\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.integer.decimal.nub",
|
|
"match": "\\b\\d+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.integer.hexadecimal.nub",
|
|
"match": "\\b0[xX][0-9A-Fa-f]+\\b"
|
|
},
|
|
{
|
|
"name": "constant.numeric.integer.binary.nub",
|
|
"match": "\\b0[bB][01]+\\b"
|
|
}
|
|
]
|
|
},
|
|
"operators": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.operator.assignment.nub",
|
|
"match": "="
|
|
},
|
|
{
|
|
"name": "keyword.operator.comparison.nub",
|
|
"match": "(==|!=|<=|>=|<|>)"
|
|
},
|
|
{
|
|
"name": "keyword.operator.arithmetic.nub",
|
|
"match": "(\\+|\\-|\\*|/)"
|
|
},
|
|
{
|
|
"name": "keyword.operator.logical.nub",
|
|
"match": "(&&|\\|\\||!)"
|
|
},
|
|
{
|
|
"name": "keyword.operator.address.nub",
|
|
"match": "&"
|
|
},
|
|
{
|
|
"name": "keyword.operator.dereference.nub",
|
|
"match": "\\^"
|
|
},
|
|
{
|
|
"name": "keyword.operator.member-access.nub",
|
|
"match": "\\."
|
|
},
|
|
{
|
|
"name": "keyword.operator.module-access.nub",
|
|
"match": "::"
|
|
}
|
|
]
|
|
},
|
|
"function-definition": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\b(export\\s+|extern\\s+)?(func)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "storage.modifier.nub"
|
|
},
|
|
"2": {
|
|
"name": "keyword.other.nub"
|
|
},
|
|
"3": {
|
|
"name": "entity.name.function.nub"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"patterns": [
|
|
{
|
|
"include": "#function-parameters"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"struct-definition": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\b(struct)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\b",
|
|
"captures": {
|
|
"1": {
|
|
"name": "keyword.other.nub"
|
|
},
|
|
"2": {
|
|
"name": "entity.name.type.struct.nub"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"function-parameters": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\.\\.\\.",
|
|
"name": "keyword.operator.variadic.nub"
|
|
},
|
|
{
|
|
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*",
|
|
"captures": {
|
|
"1": {
|
|
"name": "variable.parameter.nub"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"include": "#identifiers"
|
|
}
|
|
]
|
|
},
|
|
"function-call": {
|
|
"patterns": [
|
|
{
|
|
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?=\\()",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.function.call.nub"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"identifiers": {
|
|
"patterns": [
|
|
{
|
|
"name": "variable.other.nub",
|
|
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
} |