From b48dcb0d37bd3db854927df25e6ff41d07501026 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 19 Apr 2023 13:10:24 +0100 Subject: 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 --- subex/subexast.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'subex/subexast.go') 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, }), } } -- cgit v1.2.3