Make lexeme and token logging more concise

This commit is contained in:
Juno Takano 2026-01-05 04:18:21 -03:00
commit 735b58866c
15 changed files with 229 additions and 20 deletions

View file

@ -1,3 +1,5 @@
use std::fmt;
use crate::{prelude::*, syntax::content::parser::segment::delimiter::Delimiters};
#[derive(Clone, Debug)]
@ -154,6 +156,19 @@ impl Lexeme {
}
}
impl fmt::Display for Lexeme {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use crate::dev::wrap;
let next_display = if self.last() {
" <EOI>"
} else {
&format!("-> {}", wrap(&self.next))
};
write!(f, "{} {}", wrap(&self.text), next_display)
}
}
#[cfg(test)]
mod tests {
use super::*;