mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
binary operation bitmask
This commit is contained in:
parent
65e842f64a
commit
f92a8e900d
1 changed files with 16 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue