Skip to content

Commit

Permalink
pub use pp mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Nov 18, 2023
1 parent 50d7cd7 commit 8e1012f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/pp/merge_blank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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), " ");

Expand Down
12 changes: 6 additions & 6 deletions src/pp/mod.rs
Original file line number Diff line number Diff line change
@@ -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)
}
14 changes: 7 additions & 7 deletions src/pp/comment.rs → src/pp/rm_comment.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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\
Expand Down Expand Up @@ -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
\
Expand Down Expand Up @@ -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);
}

0 comments on commit 8e1012f

Please sign in to comment.