A example in 《Compilers: Principles, Techniques, and Tools》, rewritten in C++ (no memory management)