diff --git a/parser/src/parsing/common.rs b/parser/src/parsing/common.rs index 3c9a585..9d9aef6 100644 --- a/parser/src/parsing/common.rs +++ b/parser/src/parsing/common.rs @@ -17,7 +17,10 @@ pub fn parse_identifier(input: &str) -> IResult<&str, &str> { let (_, first) = peek(anychar)(input)?; if first.is_alphabetic() || first == '_' { take_while(|c: char| { - is_alphanumeric(c as u8) || c == '_' + match c { + 'a'..='z' | 'A'..='Z' | '_' | '0'..='9' => true, + _ => false + } })(input) } else { Err(nom::Err::Error(make_error( diff --git a/server/src/config.rs b/server/src/config.rs index 2f15935..efdb3c4 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -18,6 +18,8 @@ pub struct Configuration { port: u16, #[arg(short, long, help = "Path to the data file")] file: PathBuf, + #[arg(short, long, help = "Delay between rows in milliseconds")] + throttle: Option, } impl Configuration { @@ -30,4 +32,9 @@ impl Configuration { pub fn get_file_path(&self) -> &PathBuf { &self.file } + + #[inline] + pub fn get_throttle(&self) -> Option { + self.throttle + } } diff --git a/server/src/main.rs b/server/src/main.rs index e54677e..74d35e4 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -223,6 +223,10 @@ where token.reset(); break; } + if let Some(throttle) = config.get_throttle() { + writer.flush().await?; + tokio::time::sleep(tokio::time::Duration::from_millis(throttle)).await; + } } writer