<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/subexast.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/subexast.go')
-rw-r--r--subex/subexast.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/subex/subexast.go b/subex/subexast.go
index abf0ca6..3c807ee 100644
--- a/subex/subexast.go
+++ b/subex/subexast.go
@@ -209,3 +209,17 @@ func (ast SubexASTProduct) compileWith(next SubexState) SubexState {
}),
}
}
+
+// Runs the content Subex, if all outputted atoms can be cast to numbers, outputs them all negated
+// Rejects if this fails
+type SubexASTNegate struct {
+ content SubexAST
+}
+func (ast SubexASTNegate) compileWith(next SubexState) SubexState {
+ return &SubexCaptureBeginState {
+ next: ast.content.compileWith(&SubexArithmeticEndState {
+ next: next,
+ calculate: negateValues,
+ }),
+ }
+}