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;
|
use crate::command::command_sequence::CommandSequence;
|
||||||
|
|
||||||
fn parse_quote(characters: &mut Vec<char>) -> String {
|
fn parse_quote(characters: &mut Vec<char>) -> String {
|
||||||
if characters.is_empty() {
|
let mut quoted = String::default();
|
||||||
String::default()
|
let mut current_char = characters.pop().unwrap();
|
||||||
} else {
|
|
||||||
let mut quoted_arg = String::default();
|
|
||||||
let mut current_char = characters.pop().unwrap();
|
|
||||||
|
|
||||||
while !characters.is_empty() && current_char != '\'' {
|
while !characters.is_empty() && current_char != '\'' {
|
||||||
quoted_arg.push(current_char);
|
quoted.push(current_char);
|
||||||
current_char = characters.pop().unwrap();
|
current_char = characters.pop().unwrap();
|
||||||
}
|
|
||||||
|
|
||||||
quoted_arg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quoted
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_main(characters: &mut Vec<char>, current_arg: &mut String) -> Vec<String> {
|
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)
|
parse_main(characters, current_arg)
|
||||||
*/
|
*/
|
||||||
} else if current_char == '\'' {
|
} else if current_char == '\'' {
|
||||||
let mut argv = vec![parse_quote(characters)];
|
current_arg.push_str(parse_quote(characters).as_str());
|
||||||
argv.append(&mut parse_main(characters, &mut String::default()));
|
parse_main(characters, current_arg)
|
||||||
|
|
||||||
argv
|
|
||||||
} else if current_char == ';' {
|
} else if current_char == ';' {
|
||||||
let mut argv: Vec<String> = vec![];
|
let mut argv: Vec<String> = vec![];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue