feat(vs-code): Update aqua syntax defs [fixes LNG-227] (#46)

This commit is contained in:
InversionSpaces 2023-09-01 14:38:29 +02:00 committed by GitHub
parent f1ed3059f2
commit 3194dfb651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 83 additions and 51 deletions

View File

@ -3,10 +3,12 @@
"lineComment": "--" "lineComment": "--"
}, },
"brackets": [ "brackets": [
["{", "}"],
["[", "]"], ["[", "]"],
["(", ")"] ["(", ")"]
], ],
"autoClosingPairs": [ "autoClosingPairs": [
["{", "}"],
["[", "]"], ["[", "]"],
["(", ")"], ["(", ")"],
["\"", "\""], ["\"", "\""],

View File

@ -21,29 +21,45 @@
"repository": { "repository": {
"keywords": { "keywords": {
"patterns": [ "patterns": [
{
"name": "support.type.primitive.aqua",
"match": "\\b(string|bool|u8|u16|u32|u64|s8|s16|s32|s64|f32|f64)\\b"
},
{ {
"name": "keyword.control.flow.aqua", "name": "keyword.control.flow.aqua",
"match": "\\b(try|catch|par|if|else|otherwise|for|co|join)\\b" "match": "\\b(try|catch|par|if|else|otherwise|for|co|join|parseq)\\b"
}, },
{ {
"name": "keyword.control.other.aqua", "name": "keyword.control.other.aqua",
"match": "(<<-|<-|->|\\[\\]|\\*|\\?\\=|\\?|==)" "match": "(<<-|<-|->)"
}, },
{ {
"name": "keyword.topology.aqua", "name": "keyword.operator.math.aqua",
"match": "\\b(on|via|use|func|service|data|alias|const)\\b" "match": "(\\+|-|\/|(?<=[^:]\\s*)\\*|%|\\*\\*|>=|<=|>|<)"
}, },
{ {
"name": "keyword.operator.logical.aqua", "name": "keyword.operator.logical.aqua",
"match": "\\b(eqs|neq)\\b" "match": "=="
}, },
{ {
"name": "keyword.control.import", "name": "keyword.control.other.aqua",
"match": "\\b(import|module|export|declares|from|as)\\b" "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"
} }
] ]
}, },
@ -51,11 +67,11 @@
"patterns": [ "patterns": [
{ {
"name": "constant.language.topology.aqua", "name": "constant.language.topology.aqua",
"match": "%init_peer_id%|%last_error%|%HOST_PEER_ID%" "match": "%init_peer_id%|%last_error%|%HOST_PEER_ID%|HOST_PEER_ID|INIT_PEER_ID"
}, },
{ {
"name": "constant.numeric.aqua", "name": "constant.language.numeric.aqua",
"match": "\\b\\d+\\b" "match": "\\b-?\\d+(\\.\\d*)?\\b"
}, },
{ {
"name": "constant.language.boolean.aqua", "name": "constant.language.boolean.aqua",
@ -63,12 +79,7 @@
}, },
{ {
"name": "constant.language.option.nil.aqua", "name": "constant.language.option.nil.aqua",
"match": "nil" "match": "\\bnil\\b"
},
{
"//": "Defines tokens for constants used anywhere in code",
"name": "constant.language.other.aqua",
"match": "\\b[A-Z][A-Z0-9_]*\\b"
} }
] ]
}, },
@ -90,68 +101,87 @@
}, },
"semantics": { "semantics": {
"patterns": [ "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", "//": "Matches type name defined with alias clause",
"name": "entity.name.type", "name": "entity.name.type.aqua",
"match": "(?<=alias\\s*)[A-Z]\\w*(?=\\s*:)" "match": "(?<=alias\\s*)[A-Z]\\w*(?=\\s*:)"
}, },
{ {
"//": "Matches type specifier after function arguments and variables", "//": "Matches type specifiers in declarations",
"name": "support.type.specifier", "name": "entity.name.type.specifier.aqua",
"match": "(?<=alias.*?:.*?,*\\s**[\\[\\]\\*\\?]*)[A-Z][A-Za-z0-9_]*" "match": "(?<=:\\s*)(?:\\[\\]|\\*|\\?)*[A-Za-z]\\w*"
}, },
{ {
"//": "Matches type specifier in lambda type aliases", "//": "Defines tokens for data definitions ('data XXX:')",
"name": "support.type.specifier",
"match": "(?<=:\\s*[\\[\\]\\*\\?]*)[A-Z][A-Za-z0-9_]*"
},
{
"//": "Defines tokens for data types in Aqua (usage). Data types in aqua start with a captial letter and are followed by any space char.",
"name": "support.type.specifier",
"match": "\\b[A-Z][A-Za-z0-9_]+(?=\\s)"
},
{
"//": "Defines tokens for data and service definitions ('data XXX:')",
"name": "entity.name.type.data.aqua", "name": "entity.name.type.data.aqua",
"match": "\\b(?<=(data)\\s+)[A-Z][A-Za-z0-9_]+(?=:)\\b" "match": "\\b(?<=(data)\\s+)[A-Z][A-Za-z0-9_]+(?=:)\\b"
}, },
{ {
"//": "Defines tokens for data and service definitions ('service YYY:')", "//": "Defines tokens for service definitions ('service YYY:')",
"name": "entity.name.type.service.aqua", "name": "entity.name.type.service.aqua",
"match": "\\b(?<=(service)\\s+)[A-Z][A-Za-z0-9_]+(?=(\\(\"\\w*\"\\))*:)\\b" "match": "\\b(?<=(service)\\s+)[A-Z][A-Za-z0-9_]+(?=(\\(\"\\w*\"\\))?:)\\b"
}, },
{ {
"//": "Metod name in 'Srv.method(args)' call", "//": "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", "name": "support.function.method.call.aqua",
"match": "(?<=\\.)[a-z][a-zA-Z0-9_]+(?=\\()" "match": "(?<=\\.)[a-z][a-zA-Z0-9_]+(?=\\()"
}, },
{ {
"//": "Service name in 'Srv.method(args)' call", "//": "Ability name in 'Ability.method(args)' or 'Ability.field'",
"name": "support.type.service.aqua", "name": "support.type.ability.aqua",
"match": "\\b[A-Z][A-Za-z0-9_]*(?=\\..*?\\()" "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", "//": "Matches function arguments",
"name": "support.variable.parameter.function.arg", "name": "variable.parameter.value.aqua",
"match": "\\b[a-z]\\w*(?=:)\\b" "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", "//": "Matches defined variables",
"name": "variable.other", "name": "variable.other.definition.aqua",
"match": "\\b[a-z]\\w*(?=\\s*<-)\\b" "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", "//": "Matches function definition",
"name": "entity.name.function", "name": "entity.name.function.aqua",
"match": "\\b(?<=func\\s*)[a-z]\\w*(?=\\s*\\()\\b" "match": "\\b(?<=func\\s*)[A-Za-z]\\w*(?=\\s*(?:\\(|\\{))"
}, },
{ {
"//": "Matches method definition", "//": "Matches method definition, function usage or aggregate creation",
"name": "entity.name.function", "name": "entity.name.function.usage.aqua",
"match": "\\b[a-z]\\w*(?=\\s*\\(.*?\\)\\s*)\\b" "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" "scopeName": "source.aqua"
} }