The Implementation of Icon and Unicon a Compendium Clinton Jeffery, editor ii The Implementation of Icon and Unicon Ralph and Madge T. Griswold Kenneth W. Walker Clinton L. Jeffery ii Copyright © 2014 Clinton Jeffery Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back- Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Portions of this document ("The Implementation of the Icon Programming Language") are in the public domain and not subject to the above copyright or license. Portions of this document ("An Optimizing Compiler for Icon") are copyrighted by Kenneth Walker and appear in edited form in this document with the express permission of the author. This is a draft manuscript dated 6/6/2014. Send comments and errata to [email protected]. This document was prepared using OpenOffice.org 4.1. iii Contents Preface................................................................................................................................xi Organization of This Book.............................................................................................xi Acknowledgments..........................................................................................................xi Compendium Introduction...................................................................................................1 How Many Compilers?....................................................................................................1 Part I: The Implementation of the Icon Programming Language.........................................3 Chapter 1: Introduction........................................................................................................5 1.1 Implementing Programming Languages....................................................................5 1.2 The Background for Icon...........................................................................................6 Chapter 2: Icon Language Overview...................................................................................9 2.1 The Icon Programming Language..............................................................................9 2.2 Language Features and the Implementation............................................................31 Chapter 3: Organization of the Implementation................................................................35 3.1 The Icon Virtual Machine........................................................................................35 3.2 Components of the Implementation.........................................................................36 3.3 The Translator..........................................................................................................37 3.4 The Linker................................................................................................................38 3.4.1 Scope Resolution..............................................................................................38 3.4.2 Construction of Run-Time Structures...............................................................38 3.5 The Run-Time System.............................................................................................38 Chapter 4: Values and Variables........................................................................................41 4.1 Descriptors...............................................................................................................42 4.1.1 Strings...............................................................................................................43 4.1.2 The Null Value..................................................................................................43 4.1.3 Integers..............................................................................................................44 4.3 Variables..................................................................................................................45 4.3.1 Operations on Variables....................................................................................46 4.3.2 Trapped Variables.............................................................................................47 4.4 Descriptors and Blocks in C....................................................................................48 4.4.1 Descriptors........................................................................................................48 4.4.2 Blocks...............................................................................................................49 4.4.3 Defined Constants.............................................................................................50 4.4.4 RTL Coding......................................................................................................51 Chapter 5: Strings and Csets..............................................................................................55 5.1 Strings......................................................................................................................55 5.1.1 Representation of Strings..................................................................................55 5.1.2 Concatenation...................................................................................................57 5.1.3 Substrings..........................................................................................................59 5.1.4 Assignment to Subscripted Strings...................................................................60 5.1.5 Mapping............................................................................................................61 5.2 Csets.........................................................................................................................64 Chapter 6: Lists..................................................................................................................67 6.1 Structures for Lists...................................................................................................67 6.2 Queue and Stack Access..........................................................................................70 6.3 Positional Access.....................................................................................................76 Chapter 7: Sets and Tables.................................................................................................80 7.1 Sets...........................................................................................................................80 7.1.1 Data Organization for Sets................................................................................80 iv 7.1.2 Set Operations...................................................................................................82 7.2 Tables.......................................................................................................................83 7.2.1 Data Organization for Tables............................................................................83 7.3 Hashing Functions...................................................................................................86 EXERCISES..............................................................................................................89 Chapter 8: The Interpreter..................................................................................................91 8.1 Stack-Based Evaluation...........................................................................................91 8.2 Virtual Machine Instructions...................................................................................92 8.2.1 Constants...........................................................................................................92 8.2.2 Identifiers..........................................................................................................93 8.3 Operators................................................................................................................100 8.2.4 Functions.........................................................................................................101 8.3 The Interpreter Proper............................................................................................102 8.3. 1 The Interpreter Loop......................................................................................102 Chapter 9: Expression Evaluation....................................................................................103 9.1 Bounded Expressions.............................................................................................103 9.1.1 Expression Frames..........................................................................................105 9.2 Failure....................................................................................................................106 9.3 Generators and Goal-Directed Evaluation.............................................................109 9.4 Generative Control Structures...............................................................................119 9.4.1 Alternation......................................................................................................119 9.4.2 Repeated Alternation.......................................................................................121 9.4.3 Limitation........................................................................................................121
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages432 Page
-
File Size-