Add field names to quoted delimiters

This commit is contained in:
Jonatan Kłosko 2021-09-29 11:54:52 +02:00
parent e35f31122f
commit 3cf73a2529
4 changed files with 310471 additions and 269573 deletions

View File

@ -877,7 +877,7 @@ function defineQuoted(start, end, name) {
return {
[`_quoted_i_${name}`]: ($) =>
seq(
start,
field("quoted_start", start),
repeat(
choice(
alias($[`_quoted_content_i_${name}`], $.quoted_content),
@ -885,12 +885,12 @@ function defineQuoted(start, end, name) {
$.escape_sequence
)
),
end
field("quoted_end", end)
),
[`_quoted_${name}`]: ($) =>
seq(
start,
field("quoted_start", start),
repeat(
choice(
alias($[`_quoted_content_${name}`], $.quoted_content),
@ -898,7 +898,7 @@ function defineQuoted(start, end, name) {
$.escape_sequence
)
),
end
field("quoted_end", end)
),
};
}

View File

@ -1073,8 +1073,12 @@
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "\""
}
},
{
"type": "REPEAT",
@ -1102,17 +1106,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "\""
}
}
]
},
"_quoted_double": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "\""
}
},
{
"type": "REPEAT",
@ -1136,17 +1148,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "\""
}
}
]
},
"_quoted_i_single": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "'"
}
},
{
"type": "REPEAT",
@ -1174,17 +1194,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "'"
}
}
]
},
"_quoted_single": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "'"
}
},
{
"type": "REPEAT",
@ -1208,17 +1236,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "'"
}
}
]
},
"_quoted_i_heredoc_single": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "'''"
}
},
{
"type": "REPEAT",
@ -1246,17 +1282,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "'''"
}
}
]
},
"_quoted_heredoc_single": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "'''"
}
},
{
"type": "REPEAT",
@ -1280,17 +1324,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "'''"
}
}
]
},
"_quoted_i_heredoc_double": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "\"\"\""
}
},
{
"type": "REPEAT",
@ -1318,17 +1370,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "\"\"\""
}
}
]
},
"_quoted_heredoc_double": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "\"\"\""
}
},
{
"type": "REPEAT",
@ -1352,17 +1412,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "\"\"\""
}
}
]
},
"_quoted_i_parenthesis": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "REPEAT",
@ -1390,17 +1458,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": ")"
}
}
]
},
"_quoted_parenthesis": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "REPEAT",
@ -1424,17 +1500,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": ")"
}
}
]
},
"_quoted_i_curly": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "{"
}
},
{
"type": "REPEAT",
@ -1462,17 +1546,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "}"
}
}
]
},
"_quoted_curly": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "{"
}
},
{
"type": "REPEAT",
@ -1496,17 +1588,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "}"
}
}
]
},
"_quoted_i_square": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "["
}
},
{
"type": "REPEAT",
@ -1534,17 +1634,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "]"
}
}
]
},
"_quoted_square": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "["
}
},
{
"type": "REPEAT",
@ -1568,17 +1676,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "]"
}
}
]
},
"_quoted_i_angle": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "<"
}
},
{
"type": "REPEAT",
@ -1606,17 +1722,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": ">"
}
}
]
},
"_quoted_angle": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "<"
}
},
{
"type": "REPEAT",
@ -1640,17 +1764,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": ">"
}
}
]
},
"_quoted_i_bar": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "|"
}
},
{
"type": "REPEAT",
@ -1678,17 +1810,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "|"
}
}
]
},
"_quoted_bar": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "|"
}
},
{
"type": "REPEAT",
@ -1712,17 +1852,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "|"
}
}
]
},
"_quoted_i_slash": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "/"
}
},
{
"type": "REPEAT",
@ -1750,17 +1898,25 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "/"
}
}
]
},
"_quoted_slash": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "quoted_start",
"content": {
"type": "STRING",
"value": "/"
}
},
{
"type": "REPEAT",
@ -1784,9 +1940,13 @@
}
},
{
"type": "FIELD",
"name": "quoted_end",
"content": {
"type": "STRING",
"value": "/"
}
}
]
},
"string": {

View File

@ -1388,7 +1388,36 @@
{
"type": "charlist",
"named": true,
"fields": {},
"fields": {
"quoted_end": {
"multiple": false,
"required": true,
"types": [
{
"type": "'",
"named": false
},
{
"type": "'''",
"named": false
}
]
},
"quoted_start": {
"multiple": false,
"required": true,
"types": [
{
"type": "'",
"named": false
},
{
"type": "'''",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": false,
@ -2333,7 +2362,36 @@
{
"type": "quoted_atom",
"named": true,
"fields": {},
"fields": {
"quoted_end": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "'",
"named": false
}
]
},
"quoted_start": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "'",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": false,
@ -2356,7 +2414,36 @@
{
"type": "quoted_keyword",
"named": true,
"fields": {},
"fields": {
"quoted_end": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "'",
"named": false
}
]
},
"quoted_start": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "'",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": false,
@ -2494,7 +2581,100 @@
{
"type": "sigil",
"named": true,
"fields": {},
"fields": {
"quoted_end": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "\"\"\"",
"named": false
},
{
"type": "'",
"named": false
},
{
"type": "'''",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": "/",
"named": false
},
{
"type": ">",
"named": false
},
{
"type": "]",
"named": false
},
{
"type": "|",
"named": false
},
{
"type": "}",
"named": false
}
]
},
"quoted_start": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "\"\"\"",
"named": false
},
{
"type": "'",
"named": false
},
{
"type": "'''",
"named": false
},
{
"type": "(",
"named": false
},
{
"type": "/",
"named": false
},
{
"type": "<",
"named": false
},
{
"type": "[",
"named": false
},
{
"type": "{",
"named": false
},
{
"type": "|",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": true,
@ -2681,7 +2861,36 @@
{
"type": "string",
"named": true,
"fields": {},
"fields": {
"quoted_end": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "\"\"\"",
"named": false
}
]
},
"quoted_start": {
"multiple": false,
"required": true,
"types": [
{
"type": "\"",
"named": false
},
{
"type": "\"\"\"",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": false,

579497
src/parser.c

File diff suppressed because it is too large Load Diff