Struct pest_debugger::DebuggerContext
source · pub struct DebuggerContext { /* private fields */ }
Expand description
Debugger for pest grammars.
Implementations§
source§impl DebuggerContext
impl DebuggerContext
sourcepub fn load_grammar(&mut self, path: &PathBuf) -> Result<(), DebuggerError>
pub fn load_grammar(&mut self, path: &PathBuf) -> 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: &PathBuf) -> Result<(), DebuggerError>
pub fn load_input(&mut self, path: &PathBuf) -> 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.