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