binary operation bitmask

This commit is contained in:
Folkert 2022-05-15 21:34:43 +02:00
parent 65e842f64a
commit f92a8e900d
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -2705,6 +2705,21 @@ fn number_literal_help<'a>() -> impl Parser<'a, Expr<'a>, ENumber> {
const BINOP_CHAR_SET: &[u8] = b"+-/*=.<>:&|^?%!";
const BINOP_CHAR_MASK: [bool; 125] = {
let mut result = [false; 125];
let mut i = 0;
while i < BINOP_CHAR_SET.len() {
let index = BINOP_CHAR_SET[i] as usize;
result[index] = true;
i += 1;
}
result
};
fn operator<'a>() -> impl Parser<'a, BinOp, EExpr<'a>> {
|_, state| operator_help(EExpr::Start, EExpr::BadOperator, state)
}
@ -2774,7 +2789,7 @@ fn chomp_ops(bytes: &[u8]) -> &str {
let mut chomped = 0;
for c in bytes.iter() {
if !BINOP_CHAR_SET.contains(c) {
if !BINOP_CHAR_MASK[*c as usize] {
break;
}
chomped += 1;