Preface
In the past compiler writers and designers seemed to form an elite group within
computing science, set apart by their esoteric knowledge and their ability to
produce large, important system programs which really worked. The admiration
of the computing public, whether it was once deserved or not, is no longer
merited now that the principles of programming-language implementation are
so well understood. Compiler-writing is no longer a mystery.
This book attempts to explain and demystify the principles of compiler writing
so that you can go out and build a working compiler of your own. There is
enough detail in this book for you to build a compiler for quite a complicated
language – certainly PASCAL, perhaps ALGOL 68 or SIMULA 67 – but it
doesn’t attempt an encyclopaedic coverage of the field. It is intended more as an
introduction to compiler-writing and a do-it-yourself kit for the compiler-writer,
giving enough detail for you to understand the principles of the subject, than as
a survey of past history or present horizons. The principles of interpretation are
close enough to those of compilation for chapter 19 to give a simple introduction
to interpreter writing.
The method of treatment and the relative amount of attention given to various
topics in this book reflects my own views about the relative importance of those
topics. There is a separate section on run-time support, less attention is paid
than is perhaps usual to the topic of parsing or syntax analysis and the discussion
of translation is totally oriented to tree-walking. I have presented the subject
in this way for both practical and educational reasons. First, the object code
instruction sequences which implement run-time support are more important
in practice than is usually recognised. It is differences in run-time mechanisms,
as much as or more than anything else, which distinguish one language from
another – say SIMULA 67 from ALGOL 68, POP-2 from ALGOL 60 – and
the efficiency of run-time support code fragments is crucial to the efficiency of
the object program. Second, I believe it is more important to give a practical
description of syntax analysis in a book which is intended for the practical
compiler-writer than to give a more formal and complete introduction to the
topic. The syntax analysis mechanisms chosen for illustration in section IV] are
selected for their practical relevance. Of the three mechanisms presented, the
‘one-track’ and ‘operator-precedence’ mechanisms are now rather old-fashioned
but are still quite adequate to the task of parsing popular modern languages.
iii
评论1
最新资源