From 6ae39619b7632eb9c0f92ef973fd7193598f9e65 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Thu, 25 Apr 2024 04:10:00 +0900 Subject: [PATCH] Add support for bitwise OR and AND operators in calculateRPN function --- src/ts/process/infunctions.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ts/process/infunctions.ts b/src/ts/process/infunctions.ts index d9322282..71262537 100644 --- a/src/ts/process/infunctions.ts +++ b/src/ts/process/infunctions.ts @@ -12,6 +12,8 @@ function toRPN(expression:string) { '%': {precedence: 3, associativity: 'Left'}, '<': {precedence: 1, associativity: 'Left'}, '>': {precedence: 1, associativity: 'Left'}, + '|': {precedence: 0, associativity: 'Left'}, + '&': {precedence: 0, associativity: 'Left'}, }; expression = expression.replace(/\s+/g, ''); @@ -57,6 +59,8 @@ function calculateRPN(expression:string) { case '%': stack.push(a % b); break; case '<': stack.push(a < b ? 1 : 0); break; case '>': stack.push(a > b ? 1 : 0); break; + case '|': stack.push(a || b); break; + case '&': stack.push(a && b); break; } } });