| 10 | }; |
| 11 | |
| 12 | Op parseOp(char t) |
| 13 | { |
| 14 | using namespace matchit; |
| 15 | Id<char> token; |
| 16 | return match(t)( |
| 17 | pattern | '+' = expr(Op::Add), pattern | '-' = expr(Op::Sub), |
| 18 | pattern | '*' = expr(Op::Mul), pattern | '/' = expr(Op::Div), |
| 19 | pattern | token = [&] |
| 20 | { |
| 21 | std::cerr << "Unexpected: " << *token; |
| 22 | std::terminate(); |
| 23 | return Op::Add; |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | int32_t main() |
| 28 | { |