Implement subtraction in evaluator
This commit is contained in:
@@ -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