Alexander Hansen | 4e1142d | 2025-07-25 17:07:27 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright 2017 Intel Corporation, 2022 IBM Corp. |
Andrew Jeffery | a05437e | 2022-04-07 16:17:21 +0930 | [diff] [blame] | 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <optional> |
| 7 | #include <string> |
Andrew Jeffery | 5ace4e4 | 2022-04-07 16:58:30 +0930 | [diff] [blame] | 8 | #include <vector> |
Andrew Jeffery | a05437e | 2022-04-07 16:17:21 +0930 | [diff] [blame] | 9 | |
| 10 | namespace expression |
| 11 | { |
| 12 | enum class Operation |
| 13 | { |
| 14 | addition, |
| 15 | division, |
| 16 | multiplication, |
| 17 | subtraction, |
| 18 | modulo, |
| 19 | }; |
| 20 | |
John Edward Broadbent | 59b275f | 2022-10-06 15:26:25 -0700 | [diff] [blame] | 21 | std::optional<Operation> parseOperation(const std::string& op); |
Andrew Jeffery | a05437e | 2022-04-07 16:17:21 +0930 | [diff] [blame] | 22 | int evaluate(int a, Operation op, int b); |
Andrew Jeffery | 9555961 | 2022-04-07 17:22:47 +0930 | [diff] [blame] | 23 | int evaluate(int substitute, std::vector<std::string>::iterator curr, |
| 24 | std::vector<std::string>::iterator& end); |
Andrew Jeffery | a05437e | 2022-04-07 16:17:21 +0930 | [diff] [blame] | 25 | } // namespace expression |