Add debugging helpers.
This commit is contained in:
parent
319b288e60
commit
19bd49865f
3 changed files with 10 additions and 2 deletions
|
@ -16,6 +16,7 @@ struct EventSink {
|
|||
|
||||
impl MarkedEventReceiver for EventSink {
|
||||
fn on_event(&mut self, ev: Event, mark: Marker) {
|
||||
eprintln!(" \x1B[;34m\u{21B3} {:?}\x1B[;m", &ev);
|
||||
self.events.push((ev, mark));
|
||||
}
|
||||
}
|
||||
|
@ -34,5 +35,6 @@ fn main() {
|
|||
let mut s = String::new();
|
||||
f.read_to_string(&mut s).unwrap();
|
||||
|
||||
dbg!(str_to_events(&s));
|
||||
// dbg!(str_to_events(&s));
|
||||
str_to_events(&s);
|
||||
}
|
||||
|
|
|
@ -244,6 +244,12 @@ impl<T: Iterator<Item = char>> Iterator for Scanner<T> {
|
|||
return None;
|
||||
}
|
||||
match self.next_token() {
|
||||
Ok(Some(tok)) => {
|
||||
if std::env::var("YAMLRUST_DEBUG").is_ok() {
|
||||
eprintln!("\x1B[;32m{:?} \x1B[;36m{:?}\x1B[;m", tok.1, tok.0);
|
||||
}
|
||||
Some(tok)
|
||||
}
|
||||
Ok(tok) => tok,
|
||||
Err(e) => {
|
||||
self.error = Some(e);
|
||||
|
|
|
@ -59,7 +59,7 @@ macro_rules! assert_next {
|
|||
match $v.next().unwrap() {
|
||||
$p => {}
|
||||
e => {
|
||||
panic!("unexpected event: {:?}", e);
|
||||
panic!("unexpected event: {:?} (expected {:?})", e, stringify!($p));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue