hblang-vscode/syntaxes/hblang.tmLanguage.json

241 lines
4.2 KiB
JSON

{
"scopeName": "source.hblang",
"name": "hblang",
"fileTypes": [
"hb"
],
"patterns": [
{
"include": "#all"
}
],
"repository": {
"all": {
"patterns": [
{
"include": "#comment"
},
{
"include": "#string"
},
{
"include": "#struct"
},
{
"include": "#keyword"
},
{
"include": "#number"
},
{
"include": "#punctuation"
},
{
"include": "#function"
},
{
"include": "#operator"
},
{
"include": "#variable"
},
{
"include": "#type"
},
{
"include": "#array"
}
]
},
"parameter": {
"patterns": [
{
"name": "variable.parameter.hblang",
"match": "\\b\\w+\\s*:\\s*(?:\\^)?[\\w\\$]+\\b"
}
]
},
"number": {
"patterns": [
{
"name": "constant.numeric.float.hblang",
"match": "\\b\\d+\\.\\d+\\b"
},
{
"name": "constant.numeric.hex.hblang",
"match": "0x[0-9A-Fa-f]+"
},
{
"name": "constant.numeric.binary.hblang",
"match": "0b[0-1]+"
},
{
"name": "constant.numeric.octal.hblang",
"match": "0o[0-7]+"
},
{
"name": "constant.numeric.decimal.hblang",
"match": "\\b\\d+\\b"
}
]
},
"comment": {
"patterns": [
{
"name": "comment.block.hblang",
"begin": "/\\*",
"end": "\\*/"
},
{
"name": "comment.line.double-slash.hblang",
"begin": "//",
"end": "$"
}
]
},
"string": {
"patterns": [
{
"name": "string.quoted.double.hblang",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.hblang",
"match": "\\\\."
}
]
},
{
"name": "string.quoted.single.hblang",
"begin": "'",
"end": "'",
"patterns": [
{
"name": "constant.character.escape.hblang",
"match": "\\\\."
}
]
}
]
},
"keyword": {
"patterns": [
{
"name": "keyword.control.hblang",
"match": "(?<!\\w)\\b(fn|loop|break|if|else|return|packed|continue|true|false|struct|idk|die|null|defer|union|enum|match)\\b(?!\\w)"
}
]
},
"type": {
"patterns": [
{
"name": "storage.type.hblang",
"match": "(?<!\\w)\\b(f(32|64)|uint|int|u(8|16|32)|i(8|16|32)|void|bool|type|never)\\b(?!\\w)"
}
]
},
"variable": {
"patterns": [
{
"name": "variable.declaration.hblang",
"match": "\\b\\w+\\b(?=\\s*:=)"
},
{
"name": "variable.assignment.hblang",
"match": "\\b\\w+\\b(?=\\s*=(?!=))"
},
{
"name": "variable.member.hblang",
"match": "(?<=\\.)\\w+\\b"
}
]
},
"operator": {
"patterns": [
{
"name": "keyword.operator.assignment.hblang",
"match": ":="
},
{
"name": "keyword.operator.assignment.hblang",
"match": "=(?!=)"
},
{
"name": "keyword.operator.hblang",
"match": "(\\$|\\?|@|<<=|>>=|>=|<=|\\^=|\\+=|-=|\\*=|\\/=|%=|\\|=|&=|\\^|\\*|&|<<|>>|\\+|\\-|\\/|%|\\||!|==|!=|<|>)"
}
]
},
"struct": {
"patterns": [
{
"name": "entity.name.type.struct.hblang",
"match": "\\b[A-Z]\\w*\\b"
}
]
},
"punctuation": {
"patterns": [
{
"name": "punctuation.terminator.statement.hblang",
"match": ";|\\.|,|(?<!:):(?!=)"
}
]
},
"function": {
"patterns": [
{
"name": "meta.function.declaration.hblang",
"begin": "(\\b\\w+\\b)\\s*(:=)\\s*(fn)\\s*\\(",
"end": "\\)",
"beginCaptures": {
"1": {
"name": "entity.name.function.hblang"
},
"2": {
"name": "keyword.operator.assignment.hblang"
},
"3": {
"name": "keyword.control.hblang"
}
},
"patterns": [
{
"include": "#all"
}
]
},
{
"name": "meta.function.call.hblang",
"begin": "@?\\w+\\s*\\(",
"end": "\\)",
"beginCaptures": {
"0": {
"name": "entity.name.function.hblang"
}
},
"patterns": [
{
"include": "#all"
}
]
}
]
},
"array": {
"patterns": [
{
"name": "meta.array.initialization.hblang",
"begin": "\\.\\[",
"end": "\\]",
"patterns": [
{
"include": "#all"
}
]
}
]
}
}
}