add breakpoints on !
This commit is contained in:
parent
6b4b49142d
commit
91f3d32b2b
1 changed files with 6 additions and 1 deletions
|
@ -29,6 +29,7 @@ enum State {
|
||||||
TooFarLeft,
|
TooFarLeft,
|
||||||
EndOfProgram,
|
EndOfProgram,
|
||||||
StoppedOnMemoryValue,
|
StoppedOnMemoryValue,
|
||||||
|
BreakPointHit,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -48,6 +49,7 @@ enum Command {
|
||||||
Write,
|
Write,
|
||||||
BeginLoop(usize),
|
BeginLoop(usize),
|
||||||
EndLoop(usize),
|
EndLoop(usize),
|
||||||
|
Break,
|
||||||
End,
|
End,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +231,7 @@ impl BFInterpreter {
|
||||||
self.program_ptr = start_of_loop;
|
self.program_ptr = start_of_loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Command::Break => self.state = State::BreakPointHit,
|
||||||
Command::End => (),
|
Command::End => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +278,7 @@ fn parse(source_text: &str) -> Vec<DebugCommand> {
|
||||||
|
|
||||||
Command::EndLoop(last_loop_start)
|
Command::EndLoop(last_loop_start)
|
||||||
}
|
}
|
||||||
|
'!' => Command::Break,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
out.push(DebugCommand {
|
out.push(DebugCommand {
|
||||||
|
@ -314,7 +318,8 @@ impl Display for Command {
|
||||||
Command::Write => '.',
|
Command::Write => '.',
|
||||||
Command::BeginLoop(_) => '[',
|
Command::BeginLoop(_) => '[',
|
||||||
Command::EndLoop(_) => ']',
|
Command::EndLoop(_) => ']',
|
||||||
Command::End => '_',
|
Command::Break => '!',
|
||||||
|
Command::End => ' ',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue