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,16 +42,15 @@ module.exports = grammar({
'}',
),
identifier: $ => /[^ \n\r\t<>:;&{}"'\[\]]+/,
call: $ => seq(
choice(
seq(
optional($.call),
':',
$.identifier,
),
$.operation,
call: $ => choice(
seq(
optional($.call),
':',
optional(repeat('&')),
$.identifier,
),
$.operation,
$.identifier,
),
number: $ => /\d+(\.\d+)?/,
string: $ => seq('"', repeat(choice(/\\./, /./)), '"'),
@ -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": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_statement"
}
"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,48 +272,58 @@
},
"identifier": {
"type": "PATTERN",
"value": "[^ \\n\\r\\t<>:;&{}\"']+"
"value": "[^ \\n\\r\\t<>:;&{}\"'\\[\\]]+"
},
"call": {
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SEQ",
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "call"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "identifier"
"name": "call"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "operation"
"type": "STRING",
"value": ":"
},
{
"type": "CHOICE",
"members": [
{
"type": "REPEAT",
"content": {
"type": "STRING",
"value": "&"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
},
{
"type": "SYMBOL",
"name": "operation"
},
{
"type": "SYMBOL",
"name": "identifier"
}
]
},
@ -413,11 +432,19 @@
"name": "_spacing"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_statement"
}
"type": "CHOICE",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_statement"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
@ -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