Chapter 5. Control Constructs

Table of Contents

5.1. The Plan
5.2. Some Groundwork
5.3. The IF Statement
5.4. The WHILE Statement
5.5. The LOOP Statement
5.6. Repeat - Until
5.7. The FOR Loop
5.8. The DO statement
5.9. The BREAK Statement
5.10. Conclusion

Installment published 19th August 1988

In the first four chapters of this series, we've been concentrating on the parsing of math expressions and assignment statements. In this chapter , we'll take off on a new and exciting tangent: that of parsing and translating control constructs such as IF statements.

This subject is dear to my heart, because it represents a turning point for me. I had been playing with the parsing of expressions, just as we have done in this series, but I still felt that I was a long way from being able to handle a complete language. After all, real languages have branches and loops and subroutines and all that. Perhaps you've shared some of the same thoughts. Awhile back, though, I had to produce control constructs for a structured assembler preprocessor I was writing. Imagine my surprise to discover that it was far easier than the expression parsing I had already been through. I remember thinking, “Hey! This is easy!” After we've finished this session, I'll bet you'll be thinking so, too.