Preface

“Why learn compilers?” – that is a question many of our students have asked us in our teaching career. We have given various answers – sometimes serious, sometimes only partially serious, but here are two quotes which we like:

 

If you dont understand compilers, you can still write programs – you can even be a competent programmer – but you cant be a master.”

 

– Hal Abelson, MIT

If you dont know how compilers work, then you dont know how computers work. If youre not 100% sure whether you know how compilers work, then you dont know how they work.”

 

– Steve Yegge

The study of compilation techniques is integration of many things a Computer Science/Engineering student learns separately – Data Structures, Algorithms, Theory of Automata and Formal Languages, machine architecture, even operating systems. The only other CS course which integrates to a comparable extent is a course on Operating Systems, but there the emphasis is different.

There are several good books on Compilers available to students. Some are highly theoretical and give limited details of the practical aspects of compiler writing. Some of them are filled with detailed code of a compiler. They are very difficult to be used as a textbook in an undergraduate engineering course.

The available textbooks represent a spectrum of presentation approach. Some of the books are voluminious with considerable amount of theoretical material that are more suitable for those students who have “Compilers” as a research interest. At the other end of the spectrum are books that contain pages after pages of C code of not only compiler proper, but compiler-writing tools also, with just sufficient theory. Our book is somewhere between these extremes in this spectrum and we feel that our book is more suitable for students at Indian universities.

We have tried to strike a balance between Theory and Practice. The full source code of a compiler is available at www.pearsoned.co.in/paraghimanshudave.

The contents and style of presentation are especially suitable to Indian students. To enhance the students learning experience, we have given a Glossary, Suggestions for Further Reading and Web Resources at the end of almost all chapters.

A distinguishing feature of the book is a detailed introduction to compiler writing tools and GNU gcc (GNU Compiler Collection), which we believe, provide an excellent platform for those students who want to take up research in compilation and optimization techniques and engineers who want to implement compiler for new languages.

The chapters are sequenced like this: After Introduction in Chapter 1, we discuss a complete compiler scheme for a Simple language in Chapter 2A Simple Translator. We then start our discussion of various phases of a compiler in Chapter 3, where we discuss Lexical Analyzers. In Chapter 4 we explain Syntax Analyzer at length. Next Syntax Directed Translation is elucilated in Chapter 5. Type Checking, which has invoked considerable theoretical interest is described in Chapter 6. Chapter 7 details Run-time Environment. Intermediate Code issues are examined in Chapter 8. In Chapter 9 we have discussed Code Generation and Machine Dependent Optimization, where we have also given considerable details about programming of a Floating-point processor for a specific popular architecture (x86). Chapter 10 deals with Code Optimization issues. We thought it worthwhile to take an Overview of Processing of Some Languages to Chapter 11, where we have considered Java, Perl, PROLOG, and FORTH from the processing viewpoint. Finally, in Chapter 12 we give details of a Project: Compiler for a miniC to conclude the study of compilers.

Three Appendices – Formal Languages and Automata, Assemblers and MACRO Processors and Linkers and Loaders provide the essential background material. The fourth appendix Worked-out Problems gives several problems with solutions.

A Bibliography and an Index given at the end should help locating reading material.

There is enough material for a 40 to 45 1-hour lecture course at the undergraduate level.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.223.10