diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-19 13:10:24 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-19 13:10:24 +0100 |
commit | b48dcb0d37bd3db854927df25e6ff41d07501026 (patch) | |
tree | ae2059a0f9a66d48c9bdf3cf41c367e5c0848ad6 /subex/subexast.go | |
parent | 0072e6aad2f9969348d5315a692f1f5e2ebc075d (diff) | |
download | stred-go-b48dcb0d37bd3db854927df25e6ff41d07501026.tar |
Combines sum and product into an arithmetic state that contains a function for it's operation
Creates arithmetic.go which will house all of these functions
Diffstat (limited to 'subex/subexast.go')
-rw-r--r-- | subex/subexast.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/subex/subexast.go b/subex/subexast.go index 431ea26..abf0ca6 100644 --- a/subex/subexast.go +++ b/subex/subexast.go @@ -190,8 +190,9 @@ type SubexASTSum struct { } func (ast SubexASTSum) compileWith(next SubexState) SubexState { return &SubexCaptureBeginState { - next: ast.content.compileWith(&SubexSumEndState { + next: ast.content.compileWith(&SubexArithmeticEndState { next: next, + calculate: sumValues, }), } } @@ -202,8 +203,9 @@ type SubexASTProduct struct { } func (ast SubexASTProduct) compileWith(next SubexState) SubexState { return &SubexCaptureBeginState { - next: ast.content.compileWith(&SubexProductEndState { + next: ast.content.compileWith(&SubexArithmeticEndState { next: next, + calculate: multiplyValues, }), } } |