terewfolio.blogg.se

Compiler design and construction
Compiler design and construction












Algorithms are described in an actual programming language (ALGOL 68) but students not familiar with this particular language should not have difficulty following them. It deals with the implementation of block-structured languages such as ALGOL 60, PL/1, ALGOL 68, Pascal, or Ada and reference is made frequently to aspects of particular languages. The book should be suitable as a basis for an undergraduate course on compilers and has been used as such in the University of Strathclyde. While the emphasis therefore is on the design aims of compiler projects and how they might be achieved, the practical details of compiler writing have not been overlooked and the background to much of the text is the compiler work which has taken place in the Computer Science Department in the University of Strathclyde over the last few years. Preface This book deals firstly with the design and secondly with the construction of compilers for high-level programming languages. IX 12.5 Non-Context-Free Errors 224 12.6 Run-Time Errors 227 12.7 Limit Errors 228 Exercises 229 Chapter 13 Writing Reliable Compilers 230 13.1 Use of Formal Definition 230 13.2 Modular Design 232 13.3 Checking the Compiler 235 Exercises 235 Solutions to Exercises 237 Bibliography 258 Index 261

#COMPILER DESIGN AND CONSTRUCTION CODE#

Vlll 5.4 Construction of an LR Parsing Table 108 5.5 LL versus LR Parsing Methods 117 Exercises 121 Chapter 6 Embedding Actions in Syntax 123 6.1 Production of Quadruples 123 6.2 Symbol Table Manipulation 127 6.3 Other Applications 132 Exercises 133 Chapter 7 Compiler Design 135 7.1 Number of Passes 135 7.2 Intermedi ate Languages 143 7.3 Target Language 144 Exercises 145 Chapter 8 Symbol and Mode Tables 146 8.1 Symbol Tables 146 8.2 Mode Tables 156 Exercises 161 Chapter 9 Storage Allocation 162 9.1 The Run-Time Stack 162 9.2 The Heap 176 Exercises 185 Chapter 10 Code Generation 187 10.1 Intermediate Code 187 10.2 Data Structures for Code Generation 192 10.3 Generating Code for Some Typical Constructs 196 10.4 Type Considerations 202 10.5 Compile Time versus Run Time 205 Exercises 206 Chapter 11 Generation of Machine Code 208 11.1 Generalities 208 11.2 Examples of Machine Code Generation 210 11.3 Object Code Optimization 213 Exercises 213 Chapter 12 Error Recovery and Diagnostics 215 12.1 Types of Error 215 12.2 Lexical Errors 216 12.3 Bracket Errors 218 12.4 Syntax Errors 220 54 3.4 Problems concerning particular languages 54 Exercises 56 Chapter 4 Context-Free Grammars and Top-Down Syntax Analysis 58 4.1 Context-Free Grammars 58 4.2 Method of Recursive Descent 64 4.3 LL (1) Grammars 67 4.4 LL (1) Languages 77 4.5 LL(1) Parsing Table 84 Exercises 94 Chapter 5 Bottom-Up Syntax Analysis 97 5.1 Bottom-Up Parsing 97 5.2 LR (1) Grammars and Languages 101 5.3 LR Parsing Tables 103 Title 001.64*25 QA76.6 ISBN 4 2 Photosetting by Thomson Press (India) Limited, New Delhi, and printed and bound by The Pitman Press, Bath.Ĭontents Preface xi Chapter 1 The Compilation Process 1 1.1 Relationship between Languages and Machines 2 1.2 Aspects of the Compilation Process 11 1.3 Design of a Compiler 14 Exercises 16 Chapter 2 Language Definition 18 2.1 Syntax and Semantics 18 2.2 Grammars 19 2.3 Formal Definition of Programming Languages 29 2.4 The Parsing Problem 34 Exercises 40 Chapter 3 Lexical Analysis 42 3.1 Recognition of Symbols 42 3.2 Output from the Lexical Analyser 51 3.3 Comments, etc. British Library Cataloguing in Publication Data: Hunter, Robin The design and construction of compilers. No part of this book may be reproduced by any means, nor transmitted, nor translated into a machine language without the written permission of the publisher. The Design and Construction of Compilers Robin Hunter Department of Computer Science, University of Strathclyde JOHN WILEY & SONS Chichester Ĭopyright © 1981 by John Wiley & Sons Ltd Reprinted with corrections, January 1983 All rights reserved.












Compiler design and construction