improve highlighting

This commit is contained in:
Daniella / Tove 2024-11-15 21:01:47 +01:00
parent 02baa62702
commit e62088ee87
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
5 changed files with 2971 additions and 2784 deletions

View file

@ -6,6 +6,7 @@ module.exports = grammar({
_unspaced_statement: $ => seq(
choice(
$.string,
$.number,
$.function_definition,
$.type_definition,
$.with_expr,
@ -16,7 +17,6 @@ module.exports = grammar({
$.use,
$.include,
$.def,
$.number,
$.call_expr,
seq(
repeat('&'),
@ -41,7 +41,7 @@ module.exports = grammar({
repeat($._statement),
'}',
),
identifier: $ => /[^ \n\r\t<>:;&{}"'\[\]]+/,
identifier: $ => /[^ \n\r\t<>:;&{}"'\[\],]+/,
call: $ => choice(
seq(
optional($.call),
@ -52,20 +52,20 @@ module.exports = grammar({
$.operation,
$.identifier,
),
number: $ => /\d+(\.\d+)?/,
string: $ => seq('"', repeat(choice(/\\./, /./)), '"'),
number: $ => token(prec(10, /\d+(\.\d+)?/)),
string: $ => choice(
token(prec(10, seq('^', /[^ \n\r\t<>:;&{}"'\[\],]+/))),
seq('"', repeat(choice(/\\./, /./)), '"'),
),
call_expr: $ => seq('<', optional($._spacing), repeat($._statement), $._unspaced_statement, '>'),
with_expr: $ => seq(
'with', $._spacing,
repeat($.identifier),
repeat(seq($.identifier, $._spacing)),
';',
),
array: $ => seq('[', $._spacing, optional(repeat($._statement)), ']'),
operation: $ => choice(/[+\-*\/%&]/, "=>!", "=>?", "=>?!", "=>"),
variable: $ => choice(
seq('def', $._spacing, $.identifier),
seq('=', $.identifier),
),
set_variable: $ => seq('=', $.identifier),
type_definition: $ => seq(
'construct', $._spacing,
$.call, $._spacing,
@ -115,6 +115,7 @@ module.exports = grammar({
def: $ => seq(
'def', $._spacing,
$.identifier,
optional(repeat(seq(',', $._spacing, $.identifier)))
),
},
});

View file

@ -12,4 +12,7 @@
(number) @number
(string) @string
(call (call) @function (identifier) @property)
(call (identifier) @function)
(call (call) @function (identifier) @property)
(def (identifier) @local.definition)
(with_expr (identifier) @local.definition)

View file

@ -24,6 +24,10 @@
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "number"
},
{
"type": "SYMBOL",
"name": "function_definition"
@ -64,10 +68,6 @@
"type": "SYMBOL",
"name": "def"
},
{
"type": "SYMBOL",
"name": "number"
},
{
"type": "SYMBOL",
"name": "call_expr"
@ -272,7 +272,7 @@
},
"identifier": {
"type": "PATTERN",
"value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\]]+"
"value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\],]+"
},
"call": {
"type": "CHOICE",
@ -328,35 +328,67 @@
]
},
"number": {
"type": "PATTERN",
"value": "\\d+(\\.\\d+)?"
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 10,
"content": {
"type": "PATTERN",
"value": "\\d+(\\.\\d+)?"
}
}
},
"string": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "REPEAT",
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "\\\\."
},
{
"type": "PATTERN",
"value": "."
}
]
"type": "PREC",
"value": 10,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "^"
},
{
"type": "PATTERN",
"value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\],]+"
}
]
}
}
},
{
"type": "STRING",
"value": "\""
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "\\\\."
},
{
"type": "PATTERN",
"value": "."
}
]
}
},
{
"type": "STRING",
"value": "\""
}
]
}
]
},
@ -410,8 +442,17 @@
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "identifier"
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "_spacing"
}
]
}
},
{
@ -477,38 +518,16 @@
}
]
},
"variable": {
"type": "CHOICE",
"set_variable": {
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "def"
},
{
"type": "SYMBOL",
"name": "_spacing"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
"type": "STRING",
"value": "="
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
"type": "SYMBOL",
"name": "identifier"
}
]
},
@ -845,6 +864,34 @@
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_spacing"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
}
},
{
"type": "BLANK"
}
]
}
]
}

View file

@ -314,7 +314,7 @@
"named": true,
"fields": {},
"children": {
"multiple": false,
"multiple": true,
"required": true,
"types": [
{
@ -658,6 +658,10 @@
"type": "&",
"named": false
},
{
"type": ",",
"named": false
},
{
"type": ":",
"named": false

File diff suppressed because it is too large Load diff