yo/coroutines/demo/fsa/digit/codigit.cc
raw| 1 | #include "digit.ih" |
| 2 | |
| 3 | Digit coDigit() |
| 4 | { |
| 5 | char ch; |
| 6 | while (cin.get(ch)) |
| 7 | { |
| 8 | if (isalpha(ch)) |
| 9 | { |
| 10 | cout << "at `" << ch << "' from digit to letter\n"; |
| 11 | co_await g_letter; |
| 12 | } |
| 13 | else if (isdigit(ch)) |
| 14 | cout << "at `" << ch << "' remain in digit\n"; |
| 15 | else |
| 16 | { |
| 17 | cout << "at char #" << static_cast<int>(ch) << |
| 18 | ": from digit to start\n"; |
| 19 | co_await g_start; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | co_await g_done; |
| 24 | } |