diff --git a/src/pp/merge_blank.rs b/src/pp/merge_blank.rs index aad4242..fe0fdc5 100644 --- a/src/pp/merge_blank.rs +++ b/src/pp/merge_blank.rs @@ -46,8 +46,6 @@ pub fn pp_merge_blank(seq: &str) -> String { #[test] fn test_part1() { - use crate::pp::merge_blank::pp_merge_blank; - let seq = " \n \r \t "; assert_eq!(pp_merge_blank(seq), " "); diff --git a/src/pp/mod.rs b/src/pp/mod.rs index 317d1f7..0e19551 100644 --- a/src/pp/mod.rs +++ b/src/pp/mod.rs @@ -1,10 +1,10 @@ -use crate::pp::comment::pp_comment; -use crate::pp::merge_blank::pp_merge_blank; - -mod comment; mod merge_blank; +mod rm_comment; + +pub use merge_blank::pp_merge_blank as merge_blank; +pub use rm_comment::pp_rm_comment as rm_comment; pub fn preprocess(seq: &str) -> String { - let r = pp_comment(seq); - pp_merge_blank(&r) + let r = rm_comment(seq); + merge_blank(&r) } diff --git a/src/pp/comment.rs b/src/pp/rm_comment.rs similarity index 94% rename from src/pp/comment.rs rename to src/pp/rm_comment.rs index 39973db..c6e2722 100644 --- a/src/pp/comment.rs +++ b/src/pp/rm_comment.rs @@ -1,8 +1,8 @@ use crate::infra::either::Either; use crate::infra::iter::IteratorExt; use crate::infra::vec::VecExt; -use crate::pp::comment::Either::*; -use crate::pp::comment::Pat::*; +use crate::pp::rm_comment::Either::*; +use crate::pp::rm_comment::Pat::*; #[derive(Clone)] enum Pat { @@ -53,7 +53,7 @@ fn go( go(reduced_stack, tail.as_str()) } -pub fn pp_comment(seq: &str) -> String { +pub fn pp_rm_comment(seq: &str) -> String { let r = go(vec![], seq) .into_iter() .fold(vec![], |acc, p| match p { @@ -74,7 +74,7 @@ pub fn pp_comment(seq: &str) -> String { #[test] fn test_part1() { - use crate::pp::comment::pp_comment; + use crate::pp::rm_comment; let seq = "match x with# Comment 123# Comment 123 \ | 1 -> if a then b else c\ @@ -123,12 +123,12 @@ fn test_part1() { )\ | _ -> baz"; - assert_eq!(pp_comment(seq), r); + assert_eq!(rm_comment(seq), r); } #[test] fn test_part2() { - use crate::pp::comment::pp_comment; + use crate::pp::rm_comment; let seq = "# Comment 123# Comment 123 \ @@ -167,5 +167,5 @@ fn test_part2() { let m = (), n = 4 in \ add () 456"; - assert_eq!(pp_comment(seq), r); + assert_eq!(rm_comment(seq), r); }