Improve Parser debugging display

This commit is contained in:
Shunsuke Shibayama 2022-08-19 12:32:40 +09:00
parent 7c27021e16
commit cafc941b10
2 changed files with 366 additions and 141 deletions

View file

@ -260,13 +260,13 @@ macro_rules! debug_enum_assert {
#[macro_export] #[macro_export]
macro_rules! log { macro_rules! log {
(f $output: ident, $($arg: tt)*) => { (f $output: ident, $($arg: tt)*) => {
if cfg!(feature = "debug") { write!($output, "{}:{}: ", file!(), line!()).unwrap(); if cfg!(feature = "debug") { write!($output, "{}:{:4}: ", file!(), line!()).unwrap();
write!($output, $($arg)*).unwrap(); write!($output, $($arg)*).unwrap();
$output.flush().unwrap(); $output.flush().unwrap();
} }
}; };
($($arg: tt)*) => { ($($arg: tt)*) => {
if cfg!(feature = "debug") { print!("{}:{}: ", file!(), line!()); println!($($arg)*); } if cfg!(feature = "debug") { print!("{}:{:4}: ", file!(), line!()); println!($($arg)*); }
}; };
} }
@ -290,13 +290,13 @@ macro_rules! log_with_time {
#[macro_export] #[macro_export]
macro_rules! fmt_dbg { macro_rules! fmt_dbg {
($arg: expr $(,)*) => { ($arg: expr $(,)*) => {
if cfg!(feature = "debug") { print!("{}:{}:\n", file!(), line!()); if cfg!(feature = "debug") { print!("{}:{:4}:\n", file!(), line!());
print!("{} = ", stringify!($arg)); print!("{} = ", stringify!($arg));
println!("{}", $arg); println!("{}", $arg);
} }
}; };
($head: expr, $($arg: expr,)+) => { ($head: expr, $($arg: expr,)+) => {
if cfg!(feature = "debug") { print!("{}:{}:\n", file!(), line!()); if cfg!(feature = "debug") { print!("{}:{:4}:\n", file!(), line!());
print!("{} = ", stringify!($head)); print!("{} = ", stringify!($head));
println!("{}", $head); println!("{}", $head);
$crate::fmt_dbg!(rec $($arg,)+); $crate::fmt_dbg!(rec $($arg,)+);

File diff suppressed because it is too large Load diff