From 2c5555808a5c2f9fa257480fef37b0414996bb6c Mon Sep 17 00:00:00 2001 From: AsianIntel Date: Mon, 4 Nov 2024 21:17:30 -0800 Subject: [PATCH] fix update xp statements, allow any characters in a string for custombinds --- Cargo.lock | 2 +- rowifi_core/src/custombinds/parser.rs | 41 ++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b14ea99..a128cfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1744,7 +1744,7 @@ dependencies = [ [[package]] name = "rowifi_tower" version = "4.0.0" -source = "git+https://github.com/RoWifi-HQ/rowifi_extras?branch=main#cf9810fc91f0ccc3a927623669c9e555b6e1d1a0" +source = "git+https://github.com/RoWifi-HQ/rowifi_extras?branch=main#403b08d23727a0aa87a35e29e251a01380c85f9f" dependencies = [ "axum", "bytes", diff --git a/rowifi_core/src/custombinds/parser.rs b/rowifi_core/src/custombinds/parser.rs index 43275a2..6f7c66a 100644 --- a/rowifi_core/src/custombinds/parser.rs +++ b/rowifi_core/src/custombinds/parser.rs @@ -1,10 +1,10 @@ use nom::{ branch::alt, bytes::complete::tag, - character::complete::{alpha1, alphanumeric1, char, digit1, multispace0, multispace1}, + character::complete::{alphanumeric1, anychar, char, digit1, multispace0, multispace1}, combinator::{all_consuming, map, map_res}, error::VerboseError, - multi::separated_list0, + multi::{many1, separated_list0}, sequence::{delimited, pair, preceded, tuple}, Err, IResult, Parser, }; @@ -66,8 +66,8 @@ fn parse_number(i: &str) -> IResult<&str, Atom, VerboseError<&str>> { } fn parse_string(i: &str) -> IResult<&str, Atom, VerboseError<&str>> { - map(delimited(char('"'), alpha1, char('"')), |s: &str| { - Atom::String(s.to_string()) + map(delimited(char('"'), many1(anychar), char('"')), |s| { + Atom::String(s.into_iter().collect()) }) .parse(i) } @@ -343,27 +343,36 @@ mod tests { assert_eq!( parser("(GetRank(1000) >= 200 and GetRank(1000) <= 253) and not (GetRank(2000) >= 10)"), Ok(Expression::Operation( - Operator::And, + Operator::And, Box::new(Expression::Operation( - Operator::And, + Operator::And, Box::new(Expression::Operation( - Operator::GreaterEqual, - Box::new(Expression::Function("GetRank".into(), vec![Expression::Constant(Atom::Num(1000))])), + Operator::GreaterEqual, + Box::new(Expression::Function( + "GetRank".into(), + vec![Expression::Constant(Atom::Num(1000))] + )), Some(Box::new(Expression::Constant(Atom::Num(200)))) - )), + )), Some(Box::new(Expression::Operation( - Operator::LessEqual, - Box::new(Expression::Function("GetRank".into(), vec![Expression::Constant(Atom::Num(1000))])), + Operator::LessEqual, + Box::new(Expression::Function( + "GetRank".into(), + vec![Expression::Constant(Atom::Num(1000))] + )), Some(Box::new(Expression::Constant(Atom::Num(253)))) )),) - )), + )), Some(Box::new(Expression::Operation( - Operator::Not, + Operator::Not, Box::new(Expression::Operation( - Operator::GreaterEqual, - Box::new(Expression::Function("GetRank".into(), vec![Expression::Constant(Atom::Num(2000))])), + Operator::GreaterEqual, + Box::new(Expression::Function( + "GetRank".into(), + vec![Expression::Constant(Atom::Num(2000))] + )), Some(Box::new(Expression::Constant(Atom::Num(10)))) - )), + )), None ))) ))