Skip to content

Commit

Permalink
Fix debugger parser
Browse files Browse the repository at this point in the history
  • Loading branch information
zaddach committed Jan 30, 2025
1 parent 24d0d9c commit aae887d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions debugger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,24 @@ 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 {
Expand All @@ -158,23 +159,23 @@ impl Cli {
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 aae887d

Please sign in to comment.