Moves the code to evaluate logical expressions from the Bandada project to a new package called @zk-kit/logical-expressions.
The evaluate function now throws an error if the logical expression is incorrect.
There is no need to verify the correctness of the logical expression before calling the evaluate function, as this will be checked during the evaluation. If the expression is incorrect, an error will be thrown automatically.
Example of correct logical expression: "true and false".
Example of incorrect logical expression: "true true and false".
The @zk-kit/logical-expressions package facilitates the work with logical (boolean) expressions. It allows you to tokenize and evaluate any logical expression. It supports the use of parentheses.
Logical operators supported: and, or, not, xor.
All other existing logical operators (nand, nor, xnor) can be generated using the supported logical operators.
Description
This PR:
Moves the code to evaluate logical expressions from the Bandada project to a new package called
@zk-kit/logical-expressions
.The
evaluate
function now throws an error if the logical expression is incorrect.There is no need to verify the correctness of the logical expression before calling the evaluate function, as this will be checked during the evaluation. If the expression is incorrect, an error will be thrown automatically.
Example of correct logical expression:
"true and false"
.Example of incorrect logical expression:
"true true and false"
.The
@zk-kit/logical-expressions
package facilitates the work with logical (boolean) expressions. It allows you to tokenize and evaluate any logical expression. It supports the use of parentheses.Logical operators supported:
and
,or
,not
,xor
.All other existing logical operators (
nand
,nor
,xnor
) can be generated using the supported logical operators.More context: https://github.com/bandada-infra/bandada/issues/223
Future work:
The algorithm used to evaluate boolean expressions can be generalized to evaluate arithmetic expressions or other types of expressions if necessary.
Related Issue(s)
Closes https://github.com/privacy-scaling-explorations/zk-kit/issues/307
Checklist
yarn style
without getting any errors