diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-07-21 19:53:14 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-07-21 19:53:14 +0100 |
commit | e832b30f31c56614afe689035af4e04a29e77896 (patch) | |
tree | 5f49bc944b9505717541d774f1df3fa537720477 /subex/subexast.go | |
parent | bed0e712deda5038f52e495bacae003098df7a55 (diff) | |
download | stred-go-e832b30f31c56614afe689035af4e04a29e77896.tar |
Adds an incredibly simple equality operator
Diffstat (limited to 'subex/subexast.go')
-rw-r--r-- | subex/subexast.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/subex/subexast.go b/subex/subexast.go index b1ac931..e02091d 100644 --- a/subex/subexast.go +++ b/subex/subexast.go @@ -395,6 +395,20 @@ func (ast SubexASTNot) String() string { return fmt.Sprintf("(%v)!", ast.Content) } +// Runs the content Subex and collects the output +// Replaces it with true if all output values are equal and false otherwise +type SubexASTEqual struct { + Content SubexAST +} +func (ast SubexASTEqual) compileWith(next SubexState, slotMap *SlotMap, runic bool) SubexState { + return &SubexCaptureBeginState { + next: ast.Content.compileWith(&SubexArithmeticEndState { + next: next, + calculate: equalValues, + }, slotMap, runic), + } +} + // Does nothing type SubexASTEmpty struct {} func (ast SubexASTEmpty) compileWith(next SubexState, slotMap *SlotMap, runic bool) SubexState { |