Thoroughly updated to reflect the most current developments in language design and implementation, the second edition*Addresses key developments in programming language design:+ Finalized C99 standard+ Java 5+ C# 2.0+ Java concurrency package (JSR 166) and comparable mechanisms in C#+ Java and C# generics*Introduces and discusses scripting languages throughout the book and in an entire new chapter that covers:+ Application domains: shell languages, text processing and report generation, mathematics and statistics, "glue" languages and general purpose scripting, extension languages, scripting the World Wide Web+ Design concepts: names and scopes, string and pattern manipulation, high level data types, object orientation+ Major languages: Perl, PHP, Tcl/Tk, Python, Ruby, JavaScript, XLST*Updates many sections and topics:+ iterators+ exceptions+ polymorphism+ templates/generics+ scope rules and declaration ordering+ separate compilation+ garbage collection+ threads and synchronizationNew pedagogical featuresDesign & Implementation boxes+ Highlight the interplay between language design and language implementationTest Your Understanding review questions+ Help students assess their understanding of key points of a sectionIn More Depth CD supplements+ Present more advanced or peripheral material for students who would like to extend their knowledgeExplorations+ Provide students with additional exercises that are open-ended, research-type activitiesNew reference features+ Over 900 numbered and titled examples help the student to quickly cross-reference and access content for initial study and later review.+ Indices (in the printed text) for both the Design and Implementation boxes and the numbered examples.+ CD search engine for both the printed text and the supplemental sections. + Live links on the CD to Web-based language tutorials, reference manuals, and compilers and interpreters.On the CD+ In More Depth sections and sub-sections that are introduced in the book and presented on the CD+ In More Depth Exercises and Explorations for students wanting additional challenges+ Links to Web-based language reference manuals and tutorials+ Links to Web-based compilers and interpreters+ Text files containing the code fragments featured as examples in the book+ Search engine to search both the main text and the CD-only contentCD System RequirementsPDF ViewerThe CD material includes PDF documents that you can read with a PDF viewer such as Adobe, Acrobat or Adobe Reader. Recent versions of Adobe Reader for some platforms are included on the CD.HTML BrowserThe navigation framework on this CD is delivered in HTML and JavaScript. It is recommended that you install the latest version of your favorite HTML browser to view this CD. The content has been verified under Windows XP with the following browsers: Internet Explorer 6.0, Firefox 1.5; under Mac OS X (Panther) with the following browsers: Internet Explorer 5.2, Firefox 1.0.6, Safari 1.3; and under Mandriva Linux 2006 with the following browsers: Firefox 1.0.6, Konqueror 3.4.2, Mozilla 1.7.11. The content is designed to be viewed in a browser window that is at least 720 pixels wide. You may find the content does not display well if your display is not set to at least 1024x768 pixel resolution.Operating SystemThis CD can be used under any operating system that includes an HTML browser and a PDF viewer. This includes Windows, Mac OS, and most Linux and Unix systems.Instructor support+ Password-protected site for adopters who request the password from a sales representative+ Solutions to most exercises+ Figures from the book in several formats+ Lecture slides prepared by other instructors New Coverage: * Addresses the most recent developments in programming language design, including C99, C#, and Java 5. * Introduces and discusses scripting languages throughout the book as well as in an entire new chapter. * Includes a comprehensive chapter on concurrency, with coverage of the new Java concurrency package (JSR 166) and the comparable mechanisms in C#. * Updates many sections and topics, including iterators, exceptions, polymorphism, templates/generics, scope rules and declaration ordering, separate compilation, garbage collection, and threads and synchronization. New Pedagogical Features: * Highlights the interaction and tradeoffs inherent in language design and language implementation decisions with over 100 "Design and Implementation" call-out boxes. * Adds end-of-chapter "Exploration" exercises-open-ended, research-type activities. * Provides review questions after sections for quick self-assessment. * Includes over 800 numbered examples to help the reader quickly cross-reference and access content.
Author(s): Michael L. Scott
Edition: 2
Publisher: Morgan Kaufmann
Year: 2005
Language: English
Pages: 889
Front cover......Page 1
About the Author......Page 5
Title page......Page 6
Copyright page......Page 7
Foreword......Page 10
Table of contents......Page 12
Preface......Page 24
Changes in the Second Edition......Page 25
How to Use the Book......Page 28
Acknowledgments for the Second Edition......Page 30
I Foundations......Page 34
1 Introduction......Page 36
1.1 The Art of Language Design......Page 38
1.2 The Programming Language Spectrum......Page 42
1.3 Why Study Programming Languages?......Page 44
1.4 Compilation and Interpretation......Page 46
1.5 Programming Environments......Page 54
1.6 An Overview of Compilation......Page 55
1.7 Summary and Concluding Remarks......Page 64
1.8 Exercises......Page 65
1.9 Explorations......Page 66
1.10 Bibliographic Notes......Page 68
2 Programming Language Syntax......Page 70
2.1 Specifying Syntax: Regular Expressions and Context-Free Grammars......Page 71
2.2 Scanning......Page 79
2.3 Parsing......Page 94
2.4 Theoretical Foundations......Page 127
2.5 Summary and Concluding Remarks......Page 128
2.6 Exercises......Page 129
2.8 Bibliographic Notes......Page 134
3 Names, Scopes, and Bindings......Page 136
3.1 The Notion of Binding Time......Page 137
3.2 Object Lifetime and Storage Management......Page 139
3.3 Scope Rules......Page 147
3.4 Implementing Scope......Page 168
3.5 The Binding of Referencing Environments......Page 169
3.6 Binding Within a Scope......Page 175
3.8 Summary and Concluding Remarks......Page 182
3.9 Exercises......Page 184
3.10 Explorations......Page 190
3.11 Bibliographic Notes......Page 191
4 Semantic Analysis......Page 194
4.1 The Role of the Semantic Analyzer......Page 195
4.2 Attribute Grammars......Page 199
4.3 Evaluating Attributes......Page 201
4.4 Action Routines......Page 212
4.5 Space Management for Attributes......Page 214
4.6 Decorating a Syntax Tree......Page 215
4.7 Summary and Concluding Remarks......Page 220
4.8 Exercises......Page 222
4.9 Explorations......Page 226
4.10 Bibliographic Notes......Page 227
5 Target Machine Architecture......Page 228
5.1 The Memory Hierarchy......Page 229
5.2 Data Representation......Page 232
5.3 Instruction Set Architecture......Page 234
5.4 Architecture and Implementation......Page 237
5.5 Compiling for Modern Processors......Page 243
5.6 Summary and Concluding Remarks......Page 254
5.7 Exercises......Page 256
5.8 Explorations......Page 259
5.9 Bibliographic Notes......Page 260
II Core Issues in Language Design......Page 264
6 Control Flow......Page 266
6.1 Expression Evaluation......Page 267
6.2 Structured and Unstructured Flow......Page 287
6.3 Sequencing......Page 293
6.4 Selection......Page 294
6.5 Iteration......Page 303
6.6 Recursion......Page 320
6.7 Nondeterminacy......Page 328
6.8 Summary and Concluding Remarks......Page 329
6.9 Exercises......Page 331
6.10 Explorations......Page 337
6.11 Bibliographic Notes......Page 338
7 Data Types......Page 340
7.1 Type Systems......Page 341
7.2 Type Checking......Page 354
7.3 Records (Structures) and Variants (Unions)......Page 369
7.4 Arrays......Page 382
7.5 Strings......Page 399
7.6 Sets......Page 400
7.7 Pointers and Recursive Types......Page 402
7.8 Lists......Page 422
7.9 Files and Input/Output......Page 425
7.10 Equality Testing and Assignment......Page 426
7.11 Summary and Concluding Remarks......Page 428
7.12 Exercises......Page 431
7.13 Explorations......Page 437
7.14 Bibliographic Notes......Page 438
8 Subroutines and Control Abstraction......Page 440
8.1 Review of Stack Layout......Page 441
8.2 Calling Sequences......Page 443
8.3 Parameter Passing......Page 450
8.4 Generic Subroutines and Modules......Page 467
8.5 Exception Handling......Page 474
8.6 Coroutines......Page 486
8.7 Summary and Concluding Remarks......Page 492
8.8 Exercises......Page 493
8.9 Explorations......Page 499
8.10 Bibliographic Notes......Page 500
9 Data Abstraction and Object Orientation......Page 502
9.1 Object-Oriented Programming......Page 504
9.2 Encapsulation and Inheritance......Page 514
9.3 Initialization and Finalization......Page 522
9.4 Dynamic Method Binding......Page 530
9.5 Multiple Inheritance......Page 544
9.6 Object-Oriented Programming Revisited......Page 545
9.7 Summary and Concluding Remarks......Page 546
9.8 Exercises......Page 548
9.9 Explorations......Page 550
9.10 Bibliographic Notes......Page 551
III Alternative Programming Models......Page 554
10 Functional Languages......Page 556
10.1 Historical Origins......Page 557
10.2 Functional Programming Concepts......Page 559
10.3 A Review/Overview of Scheme......Page 561
10.4 Evaluation Order Revisited......Page 572
10.5 Higher-Order Functions......Page 578
10.7 Functional Programming in Perspective......Page 582
10.9 Exercises......Page 585
10.10 Explorations......Page 590
10.11 Bibliographic Notes......Page 591
11 Logic Languages......Page 592
11.1 Logic Programming Concepts......Page 593
11.2 Prolog......Page 594
11.4 Logic Programming in Perspective......Page 612
11.5 Summary and Concluding Remarks......Page 616
11.6 Exercises......Page 617
11.7 Explorations......Page 619
11.8 Bibliographic Notes......Page 620
12 Concurrency......Page 622
12.1 Background and Motivation......Page 623
12.2 Concurrent Programming Fundamentals......Page 634
12.3 Shared Memory......Page 652
12.4 Message Passing......Page 675
12.5 Summary and Concluding Remarks......Page 693
12.6 Exercises......Page 695
12.7 Explorations......Page 701
12.8 Bibliographic Notes......Page 702
13 Scripting Languages......Page 704
13.1 What Is a Scripting Language?......Page 705
13.2 Problem Domains......Page 710
13.3 Scripting the WorldWideWeb......Page 734
13.4 Innovative Features......Page 755
13.5 Summary and Concluding Remarks......Page 781
13.6 Exercises......Page 783
13.7 Explorations......Page 788
13.8 Bibliographic Notes......Page 789
IV A Closer Look at Implementation......Page 792
14.1 Back-End Compiler Structure......Page 794
14.2 Intermediate Forms......Page 799
14.3 Code Generation......Page 802
14.4 Address Space Organization......Page 808
14.5 Assembly......Page 809
14.6 Linking......Page 814
14.7 Dynamic Linking......Page 817
14.8 Summary and Concluding Remarks......Page 819
14.9 Exercises......Page 820
14.10 Explorations......Page 822
14.11 Bibliographic Notes......Page 823
15 Code Improvement......Page 824
A Programming Languages Mentioned......Page 826
B Language Design and Language Implementation......Page 836
C Numbered Examples......Page 840
Bibliography......Page 852
Index......Page 870