aqua-vscode/syntaxes/aqua.tmLanguage.json
2024-03-05 20:45:28 +03:00

196 lines
7.2 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "aqua",
"patterns": [
{
"include": "#comments"
},
{
"include": "#keywords"
},
{
"include": "#constants"
},
{
"include": "#strings"
},
{
"include": "#semantics"
},
{
"include": "#todo-keyword"
}
],
"repository": {
"keywords": {
"patterns": [
{
"name": "keyword.control.flow.aqua",
"match": "\\b(try|catch|par|if|else|otherwise|for|co|join|parseq)\\b"
},
{
"name": "keyword.control.other.aqua",
"match": "(<<-|<-|->)"
},
{
"name": "keyword.operator.math.aqua",
"match": "(\\+|-|\/|(?<=[^:]\\s*)\\*|%|\\*\\*|>=|<=|>|<)"
},
{
"name": "keyword.operator.logical.aqua",
"match": "=="
},
{
"name": "keyword.control.other.aqua",
"match": "(\\[\\]|\\*|\\?|=|\\?=)"
},
{
"name": "keyword.control.topology.aqua",
"match": "\\b(on|via)\\b"
},
{
"name": "keyword.control.declaration.aqua",
"match": "\\b(func|service|data|ability|alias|const)\\b"
},
{
"name": "keyword.operator.logical.aqua",
"match": "(\\|\\||&&|!(?=\\s*\\w))"
},
{
"name": "keyword.operator.control.aqua",
"match": "(?<=\\w\\s*)!"
},
{
"name": "keyword.control.import.aqua",
"match": "\\b(import|module|export|declares|from|as|use|aqua)\\b"
}
]
},
"constants": {
"patterns": [
{
"name": "constant.language.topology.aqua",
"match": "%init_peer_id%|%last_error%|%HOST_PEER_ID%|HOST_PEER_ID|INIT_PEER_ID"
},
{
"name": "constant.language.numeric.aqua",
"match": "\\b-?\\d+(\\.\\d*)?\\b"
},
{
"name": "constant.language.boolean.aqua",
"match": "\\b(true|false)\\b"
},
{
"name": "constant.language.option.nil.aqua",
"match": "\\bnil\\b"
}
]
},
"strings": {
"name": "string.quoted.double.aqua",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.aqua",
"match": "\\\\."
}
]
},
"comments": {
"name": "comment.line.aqua",
"begin": "--",
"end": "$",
"patterns": [{ "include": "#todo-keyword" }]
},
"todo-keyword": {
"begin": "TODO:",
"end": "$",
"name": "keyword.todo"
},
"semantics": {
"patterns": [
{
"name": "entity.name.type.primitive.aqua",
"match": "\\b(string|bool|u8|u16|u32|u64|i8|i16|i32|i64|f32|f64)\\b"
},
{
"//": "Matches type name defined with alias clause",
"name": "entity.name.type.aqua",
"match": "(?<=alias\\s*)[A-Z]\\w*(?=\\s*:)"
},
{
"//": "Matches type specifiers in declarations",
"name": "entity.name.type.specifier.aqua",
"match": "(?<=:\\s*)(?:\\[\\]|\\*|\\?)*[A-Za-z]\\w*"
},
{
"//": "Defines tokens for data definitions ('data XXX:')",
"name": "entity.name.type.data.aqua",
"match": "\\b(?<=(data)\\s+)[A-Z][A-Za-z0-9_]+(?=:)\\b"
},
{
"//": "Defines tokens for service definitions ('service YYY:')",
"name": "entity.name.type.service.aqua",
"match": "\\b(?<=(service)\\s+)[A-Z][A-Za-z0-9_]+(?=(\\(\"\\w*\"\\))?:)\\b"
},
{
"//": "Defines tokens for ability definitions ('ability YYY:')",
"name": "entity.name.type.ability.aqua",
"match": "\\b(?<=(ability)\\s+)[A-Z][A-Za-z0-9_]+(?=:)\\b"
},
{
"//": "Method name in 'Ability.field.method(args)'",
"name": "support.function.method.call.aqua",
"match": "(?<=\\.)[a-z][a-zA-Z0-9_]+(?=\\()"
},
{
"//": "Ability name in 'Ability.method(args)' or 'Ability.field'",
"name": "support.type.ability.aqua",
"match": "\\b(?<=[^\\.])[A-Za-z]\\w*(?=\\.)"
},
{
"//": "Field name in 'Ability.field.method(args)' or 'Ability.field'",
"name": "support.other.field.aqua",
"match": "(?<=\\.)(?>[A-Za-z]\\w*)\\b(?!\\s*\\()"
},
{
"//": "Matches function arguments",
"name": "variable.parameter.value.aqua",
"match": "(?<=[,\\(]\\s*)[A-Za-z]\\w*(?=\\s*:)"
},
{
"//": "Matches function ability arguments",
"name": "variable.parameter.ability.aqua",
"match": "(?<=func\\s*[A-Za-z]\\w*\\s*{\\s*(?:[A-Za-z]\\w*\\s*,\\s*)*)[A-Za-z]\\w*\\b"
},
{
"//": "Matches defined variables",
"name": "variable.other.definition.aqua",
"match": "\\b[A-Za-z]\\w*(?=\\s*(?:,\\s*[A-Za-z]\\w*)*\\s*(?:<-|=))"
},
{
"//": "Matches declared variables",
"name": "variable.other.declaration.aqua",
"match": "\\b[A-Za-z]\\w*(?=:)"
},
{
"//": "Matches function definition",
"name": "entity.name.function.aqua",
"match": "\\b(?<=func\\s*)[A-Za-z]\\w*(?=\\s*(?:\\(|\\{))"
},
{
"//": "Matches method definition, function usage or aggregate creation",
"name": "entity.name.function.usage.aqua",
"match": "\\b[A-Za-z]\\w*(?=\\s*(?:\\(|\\{))"
},
{
"//": "Matches variables anywhere",
"name": "variable.other.any.aqua",
"match": "\\b[A-Za-z]\\w*\\b"
}
]
}
},
"scopeName": "source.aqua"
}