From ca161b26e9b6a253837e5ec4e0cf318bd0ee7903 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 19 Apr 2023 13:58:13 +0100 Subject: Adds the NOT operator --- subex/subexast.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'subex/subexast.go') diff --git a/subex/subexast.go b/subex/subexast.go index 78c9aff..fb16658 100644 --- a/subex/subexast.go +++ b/subex/subexast.go @@ -238,3 +238,18 @@ func (ast SubexASTReciprocal) compileWith(next SubexState) SubexState { }), } } + +// Runs the content Subex and collects the output +// Maps over the values in the output, casting each to a boolean, notting each and then outputs them +// Rejects if it cannot cast to boolean +type SubexASTNot struct { + content SubexAST +} +func (ast SubexASTNot) compileWith(next SubexState) SubexState { + return &SubexCaptureBeginState { + next: ast.content.compileWith(&SubexArithmeticEndState { + next: next, + calculate: notValues, + }), + } +} -- cgit v1.2.3