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