SNOBOL4 in MTS
Total Page:16
File Type:pdf, Size:1020Kb
M T S The Michigan Terminal System Volume 9: SNOBOL4 in MTS September 1975 Updated June 1979 (Update 1) Updated May 1984 (Update 2) The University of Michigan Computing Center Ann Arbor, Michigan 1 DISCLAIMER This manual is intended to represent the current state of the Michigan Terminal System (MTS), but because the system is constantly being developed, extended, and refined, sections of this manual will become obsolete. The user should refer to the Computing_________ Center______ Newsletter,__________ Computing Center Memos, and future updates to this manual for the latest information about changes to MTS. Copyright 1979 by the Regents of the University of Michigan. Copying is permitted for nonprofit, educational use provided that (1) each reproduction is done without alteration and (2) the volume reference and date of publication are included. Permission to republish any portions of this manual should be obtained in writing from the Director of the University of Michigan Computing Center. 2 MTS 9: SNOBOL4 in MTS September 1975 Page Revised May 1984 PREFACE_______ The software developed by the Computing Center staff for the operation of the high-speed IBM 370-compatible computers can be described as a multipro- gramming supervisor that handles a number of resident, reentrant programs. Among them is a large subsystem, called MTS (Michigan Terminal System), for command interpretation, execution control, file management, and accounting maintenance. Most users interact with the computer’s resources through MTS. The MTS Manual is a series of volumes that describe in detail the facilities provided by the Michigan Terminal System. Administrative poli- cies of the Computing Center and the physical facilities provided are described in a separate publication entitled Introduction_________________________ to Computing Center_______________ Services. The MTS volumes now in print are listed below. The date indicates the most recent edition of each volume; however, since volumes are periodically updated, users should check the file *CCPUBLICATIONS, or watch for announce- ments in the Computing___________________________ Center Newsletter, to ensure that their MTS volumes are fully up to date. | Volume 1: The____________________________ Michigan Terminal System, January 1984 | Volume 2: Public________________________ File Descriptions, April 1982 | Volume 3: System______________________________ Subroutine Descriptions, April 1981 | Volume 4: Terminals_____________________________ and Networks in MTS, March 1984 | Volume 5: System_______________ Services, May 1983 | Volume 6: FORTRAN______________ in MTS, October 1983 | Volume 7: PL/I___________ in MTS, September 1982 | Volume 8: LISP____________________ and SLIP in MTS, June 1976 | Volume 9: SNOBOL4______________ in MTS, September 1975 | Volume 10: BASIC____________ in MTS, December 1980 | Volume 11: Plot_______________________ Description System, August 1978 | Volume 12: PIL/2____________ in MTS, December 1974 | Volume 13: The_____________________________ Symbolic Debugging System, November 1980 | Volume 14: 360/370_________________________ Assemblers in MTS, May 1983 | Volume 15: FORMAT__________________ and TEXT360, April 1977 | Volume 16: ALGOL______________ W in MTS, September 1980 | Volume 17: Integrated__________________________ Graphics System, December 1980 | Volume 18: The___________________ MTS File Editor, September 1982 | Volume 19: Tapes______________________ and Floppy Disks, February 1983 Other volumes are in preparation. The numerical order of the volumes does not necessarily reflect the chronological order of their appearance; however, in general, the higher the number, the more specialized the volume. Volume 1, for example, introduces the user to MTS and describes in general the MTS operating system, while Volume 10 deals exclusively with BASIC. 3 MTS 9: SNOBOL4 in MTS Page Revised May 1984 September 1975 The attempt to make each volume complete in itself and reasonably independent of others in the series naturally results in a certain amount of repetition. Public file descriptions, for example, may appear in more than one volume. However, this arrangement permits the user to buy only those volumes that serve his or her immediate needs. Richard A. Salisbury General Editor 4 MTS 9: SNOBOL4 in MTS September 1975 Page Revised May 1984 Contents________ Preface . 3 Speed Considerations . 76 Overview of SNOBOL4 in MTS . 7 Running in MTS . 78 Introduction to SNOBOL4 . 9 Parameters . 78 SNOBOL4 Constants . 10 I/O in MTS . 82 Variables . 12 External Routines . 83 Assignment . 14 Error Messages and Handling . 84 Arithmetic Operations . 16 Compilation Error Messages 84 Concatenation . 18 Execution Error Messages . 87 Indirection . 20 Error Codes . 89 Input-Output . 22 Calling External System Success and Failure . 23 Subroutines . 98 GOTOs . 24 SNOSTORM . 99 Program Format . 26 Introduction . 99 Simple Pattern Matching . 27 Definition of Terms . 99 Replacement . 29 Statement Expressions . 99 Function Calls . 31 Control Structures . .100 The Complete Statement IF Structures . .101 Format . 34 Simple IF . .101 More Sophisticated Pattern IF...ENDIF . .101 Matching . 35 IF...ELSE...ENDIF . .102 The Arbitrary Pattern - ARB . 36 IF...ELSEIF...ENDIF . .102 Conditional Value Assignment 38 LOOP Structures . .102 The Balanced Pattern - BAL . 40 LOOP . .103 The Fixed-Length Pattern LOOP FOR iteration . .103 Function - LEN(N) . 41 LOOP WHILE sexp . .104 Function definition . 43 LOOP UNTIL sexp . .105 Function Execution . 45 ENDLOOP [REPEAT [while] SPITBOL . 47 [until]] . .105 Introduction . 47 EXITLOOP . .106 Summary of Differences . 48 NEXTLOOP . .106 Features Not Implemented . 48 CASE Structures . .106 Features Implemented Procedure Structures . .107 Differently . 48 PROCEDURE...ENDPROCEDURE .107 Additional Features . 49 EXITPROCEDURE . .108 Other Incompatibilities . 49 Initialization . .108 Datatypes and Conversions . 50 Procedure and Case Datatypes in SPITBOL . 50 Initialization . .108 Datatype Conversion . 50 INITIAL...ENDINITIAL . .109 Syntax . 54 Comment Statements . .109 Pattern Matching . 55 SNOSTORM Comment Lines . .110 Functions . 55 Listing Control Statements .110 Keywords . 70 EJECT [icon] . .110 Control Cards . 72 TITLE ’text of title’ . .110 Listing Control Cards . 72 SUBTITLE ’text of Option Control Cards . 73 subtitle’ . .111 Programming Notes . 75 SPACE icon . .111 Space Considerations . 75 LIST [keyword] . .111 5 MTS 9: SNOBOL4 in MTS Page Revised May 1984 September 1975 SNOSTORM Listing . .111 Registration . .133 Source Indentation . .112 Block Organizations . .135 PAR Options . .112 FIXing a Block . .138 SIZE=icon . .112 Adaptive Blocks . .139 {COM|NOCOM} . .112 Iterated Blocks . .139 {INDENT=string|NOINDENT} .113 Replicated Blocks . .144 {LIST|NOLIST} . .113 Deferred Blocks . .148 CONVERT . .113 Nodes and Mergers . .149 DEBUG . .113 The &FILL Keyword . .154 Running SNOSTORM in MTS . .114 Surrogates . .154 Restrictions . .115 Special Built-in Functions .156 Multiple Statements . .115 Broadcasting . .158 Reserved Words . .115 Carriage Control . .158 Labeled SNOSTORM Examples . .159 Statements . .116 Appendix: Public File -COPY . .116 Descriptions . .169 Error Handling . .117 *CONVSNOBOL . .171 Obsolete SNOSTORM Statements 117 *SNOBOL4 . .173 Examples . .118 *SNOBOL4B . .175 SNOBOL4 Blocks . .127 *SPITBOL . .177 Introduction . .127 *SPITDEBUG . .180 Definition . .128 *SPITERR . .180 Printing . .128 *SPITLIB . .181 Concatenation . .129 *TRANSNOBOL . .183 Vacuous Blocks . .131 Index . .184 6 MTS 9: SNOBOL4 in MTS September 1975 Page Revised June 1979 OVERVIEW__________________________ OF SNOBOL4 IN MTS The SNOBOL4 language was developed at Bell Telephone Laboratories as a tool for string and list-processing applications. As a consequence, the language contains many powerful facilities for solving problems which involve text analysis, text formatting, etc. On the other hand, SNOBOL4 is a poor choice for solving problems which are primarily numeric in nature. Such problems are handled much more efficiently with mathematically oriented languages such as FORTRAN. In MTS, there are four distinct SNOBOL4 language processors which are available in the public files *SNOBOL4, *SNOBOL4B, *SPITBOL, and *SNOSTORM. Each public file is described in detail in the appendix to this volume. A brief summary is given here. *SNOBOL4 contains the language processor developed at Bell Telephone Laboratories and accepts the basic SNOBOL4 language. This processor is an interpreter and is implemented in a machine-independent macro language. This processor tends to be rather slow and expensive to use. *SNOBOL4B contains the language processor developed at Bell Telephone Laboratories for an upward-compatible extension of the basic SNOBOL4 language. This extension is called SNOBOL4 with Blocks and provides additional facilities for producing 2- and 3-dimensional printed output, such as is required for graphs and flowcharts. This processor is also implemented as an interpreter and tends to be expensive to use. *SPITBOL contains the language processor for a nearly compatible exten- sion of the basic SNOBOL4 language which was developed at the Illinois Institute of Technology. This processor is implemented as a true compiler and produces fast and efficient object module programs. Programs compiled with *SPITBOL can be run as much as ten times cheaper than programs run under *SNOBOL4. *SNOSTORM contains a preprocessor for an extended version of the SNOBOL4 language allowing structured-programming types