ast: formatting; main: explicit verbosity

This commit is contained in:
2025-10-17 06:57:21 -04:00
parent f05d480b35
commit db9c75b3c6
3 changed files with 11 additions and 6 deletions

View File

@@ -205,7 +205,10 @@ fn subst() -> Result<(), Box<dyn Error>> {
fn parse(document: &str) {
let mut parser = Parser::new(Lexer::new(document));
let isatty = std::io::stdin().is_terminal();
let verbose = !matches!(
std::env::var("DOUGHLANG_VERBOSE").as_deref(),
Ok("false" | "0" | "no")
);
for idx in 0.. {
match parser.parse::<Expr>(0) {
Err(e @ ParseError::EOF(s)) if s.tail == document.len() as _ => {
@@ -220,7 +223,7 @@ fn parse(document: &str) {
println!("\x1b[91m{e}\x1b[0m");
break;
}
Ok(v) if isatty => {
Ok(v) if verbose => {
println!("\x1b[{}m{v}", (idx + 5) % 6 + 31);
}
_ => {}