Top-level control flow and configuration
Perl expert Ted Zlatanov continues his top-down development of the cfperl project, a cfengine interpreter written in Perl, starting with the control flow and configuration handling.
This chapter is from Ted's book, At the Helm, being published serially on the Web in the developerWorks column The road to better programming. Catch up on Ted's earlier chapters.
In the previous installment, Chapter 6. Developing cfperl, from the beginning, we covered some of the preliminary steps of undertaking a new project, including research, choice of license, and basic architecture decisions. Having dispensed with these, I was ready to begin coding!
The first steps in writing the cfperl interpreter were to write the main loop, determine the control flow, and adopt a configuration style similar (as much as possible) to the cfengine configuration style.
Because cfperl is a small project, a top-down approach was feasible. I could keep the main loop in my head, and develop each part of the interpreter cycle sequentially. Furthermore, I documented the main loop in POD form at the end of the script, for my benefit as much as for others'.
The control flow was determined by my choice of parsing module. Using
Parse::RecDescent
enabled me to do a 2-level parse, first with a generic
parser and then (by using section-keyed grammars) with grammars
appropriate to the situation or a default grammar.
View The road to better programming: Chapter 7. Top-level control flow Discussion
Page: 1 2 3 4 5 Next Page: The main loop