Trimming down files

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
Hanif Bin Ariffin 2021-07-21 23:05:11 +08:00
parent 55b2eacb4b
commit 5def69d3ee
3 changed files with 19 additions and 22 deletions

View file

@ -1,4 +1,3 @@
use crate::unicode_table;
use nom::{ use nom::{
branch::alt, branch::alt,
bytes::complete::tag, bytes::complete::tag,
@ -14,15 +13,18 @@ use std::{
io::{BufRead, Write}, io::{BufRead, Write},
}; };
static SPACES: &'static [char] = &[ mod unicode_table {
unicode_table::HT, pub static BEL: char = '\u{0007}';
unicode_table::LF, pub static BS: char = '\u{0008}';
unicode_table::VT, pub static HT: char = '\u{0009}';
unicode_table::FF, pub static LF: char = '\u{000A}';
unicode_table::CR, pub static VT: char = '\u{000B}';
unicode_table::SPACE, pub static FF: char = '\u{000C}';
]; pub static CR: char = '\u{000D}';
static BLANK: &'static [char] = &[unicode_table::SPACE, unicode_table::HT]; pub static SPACE: char = '\u{0020}';
pub static SPACES: &'static [char] = &[HT, LF, VT, FF, CR, SPACE];
pub static BLANK: &'static [char] = &[SPACE, HT];
}
pub enum Sequence { pub enum Sequence {
Char(char), Char(char),
@ -214,8 +216,12 @@ impl Sequence {
} }
fn parse_blank(input: &str) -> IResult<&str, Sequence> { fn parse_blank(input: &str) -> IResult<&str, Sequence> {
tag("[:blank:]")(input) tag("[:blank:]")(input).map(|(l, _)| {
.map(|(l, _)| (l, Sequence::CharRange(Box::new(BLANK.into_iter().cloned())))) (
l,
Sequence::CharRange(Box::new(unicode_table::BLANK.into_iter().cloned())),
)
})
} }
fn parse_control(input: &str) -> IResult<&str, Sequence> { fn parse_control(input: &str) -> IResult<&str, Sequence> {
@ -297,7 +303,7 @@ impl Sequence {
tag("[:space:]")(input).map(|(l, _)| { tag("[:space:]")(input).map(|(l, _)| {
( (
l, l,
Sequence::CharRange(Box::new(SPACES.into_iter().cloned())), Sequence::CharRange(Box::new(unicode_table::SPACES.into_iter().cloned())),
) )
}) })
} }

View file

@ -15,7 +15,6 @@ extern crate uucore;
extern crate nom; extern crate nom;
mod operation; mod operation;
mod unicode_table;
use clap::{crate_version, App, Arg}; use clap::{crate_version, App, Arg};
use nom::AsBytes; use nom::AsBytes;

View file

@ -1,8 +0,0 @@
pub static BEL: char = '\u{0007}';
pub static BS: char = '\u{0008}';
pub static HT: char = '\u{0009}';
pub static LF: char = '\u{000A}';
pub static VT: char = '\u{000B}';
pub static FF: char = '\u{000C}';
pub static CR: char = '\u{000D}';
pub static SPACE: char = '\u{0020}';