From f91785bcc2efea5a560acddcbf4ce0d91c27e850 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 20 Jan 2023 10:29:52 -0800 Subject: feat(wpcarro/slx): Support EQ operator Naturally... Change-Id: I9802a12db65eb07ed820e6ec1b56a9528001d0b8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7879 Reviewed-by: wpcarro Autosubmit: wpcarro Tested-by: BuildkiteCI --- users/wpcarro/slx.js/index.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'users/wpcarro/slx.js') diff --git a/users/wpcarro/slx.js/index.js b/users/wpcarro/slx.js/index.js index 44f2f3643f..0f980c8d5a 100644 --- a/users/wpcarro/slx.js/index.js +++ b/users/wpcarro/slx.js/index.js @@ -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; -- cgit 1.4.1