parser : gestion plus précise des simple quotes
This commit is contained in:
parent
7d319335fe
commit
e2a850cfbb
1 changed files with 9 additions and 15 deletions
|
@ -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 quoted = String::default();
|
||||
let mut current_char = characters.pop().unwrap();
|
||||
|
||||
while !characters.is_empty() && current_char != '\'' {
|
||||
quoted_arg.push(current_char);
|
||||
quoted.push(current_char);
|
||||
current_char = characters.pop().unwrap();
|
||||
}
|
||||
|
||||
quoted_arg
|
||||
}
|
||||
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![];
|
||||
|
||||
|
|
Loading…
Reference in a new issue