pub struct DebuggerContext { /* private fields */ }
Expand description
Debugger for pest grammars.
Implementations§
Source§impl DebuggerContext
impl DebuggerContext
Sourcepub fn load_grammar(
&mut self,
path: impl AsRef<Path>,
) -> Result<(), DebuggerError>
pub fn load_grammar( &mut self, path: impl AsRef<Path>, ) -> Result<(), DebuggerError>
Loads a grammar from a file.
Sourcepub fn load_grammar_direct(
&mut self,
grammar_name: &str,
grammar: &str,
) -> Result<(), DebuggerError>
pub fn load_grammar_direct( &mut self, grammar_name: &str, grammar: &str, ) -> Result<(), DebuggerError>
Loads a grammar from a string.
Sourcepub fn load_input(
&mut self,
path: impl AsRef<Path>,
) -> Result<(), DebuggerError>
pub fn load_input( &mut self, path: impl AsRef<Path>, ) -> Result<(), DebuggerError>
Loads a parsing input from a file.
Sourcepub fn load_input_direct(&mut self, input: String)
pub fn load_input_direct(&mut self, input: String)
Loads a parsing input from a string.
Sourcepub fn add_all_rules_breakpoints(&mut self) -> Result<(), DebuggerError>
pub fn add_all_rules_breakpoints(&mut self) -> Result<(), DebuggerError>
Adds all grammar rules as breakpoints. This is useful for stepping through the entire parsing process. It returns an error if the grammar hasn’t been loaded yet.
Sourcepub fn add_breakpoint(&mut self, rule: String)
pub fn add_breakpoint(&mut self, rule: String)
Adds a rule to breakpoints.
Sourcepub fn delete_breakpoint(&mut self, rule: &str)
pub fn delete_breakpoint(&mut self, rule: &str)
Removes a rule from breakpoints.
Sourcepub fn delete_all_breakpoints(&mut self)
pub fn delete_all_breakpoints(&mut self)
Removes all breakpoints.
Sourcepub fn list_breakpoints(&self) -> Vec<String>
pub fn list_breakpoints(&self) -> Vec<String>
Returns a list of all breakpoints.
Sourcepub fn run(
&mut self,
rule: &str,
sender: Sender<DebuggerEvent>,
) -> Result<(), DebuggerError>
pub fn run( &mut self, rule: &str, sender: Sender<DebuggerEvent>, ) -> Result<(), DebuggerError>
Starts a debugger session: runs a rule on an input and stops at breakpoints.
When the debugger is stopped, an event is sent to the channel using sender
.
The debugger can be resumed by calling cont
.
This naturally returns errors if the grammar or input haven’t been loaded yet etc.
Sourcepub fn cont(&self) -> Result<(), DebuggerError>
pub fn cont(&self) -> Result<(), DebuggerError>
Continue the debugger session from the breakpoint. It returns an error if the session finished or wasn’t started yet.
Sourcepub fn get_position(&self, pos: usize) -> Result<Position<'_>, DebuggerError>
pub fn get_position(&self, pos: usize) -> Result<Position<'_>, DebuggerError>
Returns a Position
from the loaded input.