Fix quoted string parsing for commands
This commit is contained in:
parent
70ad08128c
commit
9a65afa083
@ -17,7 +17,14 @@ impl AbstractTree for Command {
|
||||
|
||||
for index in 1..node.child_count() {
|
||||
let text_node = node.child(index).unwrap();
|
||||
let text = source[text_node.byte_range()].to_string();
|
||||
let mut text = source[text_node.byte_range()].to_string();
|
||||
|
||||
if (text.starts_with('\'') && text.ends_with('\''))
|
||||
|| (text.starts_with('"') && text.ends_with('"'))
|
||||
|| (text.starts_with('`') && text.ends_with('`'))
|
||||
{
|
||||
text = text[1..text.len() - 1].to_string();
|
||||
}
|
||||
|
||||
command_texts.push(text);
|
||||
}
|
||||
|
@ -90,7 +90,11 @@ module.exports = grammar({
|
||||
),
|
||||
),
|
||||
|
||||
command_text: $ => /\S+/,
|
||||
command_text: $ =>
|
||||
choice(
|
||||
/\S+/,
|
||||
/("[^"]*?")|('[^']*?')|(`[^`]*?`)/,
|
||||
),
|
||||
|
||||
block: $ =>
|
||||
seq(
|
||||
|
@ -246,9 +246,18 @@
|
||||
}
|
||||
},
|
||||
"command_text": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\S+"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "(\"[^\"]*?\")|('[^']*?')|(`[^`]*?`)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"block": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
@ -71,6 +71,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "command_text",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "else",
|
||||
"named": true,
|
||||
@ -621,6 +626,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "structure",
|
||||
"named": true,
|
||||
@ -899,10 +909,6 @@
|
||||
"type": "collection",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "command_text",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "else",
|
||||
"named": false
|
||||
@ -1011,10 +1017,6 @@
|
||||
"type": "string",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "struct",
|
||||
"named": false
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user