parser : gestion plus précise des simple quotes

This commit is contained in:
Ahurac 2024-04-15 12:06:23 +02:00
parent 7d319335fe
commit e2a850cfbb

View file

@ -2,19 +2,15 @@ use crate::command::command_builder::CommandBuilder;
use crate::command::command_sequence::CommandSequence;
fn parse_quote(characters: &mut Vec<char>) -> String {
if characters.is_empty() {
String::default()
} else {
let mut quoted_arg = String::default();
let mut current_char = characters.pop().unwrap();
let mut quoted = String::default();
let mut current_char = characters.pop().unwrap();
while !characters.is_empty() && current_char != '\'' {
quoted_arg.push(current_char);
current_char = characters.pop().unwrap();
}
quoted_arg
while !characters.is_empty() && current_char != '\'' {
quoted.push(current_char);
current_char = characters.pop().unwrap();
}
quoted
}
fn parse_main(characters: &mut Vec<char>, current_arg: &mut String) -> Vec<String> {
@ -38,10 +34,8 @@ fn parse_main(characters: &mut Vec<char>, current_arg: &mut String) -> Vec<Strin
parse_main(characters, current_arg)
*/
} else if current_char == '\'' {
let mut argv = vec![parse_quote(characters)];
argv.append(&mut parse_main(characters, &mut String::default()));
argv
current_arg.push_str(parse_quote(characters).as_str());
parse_main(characters, current_arg)
} else if current_char == ';' {
let mut argv: Vec<String> = vec![];