build: remove regex dependency in favor of rust iterators

This commit is contained in:
Chance 2025-04-07 22:11:38 -04:00 committed by BitSyndicate
parent ada0c9ae1e
commit af718fbbe6
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 443E4198D6BBA6DE
5 changed files with 90 additions and 75 deletions

View file

@ -1,7 +1,6 @@
use std::{fs, path::PathBuf, str::FromStr};
use parking_lot::RwLock;
use regex::Regex;
use super::{handler::Command, input::tokenize};
use crate::core::repl::handler::COMMAND_MANAGER;
@ -286,14 +285,7 @@ fn eval(input: String) -> Result<Vec<(String, Option<Vec<String>>)>, ZenyxError>
.with_message("Input was empty")
.build());
}
let pattern = Regex::new(r"[;|\n]").map_err(|e| {
ZenyxError::builder(ZenyxErrorKind::CommandParsing)
.with_message("Failed to compile regex")
.with_source(e)
.build()
})?;
let commands: Vec<&str> = pattern.split(&input).collect();
let commands: Vec<&str> = input.split(|c| c == ';' || c == '\n').collect();
let mut evaluted = vec![];
for command in commands {

View file

@ -6,7 +6,6 @@ use std::{
use chrono::Local;
use colored::Colorize;
use parking_lot::Mutex;
use regex::Regex;
use rustyline::{
Cmd, Completer, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, Helper,
Hinter, KeyEvent, RepeatCount, Validator, completion::Completer, error::ReadlineError,
@ -131,12 +130,10 @@ pub fn tokenize(command: &str) -> Vec<String> {
}
pub fn parse_command(input: &str) -> Result<Vec<String>> {
let pattern = Regex::new(r"[;|\n]").map_err(|_| {
ZenyxError::builder(ZenyxErrorKind::CommandParsing)
.with_message("Failed to compile regex pattern")
.build()
})?;
let commands: Vec<String> = pattern.split(input).map(String::from).collect();
let commands = input
.split(|c| c == ';' || c == '\n')
.map(|slice| slice.to_string())
.collect::<Vec<String>>();
Ok(commands)
}
@ -145,12 +142,10 @@ pub fn evaluate_command(input: &str) -> Result<()> {
return Ok(());
}
let pattern = Regex::new(r"[;|\n]").map_err(|_| {
ZenyxError::builder(ZenyxErrorKind::CommandParsing)
.with_message("Failed to compile regex pattern")
.build()
})?;
let commands: Vec<&str> = pattern.split(input).collect();
let commands = input
.split(|c| c == ';' || c == '\n')
.map(|slice| slice.to_string())
.collect::<Vec<String>>();
for command in commands {
let command = command.trim();