<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/subexast.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-19 13:58:13 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-19 13:58:13 +0100
commitca161b26e9b6a253837e5ec4e0cf318bd0ee7903 (patch)
treec3863c145024fd1124943e1eab525230c3236aaa /subex/subexast.go
parentd3d17484012dc603ae326bec419cff990898e6a0 (diff)
downloadstred-go-ca161b26e9b6a253837e5ec4e0cf318bd0ee7903.tar
Adds the NOT operator
Diffstat (limited to 'subex/subexast.go')
-rw-r--r--subex/subexast.go15
1 files changed, 15 insertions, 0 deletions
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,
+ }),
+ }
+}