Implement subtraction in evaluator
This commit is contained in:
1 parent
d4855813a2
commit
bb622a0766
2 files changed
+28
-1
No files matched your search
+8
-1
@@ -6,5 +6,12 @@ int evaluate(const expression_t *expression)
|
||||
return expression->number;
|
||||
const int x = evaluate(expression->application.operands[0]);
|
||||
const int y = evaluate(expression->application.operands[1]);
|
||||
return x + y;
|
||||
switch (expression->application.operator) {
|
||||
case OPERATOR_ADD:
|
||||
return x + y;
|
||||
case OPERATOR_SUBTRACT:
|
||||
return x - y;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user