I took a compiler course in college, and we wrote a nearly complete compiler, but we did it from scratch. We wrote the tokeniser, the parser, the dump method to create the assembly. We never got to complete the expression parsing, sadly.
Other people, however, took Dr. Abrahamson’s compiler course. They used Flex.
I don’t know if that was a better way to teach it, but Flex is something I certainly want to learn. Some of the people there were not so skilled, so they often asked for help with their homework. Flex looked interesting, it did.
Of course, I totally enjoyed writing my own compiler from scratch. Highly enjoyable OOP. I should probably write a compiler from scratch-
a more complete one with closures and lambdas all sorts of fun details-and then reimplement it using Flex.