An Experimental Compiler-Compiler System James Robert Van Doren Iowa State University
Total Page:16
File Type:pdf, Size:1020Kb
Iowa State University Capstones, Theses and Retrospective Theses and Dissertations Dissertations 1971 An experimental compiler-compiler system James Robert Van Doren Iowa State University Follow this and additional works at: https://lib.dr.iastate.edu/rtd Part of the Computer Sciences Commons Recommended Citation Van Doren, James Robert, "An experimental compiler-compiler system " (1971). Retrospective Theses and Dissertations. 4516. https://lib.dr.iastate.edu/rtd/4516 This Dissertation is brought to you for free and open access by the Iowa State University Capstones, Theses and Dissertations at Iowa State University Digital Repository. It has been accepted for inclusion in Retrospective Theses and Dissertations by an authorized administrator of Iowa State University Digital Repository. For more information, please contact [email protected]. 1 72-5264 VAN DOREN, James Robert, 1939- f AN EXPERIMENTAL COMPILER-COMPILER SYSTEM. I I Iowa State University, Ph.D., 1971 I Conçuter Science University Microfilms, A XEROX Company, Ann Arbor, Michigan THIS DISSERTATION HAS BEEN MICROFILMED EXACTLY AS RECEIVED An experimental oompiler-compiler system by James Robert Van Doren A Dissertation Submitted to the Graduate Faculty in Partial Fulfillment of The Requirements for the Degree of DOCTOR OF PHILOSOPHY Major Subject: Computer Science Approved: Signature was redacted for privacy. In unciiy« ot najuL wwtft. Signature was redacted for privacy. For the Major Department Signature was redacted for privacy. For the Graduate College Iowa State University Of Science and Technology Ames, Iowa 1971 PLEASE NOTE: Some Pages have indistinct print. Filmed as received. UNIVERSITY MICROFILMS ii TABLE OF CONTENTS I. INTRODUCTION 1 II. REVIEW OF THE LITERATURE % III. THE METAX METALANGUAGES I'* A. Developmental Rationale B. Bootstrapping 16 C. The HETAX9 Metalanguage 18 1. Compiler definition commands 18 2. Elmentary syntactical commands 20 3. Metasyntactic elements 26 4. Semantic commands 27 5. Output operators 35 6- Error processing 37 D. The METAX9 Pseudo-Machine 41 1. Primitive operations 41 2. Control stack 46 3. Symbol table structure 47 4. Addressing structure 51 5- Block list 51 6- General comments 52 E. METAX8 and METAX9 Pseudo-Machine Differences 52 F. Chronological Development 54 IV. THE METAX SYSTEM ORGANIZATION 57 A. Control Program 57 B. Control Record Analyzer 59 C. Communications Region 60 D. Main Storage Usage 62 V. PLEX; THE LANGUAGE AND ITS TRANSLATOR 64 A. The PLEX Language 64 iii B. The PLEX Pseudo-Machine 71 C- The PLEX Translator 87 VI. CONCLaSIONS AND SUGGESTED FURTHER WORK 95 VII. BIBLIOGRAPHY 99 VIII. ACKNOWLEDGEMENTS 104 IX. APPENDIX A 105 X. APPENDIX B 113 XI. APPENDIX C 220 XII. APPENDIX D 317 XIII. APPENDIX E 325 1 I. INTRODUCTION This dissertation presents the investigation of a number of factors in the development of an experimental compiler- compiler system capable of accommodating the implementation of reasonably sophisticated high level programming languages such as ALGOL (41,42) and PL/I (29) as well as implementation of compiler writing languages or metalanguages. The primary results include a compiler waiting language with which a translator for a language similar to PL/I was implemented and a metalanguage version in which compiler writing languages may be written. Perhaps a minor result is the overall system organization. However, certain aspects of this organization, particularly the job control scheme; materially aided in the development of the principal results. We refer frequently to the METAX (META experimental) system due to the influence of the META series of translator writing systems (43,44,45,52,54) and we also refer to the compiler-compiler system because compilers for compiling a compiler written in a metalanguage are included. It should be noted that "metalanguage" and "compiler writing language" are used almost synonymously throughout this dissertation al though it is certainly true that one may metalinguistically describe a language without necessarily implying anything about a computer program. Additionally, "semantic" may be 2 used in a manner meaning postsyntatic, that is, not syntactic. With reference to the functions of the various object languages and their interpreters, "primitive" and "pseudo-machine instruction" are also used synonymously. In Chapter II we review the literature with emphasis on translator writing systems having the most influence on the one presented here. Chapter III contains a brief discussion of a number of practical matters having an influence on the course of devel opment. The culmination of this development is the KETAX9 metalanguage with which the PLEX translator was written, PLEX being the PL/I-like language mentioned. A review of METAX9 and its object code interpreter is presented. The overall system organization is presented in Chapter IV including descriptions of the supporting assembler lan guage programs and the control record analyzer, the processor for which was written in one version of the metalanguage. Chapter V comprises a discussion of a PL/I-like lan guage, PLEX, the object language interpreter and the imple mentation of its compiler which illustrates most of the fea tures of METAX9. Pun-time storage administration represents an important aspect of the implementation and is considered extensively. In Chapter VI we review the results, present some con clusions and suggest some areas for future investigation. 3 It should be noted that the appendices comprise an es sential segment of this dissertation as the syntax and seman tics for PLEX and METAX9 are displayed. Additionally the object code interpreters are presented which may be used to resolve fine points and to give more detail about certain aspects of the implementations. Three PLEX programs are in cluded, two of which at least partially demonstrate the viability of PLEX, the third being an error diagnostic exam ple. One of the PLEX programs, program ESYLST, was used to prepare the assembler language listings and symbol definition indices found in Appendices B, C and D. Finally, some hardware and software characteristics of the host computer system, an H-1200, are given in Appendix E for the benefit of readers not familiar with that system. 4 II. REVIEW OF THE LITERATURE This chapter begins with a review of the META series of translator writing systems as the compiler-compiler system reported in this dissertation owes much to this particular series. Schorre (53) and Metcalfe (39) first reported syntax di rected compiling schemes which contained the basic ideas leading to the META series. Metcalfe (39) presented a translation machine with primitives strikingly similar to the object code primitives of Schorre's META II system (54) and also recognized the potential application of his translation machine in translating directly from a higher order metalanguage to syntax code using a metagrammar. META II (54) is the first published work on the META series itself. A basic characteristic of the META II system is a top-down syntax analysis without backup directed by an encoding language (translator writing language) similar to the Backus Naur Form (BNF), BNF having been originally used in defining the syntax of ALGOL 60 (41,42). Furthermore, the META II language (or metalanguage) enabled the specification of symbolic code and label generation to be output subsequent to successful recognition of specified syntactical ^ ^^ M E With this scheme Schorre (54) constructed translators 5 for two languages he called VALGOL I and VALGOL II based on restricted subsets of ALGOL. Although this system has many deficiencies such as the lack of a symbol table, no error recovery and the inability to handle anything but a deterministic syntax analysis it presents rather interesting bootstrapping capabilities of interest here. BNF as it stands has a limitation as a metalanguage in that it is not possible to describe the syntax of BNF in BNF due to metasymbol conflicts. The syntax specifications used in BETA II resolve this problem by making certain changes in metasymbol usage and thus it is possible to describe the META II language or other metalanguages with META II. Specifically, terminal symbols in META II are indicated with enclosing delimiters (•') and nonterminal symbols are in dicated with no enclosing delimiters whatsoever as opposed to the use of the symbols "<" and ">" to delimit nonterminal symbols and the lack of any enclosing syntax for terminal symbols in BNF. Moreover, an iteration operator, "$", is used in place of left recursion. The use of parentheses as meta symbols for denoting metaexpressions is also included in META II. Thus the representation of a subscript list may be writ ten as. SDBLIST:= EXP $ ( EXP ); 6 in META II as opposed to <SOBLIST>::= <SUBLIST> , <EXP> | <EXP>; in EHF. The fact that specific symbols in the language being de scribed are enclosed in quotes permits description of metasyntactic symbols if that is desired. Thus it is possi ble to denote the alternation symbol "I" as a syntax specifi cation which cannot be accomplished in BNF because such a symbol in unquoted form would represent a metasymbol and not a syntax specification of the language being described. It is thus possible to represent the syntax of META II in META II as follows: .SYNTAX PROGRAM PROGRAM := ".SYNTAX" .ID $ ST ".END"; ST := .ID EX1 EX1 ;= EX2 $ ( "1" EX2 ); EX2 := ( EX3 I OOTPOT ) $ (EX3 | OUTPUT ); EX3 := .ID I .STRING | ".ID" | ".NUMBER" | ".STRING" I "(" EX1 " I ".EMPTY" I "$" EX3 ; OUTPUT := ".OUT" "(" $ 0UT1 ")" | ".LABEL" "(" 0UT1 ")" ; 0UT1 := "*1" I "*2" I I .STRING ; .END . Certain additional liber+ies with BNF may be evident in that .ID and .STRING are assumed to be terminal symbols which 7 will in fact be references to corresponding pseudo-machine interpreter segments for recognition purposes. Whitney (56) presents other types of modifications to BNF specifically aimed at the syntax of declarations which represents a degree of context sensitivity that BNF cannot represent. The full translator of META II in META II is not given here. Suffice it to say that Theys (55) presents an exten sive and detailed review of META II as well as other members of the META series.