Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger: Fix command parsing on the debugger prompt #1074

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading