Skip to content

Commit

Permalink
Debugger: Fix command parsing on the debugger prompt (#1074)
Browse files Browse the repository at this point in the history
* Fix debugger parser

* Forgot to change to command for one line
  • Loading branch information
zaddach authored Jan 31, 2025
1 parent 4240479 commit 8ea0c31
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions debugger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,51 +130,52 @@ impl Cli {
}

fn execute_command(&mut self, command: &str) -> Result<(), DebuggerError> {
match command {
let verb = command.split(&[' ', '\t']).next().unwrap().trim();
match verb {
"" => (),
help if "help".starts_with(help) => Cli::help(),
list if "list".starts_with(list) => self.list(),
cont if "continue".starts_with(cont) => self.cont()?,
"ba" => self.context.add_all_rules_breakpoints()?,
"da" => self.context.delete_all_breakpoints(),
grammar if "grammar".starts_with(grammar) => {
let grammar_file = Self::extract_arg(grammar);
let grammar_file = Self::extract_arg(command);
if let Some(grammar_file) = grammar_file {
self.grammar(PathBuf::from(grammar_file))?;
} else {
println!("expected filename, usage: g(grammar) <filename>");
}
}
input if "input".starts_with(input) => {
let input_file = Self::extract_arg(input);
let input_file = Self::extract_arg(command);
if let Some(input_file) = input_file {
self.input(PathBuf::from(input_file))?;
} else {
println!("expected filename, usage: i(input) <filename>");
}
}
x if x.starts_with("id ") => {
let input = &x[3..];
let input = &command[3..];
self.context.load_input_direct(input.to_owned());
}
breakpoint if "breakpoint".starts_with(breakpoint) => {
let rule = Self::extract_arg(breakpoint);
let rule = Self::extract_arg(command);
if let Some(rule) = rule {
self.breakpoint(rule);
} else {
println!("expected rule, usage: b(breakpoint) <rule>");
}
}
delete if "delete".starts_with(delete) => {
let rule = Self::extract_arg(delete);
let rule = Self::extract_arg(command);
if let Some(rule) = rule {
self.context.delete_breakpoint(rule);
} else {
println!("expected rule, usage: d(delete) <rule>");
}
}
run if "run".starts_with(run) => {
let rule = Self::extract_arg(run);
let rule = Self::extract_arg(command);
if let Some(rule) = rule {
self.run(rule)?;
} else {
Expand Down

0 comments on commit 8ea0c31

Please sign in to comment.