Adding first operator

This commit is contained in:
Mike Farah
2025-11-09 16:12:17 +11:00
parent 49b6477c49
commit 3050ca5303
6 changed files with 588 additions and 0 deletions
+6
View File
@@ -54,6 +54,12 @@ func (p *expressionParserImpl) createExpressionTree(postFixPath []*Operation) (*
switch numArgs {
case 1:
if len(stack) < 1 {
// Allow certain unary ops to accept zero args by interpreting missing RHS as nil
// TODO - make this more general on OperationType
if Operation.OperationType == firstOpType {
// no RHS provided; proceed without popping
break
}
return nil, fmt.Errorf("'%v' expects 1 arg but received none", strings.TrimSpace(Operation.StringValue))
}
remaining, rhs := stack[:len(stack)-1], stack[len(stack)-1]