feat(wpcarro/slx): Support EQ operator

Naturally...

Change-Id: I9802a12db65eb07ed820e6ec1b56a9528001d0b8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7879
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
This commit is contained in:
William Carroll 2023-01-20 10:29:52 -08:00 committed by clbot
parent 9df188ad03
commit f91785bcc2

View file

@ -53,6 +53,7 @@ function compile(ast, config) {
const f = compile(ast.val, config);
let compare = null;
if (ast.operator === 'EQ') { compare = (x, y) => x === y; }
if (ast.operator === 'LT') { compare = (x, y) => x < y; }
if (ast.operator === 'GT') { compare = (x, y) => x > y; }
if (ast.operator === 'LTE') { compare = (x, y) => x <= y; }
@ -150,6 +151,11 @@ function tokenize(x) {
result.push(['ATOM', curr]);
continue;
}
if (x[i] === '=') {
result.push(['COMPARE', 'EQ']);
i += 1;
continue;
}
if (x[i] === '<' && i + 1 < x.length && x[i + 1] === '=') {
result.push(['COMPARE', 'LTE']);
i += 1;