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

View File

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

View File

@ -1388,7 +1388,36 @@
{ {
"type": "charlist", "type": "charlist",
"named": true, "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": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": false,
@ -2333,7 +2362,36 @@
{ {
"type": "quoted_atom", "type": "quoted_atom",
"named": true, "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": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": false,
@ -2356,7 +2414,36 @@
{ {
"type": "quoted_keyword", "type": "quoted_keyword",
"named": true, "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": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": false,
@ -2494,7 +2581,100 @@
{ {
"type": "sigil", "type": "sigil",
"named": true, "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": { "children": {
"multiple": true, "multiple": true,
"required": true, "required": true,
@ -2681,7 +2861,36 @@
{ {
"type": "string", "type": "string",
"named": true, "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": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": false,

579497
src/parser.c

File diff suppressed because it is too large Load Diff