separate ^-strings from normal ones

This commit is contained in:
Daniella / Tove 2024-11-15 21:44:36 +01:00
parent e62088ee87
commit 1a197b26ab
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
5 changed files with 2370 additions and 2353 deletions

View file

@ -5,6 +5,7 @@ module.exports = grammar({
source_file: $ => seq(repeat($._statement)), source_file: $ => seq(repeat($._statement)),
_unspaced_statement: $ => seq( _unspaced_statement: $ => seq(
choice( choice(
$.ministring,
$.string, $.string,
$.number, $.number,
$.function_definition, $.function_definition,
@ -53,10 +54,8 @@ module.exports = grammar({
$.identifier, $.identifier,
), ),
number: $ => token(prec(10, /\d+(\.\d+)?/)), number: $ => token(prec(10, /\d+(\.\d+)?/)),
string: $ => choice( ministring: $ => token(prec(10, seq('^', /[^ \n\r\t<>:;&{}"'\[\],]+/))),
token(prec(10, seq('^', /[^ \n\r\t<>:;&{}"'\[\],]+/))), string: $ => seq('"', repeat(choice(/\\./, /./)), '"'),
seq('"', repeat(choice(/\\./, /./)), '"'),
),
call_expr: $ => seq('<', optional($._spacing), repeat($._statement), $._unspaced_statement, '>'), call_expr: $ => seq('<', optional($._spacing), repeat($._statement), $._unspaced_statement, '>'),
with_expr: $ => seq( with_expr: $ => seq(
'with', $._spacing, 'with', $._spacing,

View file

@ -16,3 +16,4 @@
(call (call) @function (identifier) @property) (call (call) @function (identifier) @property)
(def (identifier) @local.definition) (def (identifier) @local.definition)
(with_expr (identifier) @local.definition) (with_expr (identifier) @local.definition)
(ministring) @string.special.symbol

View file

@ -20,6 +20,10 @@
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{
"type": "SYMBOL",
"name": "ministring"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "string" "name": "string"
@ -338,58 +342,53 @@
} }
} }
}, },
"string": { "ministring": {
"type": "CHOICE", "type": "TOKEN",
"members": [ "content": {
{ "type": "PREC",
"type": "TOKEN", "value": 10,
"content": { "content": {
"type": "PREC",
"value": 10,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "^"
},
{
"type": "PATTERN",
"value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\],]+"
}
]
}
}
},
{
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
"type": "STRING", "type": "STRING",
"value": "\"" "value": "^"
}, },
{ {
"type": "REPEAT", "type": "PATTERN",
"content": { "value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\],]+"
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "\\\\."
},
{
"type": "PATTERN",
"value": "."
}
]
}
},
{
"type": "STRING",
"value": "\""
} }
] ]
} }
}
},
"string": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "\\\\."
},
{
"type": "PATTERN",
"value": "."
}
]
}
},
{
"type": "STRING",
"value": "\""
}
] ]
}, },
"call_expr": { "call_expr": {

View file

@ -39,6 +39,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -106,6 +110,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -211,6 +219,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -282,6 +294,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -406,6 +422,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -494,6 +514,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -604,6 +628,10 @@
"type": "include", "type": "include",
"named": true "named": true
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "number", "type": "number",
"named": true "named": true
@ -738,6 +766,10 @@
"type": "include", "type": "include",
"named": false "named": false
}, },
{
"type": "ministring",
"named": true
},
{ {
"type": "namespace", "type": "namespace",
"named": false "named": false

File diff suppressed because it is too large Load diff