From 862d81a9d45d5bd8e4b30b35c439a4402a4244de Mon Sep 17 00:00:00 2001 From: John Date: Wed, 28 Feb 2024 05:32:10 -0600 Subject: [PATCH] cl-repl: Rename from cl-frontend. Also disable escape code printing when debug assertions are off --- Cargo.toml | 2 +- {cl-frontend => cl-repl}/Cargo.toml | 2 +- {cl-frontend => cl-repl}/examples/collect-identifiers.rs | 2 +- {cl-frontend => cl-repl}/examples/identify_tokens.rs | 0 {cl-frontend => cl-repl}/src/lib.rs | 0 {cl-frontend => cl-repl}/src/main.rs | 2 +- {cl-frontend => cl-repl}/src/repline.rs | 8 ++++++-- 7 files changed, 10 insertions(+), 6 deletions(-) rename {cl-frontend => cl-repl}/Cargo.toml (94%) rename {cl-frontend => cl-repl}/examples/collect-identifiers.rs (99%) rename {cl-frontend => cl-repl}/examples/identify_tokens.rs (100%) rename {cl-frontend => cl-repl}/src/lib.rs (100%) rename {cl-frontend => cl-repl}/src/main.rs (75%) rename {cl-frontend => cl-repl}/src/repline.rs (98%) diff --git a/Cargo.toml b/Cargo.toml index 2e6a538..6dc37cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["libconlang", "cl-frontend"] +members = ["libconlang", "cl-repl"] resolver = "2" [workspace.package] diff --git a/cl-frontend/Cargo.toml b/cl-repl/Cargo.toml similarity index 94% rename from cl-frontend/Cargo.toml rename to cl-repl/Cargo.toml index bac1e19..6358b94 100644 --- a/cl-frontend/Cargo.toml +++ b/cl-repl/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cl-frontend" +name = "cl-repl" repository.workspace = true version.workspace = true authors.workspace = true diff --git a/cl-frontend/examples/collect-identifiers.rs b/cl-repl/examples/collect-identifiers.rs similarity index 99% rename from cl-frontend/examples/collect-identifiers.rs rename to cl-repl/examples/collect-identifiers.rs index 55dc8af..a6158ca 100644 --- a/cl-frontend/examples/collect-identifiers.rs +++ b/cl-repl/examples/collect-identifiers.rs @@ -1,6 +1,6 @@ //! Collects identifiers into a list -use cl_frontend::repline::Repline; +use cl_repl::repline::Repline; use conlang::{common::Loc, lexer::Lexer, parser::Parser}; use std::{ collections::HashMap, diff --git a/cl-frontend/examples/identify_tokens.rs b/cl-repl/examples/identify_tokens.rs similarity index 100% rename from cl-frontend/examples/identify_tokens.rs rename to cl-repl/examples/identify_tokens.rs diff --git a/cl-frontend/src/lib.rs b/cl-repl/src/lib.rs similarity index 100% rename from cl-frontend/src/lib.rs rename to cl-repl/src/lib.rs diff --git a/cl-frontend/src/main.rs b/cl-repl/src/main.rs similarity index 75% rename from cl-frontend/src/main.rs rename to cl-repl/src/main.rs index ec50ac4..2dfb6cd 100644 --- a/cl-frontend/src/main.rs +++ b/cl-repl/src/main.rs @@ -1,4 +1,4 @@ -use cl_frontend::{args::Args, cli::CLI}; +use cl_repl::{args::Args, cli::CLI}; use std::error::Error; fn main() -> Result<(), Box> { diff --git a/cl-frontend/src/repline.rs b/cl-repl/src/repline.rs similarity index 98% rename from cl-frontend/src/repline.rs rename to cl-repl/src/repline.rs index 87130fd..18f05b4 100644 --- a/cl-frontend/src/repline.rs +++ b/cl-repl/src/repline.rs @@ -255,7 +255,9 @@ impl<'a, R: Read> Repline<'a, R> { } } c if c.is_ascii_control() => { - eprint!("\\x{:02x}", c as u32); + if cfg!(debug_assertions) { + eprint!("\\x{:02x}", c as u32); + } } c => { self.ed.push(c, stdout)?; @@ -296,7 +298,9 @@ impl<'a, R: Read> Repline<'a, R> { } } other => { - eprint!("{}", other.escape_unicode()); + if cfg!(debug_assertions) { + eprint!("{}", other.escape_unicode()); + } } } Ok(())