fix => and =>? support

This commit is contained in:
Daniella / Tove 2024-11-15 11:36:15 +01:00
parent 4246b7a44c
commit 9c9856d9ee
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
4 changed files with 2503 additions and 2475 deletions

View file

@ -2,7 +2,7 @@ module.exports = grammar({
name: 'spl',
rules: {
source_file: $ => seq(repeat($._statement), optional($._unspaced_statement)),
source_file: $ => seq(repeat($._statement)),
_unspaced_statement: $ => seq(
choice(
$.string,
@ -42,17 +42,16 @@ module.exports = grammar({
'}',
),
identifier: $ => /[^ \n\r\t<>:;&{}"'\[\]]+/,
call: $ => seq(
choice(
call: $ => choice(
seq(
optional($.call),
':',
optional(repeat('&')),
$.identifier,
),
$.operation,
$.identifier,
),
),
number: $ => /\d+(\.\d+)?/,
string: $ => seq('"', repeat(choice(/\\./, /./)), '"'),
call_expr: $ => seq('<', optional($._spacing), repeat($._statement), $._unspaced_statement, '>'),
@ -62,7 +61,7 @@ module.exports = grammar({
';',
),
array: $ => seq('[', $._spacing, optional(repeat($._statement)), ']'),
operation: $ => choice(/[+\-*\/%&]/, "=>", "=>?"),
operation: $ => choice(/[+\-*\/%&]/, "=>?", "=>"),
variable: $ => choice(
seq('def', $._spacing, $.identifier),
seq('=', $.identifier),
@ -79,7 +78,7 @@ module.exports = grammar({
)),
'}',
),
_spacing: $ => /[ \n\r\t]+/,
_spacing: $ => /[ \n\r\t\(\)]+/,
if: $ => seq(
'if', $._spacing,
'{', $._spacing,

View file

@ -3,11 +3,16 @@
"name": "spl",
"rules": {
"source_file": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_statement"
}
}
]
},
"_unspaced_statement": {
"type": "SEQ",
@ -170,6 +175,10 @@
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "_spacing"
},
{
"type": "STRING",
"value": "!"
@ -263,12 +272,9 @@
},
"identifier": {
"type": "PATTERN",
"value": "[^ \\n\\r\\t<>:;&{}\"']+"
"value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\]]+"
},
"call": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
@ -290,6 +296,21 @@
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
{
"type": "REPEAT",
"content": {
"type": "STRING",
"value": "&"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "identifier"
@ -305,8 +326,6 @@
"name": "identifier"
}
]
}
]
},
"number": {
"type": "PATTERN",
@ -412,6 +431,9 @@
"type": "SYMBOL",
"name": "_spacing"
},
{
"type": "CHOICE",
"members": [
{
"type": "REPEAT",
"content": {
@ -419,6 +441,11 @@
"name": "_statement"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "]"
@ -432,6 +459,10 @@
"type": "PATTERN",
"value": "[+\\-*\\/%&]"
},
{
"type": "STRING",
"value": "=>?"
},
{
"type": "STRING",
"value": "=>"
@ -582,7 +613,7 @@
},
"_spacing": {
"type": "PATTERN",
"value": "[ \\n\\r\\t]+"
"value": "[ \\n\\r\\t\\(\\)]+"
},
"if": {
"type": "SEQ",

View file

@ -674,6 +674,10 @@
"type": "=>",
"named": false
},
{
"type": "=>?",
"named": false
},
{
"type": ">",
"named": false

File diff suppressed because it is too large Load diff