wffl mm Warn 111 Sal ma WBB| BHNraffl IB! mm Bill 8SIM LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510 A4 top' 2 ' Digitized by the Internet Archive in 2013 http://archive.org/details/interactivesynta504sanf r/)/ UIUCDCS-R-72-504 ' top- 2- AN INTERACTIVE SYNTAX ANALYZER by Wayne C. Sanford January, 1972 DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN • URBANA, ILLINOIS /ERS1TY : The person charging this material is re- sponsible for its return on or before the Latest Date stamped below. Theft, mutilation, and underlining of books ore reasons for disciplinary action and may result m d.smissal from the University UN.VERS.TY OF .LL.NQ.S UBRARY AT URBANA-CHAMPA.GN Report No. UIUCDCS-R-72-504 AN INTERACTIVE SYNTAX ANALYZER BY Wayne C. Sanford 1972 Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 61801 This work was supported in part by the National Science Foundation Grant No. US NSF-GJ-328. iii ACKNOWLEDGMENT The author would like to thank Professor J. R. Phillips for the advice and guidance which made this project possible, Mr. M. Ozga for his assistance in using the TWST65 compiler- compiler, and the Center for Advanced Computation and the Department of Computer Science for the use of their resources. iv TABLE OP CONTENTS Page 1. INTRODUCTION 1 2. METHOD OF ERROR DETECTION 4 2.1 Parsing Trees 4 2.2 Insertion of Error Routines 10 2.3 Locating Errors in the String 17 2.4 Interactive Considerations 18 2.5 Examples from 0L2/PARSER 19 3. APPLICATIONS OF AN INTERACTIVE SYNTAX ANALYZER 22 3-1 For the Language Designer 22 3.2 For the Language User 25 4. EXTENSIONS TO AN INTERACTIVE SYNTAX ANALYZER 27 4.1 More Accurate Error Location 27 4.2 Automatic Error Correction 28 4.3 Semantic Preprocessing 28 4.4 Global Syntax Analysis 29 4.5 Teaching 30 4.6 File Editing and Building 31 5. CONCLUSION 32 LIST OF REFERENCES 33 APPENDIX A DOCUMENTATION OF 0L2/SYNTAX 3^ APPENDIX B DOCUMENTATION OF OL2/TWST 42 APPENDIX C DOCUMENTATION OF OL2/SKELETON 65 APPENDIX D FILE MAINTENANCE 84 Figure LIST OP FIGURES Page 1. Syntax definitions and parsing trees 6 2. Ambiguous and unambiguous parsing trees 12 3. Insertion of error routines into unambiguous trees -, c- 4. Examples from 0L2/PARSER 19 1. INTRODUCTION This project is motivated by the problems which face anyone starting to program in an unfamiliar language. The new user is usually not very familiar with either the syntax or the power of the language, but he needs to write programs to discover its capabilities. Surely his anxieties would be lessened if he could seat himself at a remote terminal and have each statement immediately analyzed for proper syntactic content, especially if a concerted effort is made to fully des- cribe his errors to him. A program, 0L2/PARSER, has been developed which allows users of OL/2 , a compact, powerful array processing language, to type their programs at a terminal and receive a statement by statement syntactic analysis for the purpose of determining whether their programs are syntactically correct. The program does not enable the user to construct a file which may be passed to an OL/2 compiler only because 0L2/PARSER and OL/2 are imple- mented on separate machines; however, 0L2/PARSER in its present state has significant teaching value, and continued development could be of further value to the OL/2 project. 0L2/PARSER is maintained using TWST65 (1, 2), a syntax-directed compiler- compiler In use on the Burroughs 6500 computer system. It is the purpose of this paper to show that syntax- directed, recursive-descent compiler-compilers can benefit the software designer and user in more ways than just providing a 2 convenient method of implementing new languages. The paper will show how a representative compiler-compiler can be used to create an interactive syntax analyzer which is of some valuo at its present stage of development and which shows promise of greater usefulness. The techniques and applications discussed are by no means specific to this project and may be used by any lan- guage development project, especially one utilizing syntax- directed compiling. The core of the specific problem is that of identifying and correcting the users' syntactical errors. LaFrance (3) specifies syntactical errors as the third of five levels of errors which prevent a program from running successfully; clearlj some effort should be made to enable the programmer to overcome these errors as easily as possible. LaFrance has developed an algorithm to correct syntactical errors at compilation; this project enables the user to correct syntactical errors as he creates his source program. Usually it is the task of the compiler to detect and identify syntactic errors. Most of the effort in compiler writing is not devoted to identifying and describing syntactical errors, and most compilers scan to some easily found symbol afte: an error before resuming compilation. The result can often be a long series of errors traceable to one previous mistake. The approach of this project allows each syntactic error to be handled separately, with little or no effect upon succeeding statements. Also, since it is devoted to syntactical errors, a great deal of attention is paid to error descriptions. 3 The approach of this project does not provide as thor- ough an analysis of a user's program as a quick-and-dirty com- piler might, but it is certainly easier to code and offers the user the opportunity to correct his errors as they are found. Overview of the Thesis The next chapter discusses how syntactic errors can be determined using recursive-descent parsing by inserting error routines into the parsing tree. The difficulty of locating errors with respect to both the syntax and the input string are described . Chapter 3 discusses the potential value of a syntax analyzer, especially an interactive syntax analyzer, to both the language designer and the language user. The coding and use of such a program offers the designer a rapid and simple means to analyze proposed and alternate syntactical constructions be- fore incorporating them into a compiler, where undiscovered syn- tactic ambiguities may later cause severe difficulties. Such a program can enhance users' understanding of the language, and should provide more rapid turnaround for debugging. Chapter 4 briefly explores other directions which such a project might take. The discussion of finer error location, error correction, semantic checking, teaching applications, and file editing and building capabilities are directed toward the OL/2 project, but are by no means specific. The conclusion is that imaginative use of compiler- compilers can be of significant value in the development of new software . 2. METHOD OF ERROR DETECTION The central problem in constructing a syntax analyzer is developing a method of finding and describing syntax errors. The method used in 0L2/PARSER, with fair success, is that of inserting error routines as alternatives within the syntax of the language. Error messages are in terms of the nonterminals of the syntax, and the series of messages related to an error describe the path taken by the syntax analyzer through the pars- ing tree of the language to the point of the error. This chapte] will discuss that method. 2.1 Parsing Trees Throughout this paper, reference will be made to the pars- ing tree of a language. The parsing tree of a language is the most inclusive tree in the forest of trees which can be construc- ted from the Backus Naur Form or modified Backus Naur Form defini- tion of the syntax of that language. The reader is assumed to be familiar with the basic concepts of trees and the composition of BNF. The definition of language syntax in BNF is not uncommon; for example, ALGOL is usually specified in BNF. Compiler-compile! often utilize a streamlined form of BNF as input (1, 4), and Trout shows that TBNF, which is used in TWST65, is as powerful as pure BNF (1). Appendix A contains a brief description of some of the symbols of TBNF (Figure A.l), some of which will be used in this paper . 5 The process of forming the parsing forest of a language is that of forming a parsing tree for each nonterminal defined in the language. This is done in a very straightforward manner. Nonterminals appearing to the left of the "::=" operator are in- terpreted as the root of the parsing tree associated with that nonterminal. Alternative definitions are interpreted as separ- ate branches of the root . Nonterminals and terminals on the right hand side of the "::=" operator are interpreted as nodes at successive levels of the parsing tree. The node representing a particular nonterminal or terminal is labeled "TESTelement name," for example, TESTK at the top of Figure 1 on the next page. This convention is used because the parsing algorithm will "interrogate" nodes and expect either TRUE or FALSE to be returned. A node will return the value TRUE when it is "interrogated" if the nonterminal or terminal to which it corresponds exists in the string being scanned starting at the scanner location when the node is "interrogated." Otherwise, the value FALSE will be returned. The examples in Figure 1 show how parsing trees are con- structed from BNF productions. is defined as either or ; so TESTK has two branches, TESTL and TESTM. is defined as followed by <0> ; so TESTL has one branch with TESTN followed by TESTO. has three alternate definitions, so TESTM has three branches. The definition of shows how square brackets may be used to simplify syntactic definitions. <0> is defined as <*I>, a symbol from TBNF, which accepts strings of alphanumeric charac- ters with an initial alphabetic character. : := / ; T^TK TESTL TESTM : := <0> ; TESTL I TESTN TESTO ::= <0> / / ; TESTM TESTO TESTQ TESTL I I I TESTL TESTR TESTQ ::= <0> [ / ] /

; TESTN TESTo' TESTQ TESTR TESTP I TESTR <0> : := <*I> ; TESTO I TEST*I Figure 1. Syntax definitions and parsing trees 7 The set of trees formed from all the nonterminal defini- tions in a language is the parsing forest associated with that language. The parsing tree for the language can be considered to be that tree which has the most inclusive nonterminal in the language as its root. All of its nodes are parsing trees in the parsing forest. In the example of Figure 1, is the most in- clusive nonterminal. Most language definitions would use or something similar. (For the purpose of constructing a syntax analyzer as described in this paper, the syntactic unit at the statement level should be used to define the parsing tree of the language, for the method being developed is primarily directed toward interactive parsing at that level (Chapter 2.4).) The parsing algorithm must determine whether the parsing tree for the language has the value TRUE or the value FALSE. The parsing algorithm traverses any parsing tree by in- terrogating nodes in the tree. It interrogates a node by saving information on a stack for continuing the parse after the inter- rogated node returns a value and traversing the parsing tree of the interrogated node. The process of stacking and interrogating continues until some interrogated node looks for particular term- inal symbols, at which time the input string is scanned for the required symbols starting at the last character successfully scanned, and a value, TRUE or FALSE, is returned. The parsing algorithm traverses a parsing tree by inter- rogating its nodes, other than the root, in the following order. Start with the node at the first level of the left-most branch. If a node returns the value TRUE, interrogate the left-most son 8 of that node, except that if that node is a leaf of the tree, return the value TRUE for the tree being traversed. If a node returns the value FALSE, interrogate the brother to trie right of that node. If the node has no brothers to its right, back- track by ascending one level at a time until either a brother to the right is found, in which case interrogate that brother, or all branches from the root have been examined (there are no more brothers to the right), in which case return the value FALSE for the tree being traversed. Note that every time the algorithm is forced to ascend a level, it must re-scan some pre- viously reduced portion of the input string. The parse of any tree is said to be complete if a leaf returns the value TRUE, since all nodes between the root and that leaf must have been interrogated with a resulting TRUE return. The parse is incomplete if the algorithm exhausts the alternatives and returns the value FALSE. The parsing algorithm always starts in the parsing tree of the language; if it is com- plete, a syntactically correct or has been reduced. The parsing tree for the language will be incomplete if a syntax error causes the parsing algorithm to unsuccessfully exhaust all alternatives within it. For example, in Figure 1, TESTK will be TtfUE if either TESTL or TESTM returns the value TRUE and TESTL will be TRUE only if TESTN and TESTO return TRUE when interrogated in that order. As as example of traversal, consider the path taken by the parsing algorithm in reducing the following valid sequence of nonterminals . 9 <0>

<0> TESTK interrogates TESTL. TESTL interrogates TESTN. TESTN in- terrogates TESTO, which returns TRUE. TESTN then Inti 'rogates TESTQ and TESTR, which both return FALSE. TESTN backtracks, so that <0> is no longer reduced, and interrogates TESTP. TESTP re- turns FALSE; so TESTN must return FALSE; so TESTL must return FALSE. TESTK now interrogates TESTM. TESTM interrogates TESTO, which returns TRUE, and then TESTL. TESTL interrogates TESTN, which interrogates TESTP after TESTO returns FALSE. TESTP and TESTR return TRUE, so TESTN returns TRUE, and TESTL interrogates TESTO. TESTO returns TRUE, TESTL returns TRUE, TESTM returns TRUE, and the parsing tree TESTK is complete. The algorithm has done a great amount of work to reduce a string containing four nonterminals. The algorithm would have done even more work in determining that the sequence <0>

is not a valid instance of . After <0>,

, and have been reduced as above, TESTL would interrogate TESTO, which would fail. The algorithm would be forced to backtrack and examine the final two branches of TESTM before TESTM would finally return the value FALSE. In the second example considered, clearly the user should be informed that he has failed to include <0> following the occur- rence of in his string. The next section of this chapter will explain how parsing trees can be modified so that such error rou- tines may be inserted as alternatives within the syntax. 10 2.2 Insertion of Error Routines In a parsing tree for a language as defined in the pre- vious section, a complete parse is associated with a ^syntactically correct statement, and an incomplete parse indicates that a syn- tactic error is imbedded in the input string. What can be done beyond telling the user that an error exists in his input to the parser? How specifically can the error be described to the user? The solution to these problems depends on having unam- biguous parsing trees and knowing the location of the parsing algorithm when it exhausts its possible alternatives. An unambiguous parsing tree is one which has the prope] that, if a node at any level of the tree returns the value FALSE, the parsing algorithm need only examine the brothers of that node and their descendants before returning an answer. In other words, an unambiguous parsing tree is one in which backtracking above the node currently being tested is of no value since all subse- quent alternatives will fail. An ambiguous parsing tree is one which has the property that, if a node at any level returns the value FALSE, the parsing algorithm must examine all remaining nodes at the current level on the current branch, their descendants, and all nodes on any remaining branches before it can return an answer. In other words, an ambiguous parsing tree is one in which the knowledge of what has been previously reduced is of no value. The syntax of Figure 1, and its associated trees, is clearly ambiguous, as shown in the previous section. In the example at the end of the 11 preceding section, the fact that TESTO returned the value TRUE while TESTL was first being interrogated was not useful since TESTM contains a branch with TESTO as the first node. For the ambiguous parsing tree in Figure 2. a on the next page, if TESTJ returns the value FALSE, the parsing al- gorithm would be forced to interrogate TESTE, TESTD, and TESTB (on the right branch), TESTF, TESTG, TESTH, and TESTI before returning the value FALSE for TESTA if the user intended to use the construct in his statement and committed an error. In fact, the parsing algorithm need not have interrogated any further nodes, since TESTC had already returned the value TRUE (otherwise the algorithm could not interrogate TESTJ). Only can follow in the syntax represented. The unambiguous tree shown in Figure 2.b allows the algorithm to stop parsing and issue an error message if TESTJ returns the value FALSE since there is no other path through the tree which begins with TESTB. The message can be that an incorrect occurrence of follows an occurrence of . If the parsing tree for , TESTJ, is also unambig- uous, then a similar message involving the nonterminals or terminals used in the definition of can be produced where the parse failed. The process can continue until the parsing tree for the last node interrogated, which will halt when some incorrect terminal symbol is found, produces the most specific message possible. 12 ::= [ / ] / /

[ / / ] ; TESTA TESTC TESTJ TESTG TESTH TESTI Figure 2. a. Ambiguous parsing tree ::= [ / /

[ / / ] ] / ; TESTA TESTD TESTC TESTJ TESTG TESTH TESTI Figure 2.b. Unambiguous parsing tree Figure 2. Ambiguous and unambiguous parsing trees 13 The syntax of a language will usually contain words and symbols which can serve to make the parsing forest associa- ted with the language unambiguous, or at least make ' ne trees associated with some of the nonterminals unambiguous. For example, in OL/2, a must start with the word "PARTITION". Once the word "PARTITION" has been recog- nized, the parsing is limited to the tree TESTPARTITIONSTATE- MENT. If the word "PARTITION" is found and TESTPARTITION- STATEMENT returns the value FALSE, there is absolutely no reason to interrogate the nodes for the remaining statement types in the parsing tree for OL/2, since no other statement type starts with "PARTITION". Careful examination of the syn- tax of OL/2 shows that each of the twelve types of <0L2STATE- MENT> contains a unique symbol near the beginning of the state- ment type (Appendix A) . The key to locating syntactical errors with respect to the parsing tree of a language with the approach of this paper is finding signpost symbols which identify the user's intention to use a particular syntactic construction. The single most serious drawback to this system is that errors involving the signpost symbols will prevent the parsing algorithm from enter- ing those sections of the parse from which the best messages can be supplied and may force the algorithm into an incorrect parsing tree. For example, "LET" is the signpost symbol for and "SET" is the signpost symbol for in OL/2. The use of "LET" instead of "SET" will cause 0L2/PARSER to issue error messages pertaining to , 14 and the use of "SAT" instead of "SET" will force 0L2/PARSER to consider the string an since "SET" and "LET" are recognized as signposts but "SAT" is considered a variable name. Once the signpost symbols in each nonterminal definition have been located, error routines can be inserted as additional alternatives in portions of the syntax following a signpost. In the example of Figure 2.b, the parse can be modified so that if TESTB is TRUE and TESTC is TRUE the parsing algorithm will expect to find an occurrence of , since TESTC acts as a signpost. If TESTC is TRUE, must follow or a message in- forming the user that has been reduced but does not follow in an intended occurrence of should be produced. Figure 3 on the next page shows how the unambiguous syn- tax of Figure 2 can be modified by the inclusion of error rou- tines. The square brackets of TBNF are used to indicate how error routines are inserted in syntax using that form of BNF. The equivalent parsing tree appears below the definition. Failure of TESTD cannot be used to precipitate an error routine at this level, since the parsing tree from which TESTA is being interrogated might not be unambiguous. If it is unambiguous, the error routine following TESTA will be entered after TESTA returns the value FALSE. Failure of TESTF, however, can cause ERRORCEF to execute since TESTB must be TRUE, a signpost that the user intended to use in his entry. The fact that an error exists and can be limited to the set of currently interrogated nodes in an unambiguous parsing 15 ::= [ [ [ / ] / /

[ / / / ] / ] / ; TESTA TESTERRORCEF TESTJ TESTERRORJ TESTG TESTH TESTI TESTERRORGHI Figure 3- Insertion of error routines into unambiguous trees 16 structure allows the supresslon of all backtracking as defined in the order of traversal (Chapter 2.1). The value FALSE will be assigned to each interrogated node, causing the parsing al- gorithm to empty its stack. Consequently, the discovery of an error will cause the parse of the input string to be incomplete The user will know that there is an error in his input string, the error routines will describe the error to him in terms': of the syntax, but only the one error will be found and des- cribed. Only the use of error correcting routines (3) can enable the parsing algorithm, in general, to continue. 'The method of this thesis is an attempt to positively identify syntax errors. It is the opinion of the author that it is better to give the user as much information as possible about the first error in a statement and stop parsing than to describe the first error, attempt recovery, and take the chance of issuing misleading error messages. One advantage of the use of a stack in controlling the parsing algorithm is that one message can be displayed for each node which returns a value of FALSE as the algorithm is forced back through a series of interrogated nodes . If the nonterminal name associated with each such node is displayed along-side the message the node produces, the user can realize how his input was parsed. The user who refers to a listing of the syntactic definitions of the language he is using can then trace the action of the parser through his string if he does not understand the error. The syntax listing will thus show him how the parsing mechanism reaches its decisions and what it expects. 17 Using the method of this paper, errors may only be described in terms of the nonterminals of the syntax. Errors must be described as a missing syntactic unit following the occurrence of a previously reduced syntactic unit as defined by a more inclusive syntactic unit. The problem is complicated by the existence of large numbers of alternatives in the syntax. In the syntax of Figure 2.b, if the user entered a string in which he intended to use , and if no signpost for were reduced by the syntax analyzer before an error is found, the most accurate error message would be that of ERRORGHI , namely that an incorrect occurrence of either , , or follows the occurrence of

as defined by . Similarly, errors con- cerning very large syntax definitions may be vague, such as "INCORRECT FOLLOWING ' = '», which really says very little. The user must be informed that unin- formative error messages are usually due to incorrect signposts. 2.3 Locating Errors in the String Explaining to the user exactly where in the input string an error occurs is probably impossible, since an error may only force the parse down the wrong branch of some parsing tree, in which case the parse may not fail until it has successfully re- duced some portion of the input string. Consider what happens when a left square bracket, "[", is used instead of a left paren- thesis, "(". The parse will treat the "[" as a signpost. The parse will expect a matching right square bracket. If square brackets and parentheses are used to enclose similar syntactic 18 units, the parse will not fail until it reaches the right paren- thesis. The syntactic error may not always occur simultaneousl with the user's actual error. It is not difficult, however, to indicate a portion of the input string which includes the error. The parsing algorit generated by a compiler-compiler must maintain a pointer to the input string which indicates which character must be scanned once the previous character is reduced. The value of this pointi is easily displayed as a marker under the input string at the appropriate position. 2.4 Interactive Considerations The method of locating errors discussed so far applies to syntax analysis at any level of syntax. It is expected that the actual syntax analyzer will be written using a syntax directe compiler-compiler, since the method involves modifying the syntax Making the syntax analyzer interactive is a simple process on a machine which supports remote terminals, since the software for terminal input/output is usually made transparent to users. Usually all that is required is proper file attribute declaration Interactive syntax analysis does warrant special consid- deration, however. The user's entries will normally be limited to one line at a time, approximately the size of a statement in most languages. The user will obtain the most benefit if the analysis of his entries is carried out at the statement level, since that will allow him to catch and correct his errors almosl as soon as he makes them. If the results of the complete or 19 incomplete syntax analysis are not displayed at the conclusion of each statement, the syntax analyzer will not seem much dif- ferent from a keypunch. In addition, since the sugges id method causes parsing failure back to and including the largest syntac- tic unit defined, it makes sense to keep that unit at the same level as the input in order to easily reinitialize the parsing algorithm after an error has been found. 2.5 Examples from 0L2/PARSER A few examples from 0L2/PARSER should help to clarify the concepts mentioned. The following figure shows some incor- rect OL/2 statements (underlined), an error position marker, and appropriate error messages. (Appendix B documents the syntax of 0L2/PARSER.) LET X BE A FINITE VECTOR SPACE OF DIMENSION (N); < : 'DIMENSIONAL' MISSING FOLLOWING 'FINITE' : INCORRECT ' LET K BE A FIXED SCALAR : INCORRECT X(K) = N***K ; < <0L2FACT0R>: INCORRECT <0L2EXTRA> FOLLOWING '**' : INCORRECT Figure 4. Examples from 0L2/PARSER 20 In the first example, the user had not included the word "DIMENSIONAL" after "FINITE," as required by the syntax of OL/2 (Appendix A). The error position marker, "<", is displayed under the first character not scanned at the time of the error, in this case, the blank between "VECTOR" and "SPACE'.', since the word "VECTOR" is scanned as a single unit instead of a sequence of individual characters. The scanning mechanism scans "VECTOR" from the string, the parsing algorithm compares that unit to the terminal word "DIMENSIONAL", and, since the signpost "FINITE" had previously been recognized, the first message is displayed. The message shows that TESTDEFINITION is the node being inter- rogated at the time the error is found. The second message indi- cates that TESTDEFINITION is being interrogated from TESTNEW0L2- BLOCK. The second message is produced because "LET" is a sign- post for and because the nodes TESTIDLIST and TESTDENOTATIVEPHRASE preceding TESTDEFINITION have been satisfied by "X" and "BE A" respectively. The feature of displaying addi- tional messages as the stack empties is most helpful when errors occur within parentheses, square brackets, or angle brackets, where TESTPL1EXPRESSI0N often occurs. For nonterminals such as which are used in many places in the syntax, knowing from where their parsing trees are interrogated may often be of value. The second example shows that the error messages cannot always be as specific as the first message in the prior example. The algorithm interrogates TESTDEFINITION but can locate no sign- post within TESTDEFINITION ("VECTOR" or ) before it tries 21 to reduce "FIXED". The only remaining alternatives are the words "SCALARS" and "SCALAR", so TESTDEFINITION is g /en the value FALSE, and the error message is forced. The presence of "LET" prevents the algorithm from interrogating the parsing tree of any other statement type. The third example shows error messages from another statement type, . The first message indi- cates that "*" is not a legal operand for the exponentiation operator. The character "K" is not scanned from the string at the time this message is produced. The second message indicates that the parsing algorithm reached, this point by interrogating TESTASSIGNMENTSTATEMENT and TESTCOMPAREEXPRESSION. The second example also shows that errors subsequent to the first error in the string are not found by an algorithm which is forced to fail at all levels by the occurrence of an error. There is no terminal semicolon at the end of the state- ment, but the syntax analyzer cannot find the error since it re- initializes itself and asks for more input after displaying a set of error messages. 22 3. APPLICATIONS OF AN INTERACTIVE SYNTAX ANALYZER 3.1 For the Language Designer This chapter of the thesis will explain of what value constructing a syntax analyzer of the complexity of 0L2/PARSER, incorporating the methods of the preceding section, can be to the language development project and the language user. This subsection is concerned with the development of the language; the next involves the benefits to users. If a design group develops a syntax analyzer as the first step of their project, they can benefit in two ways. First, they will be able to write the version of their syntax which will be most efficiently handled by their compiler. Second, once they have the syntax analyzer, they can use it to preprocess user programs, obviating the need for syntax analysis in the compiler. 3.1.1 Developing Syntax The group which intends to use a compiler-compiler to write the compiler for their language clearly stands to gain insight into how their compiler will operate by building a syntax analyzer using the same compiler-compiler. Developing a comprehensive set of syntactic error messages will necessi- tate the understanding of the string handling and reduction techniques employed by the compiler-compiler and the discovery of the signpost symbols in the proposed syntax. 23 The developers should strive to make the parsing trees for their syntax as unambiguous as possible. This will enable them to produce the most meaningful set of error mess'-es, and will later allow the most precise placement of semantic routines. The first result, production of the most meaningful set of error messages, is evident from the preceding chapter. The second result, precise placement of semantic routines follows directly. Semantic routines, which must maintain a symbol table and emit machine or intermediate code, should be executed as soon as possible after the reduction of their associated syn- tactic units so that they may be accomplished with a minimum of program linkage. Routines in an ambiguous syntax must be delayed until there is no chance of incorrectly processing the syntactic unit in question. In the ambiguous syntax shown in Figure 5> for example, semantic processing of cannot be accomplished at the left-most son of the root because the pars- ing algorithm may be forced to examine its brother or even back- track above that node. In either case, the previous reduction must be undone. There is no such problem in the unambiguous version of the syntax. Semantic processing as a function of can be accomplished as soon as TESTB returns the value TRUE. Those semantic actions which depend on whether , , or

follows must of course wait until one of those syntactic units is reduced. The effort to develop an unambiguous parsing tree for the language will also allow the designer to uncover and correct inconsistencies and repetitions in the syntax. An example of 24 inconsistency would be equivalent syntactic definitions of non- terminals intended to be distinct. Two alternatives with dif- ferent semantic meanings might be equivalent, even though de- fined in terms of different nonterminals. In such a case, a string meant to contain an instance of the second structure would always be reduced as an instance of the first. This problem is most likely to arise when a large number of alternatives are defined in the syntax. The problem would not be evident to a person reading the syntax; however, someone attempting to pro- duce separate error messages for each of the forms would find the parallel constructions when unable to precipitate error mes- sages regarding the second construct. Consider, for example, what would happen if , , and of the syntax in Figure 5-b were defined in the follow- ing way . ::= <*I> ; : := (<*N>) ; ::= (<*N>) ; ::= ' <*I>' / <*I> ; Clearly no string would ever be reduced by TESTE unless the apos- trophes were in fact used to surround the identifier. This prob- lem might not be discovered at the time the syntax is written, especially if this is only a small part of a large, complex grammar . The language designer can also use the syntax analyzer for the language to discover whether strings he intends to be legal are in fact accepted by the syntax he has defined. He will 25 be able to determine the completeness of his syntax. 3.1.2 Syntactic preprocessing The language project which has developed a syntax ana- lyzer can use it as a preprocessor for the language compiler. An interactive analyzer such as 0L2/PARSER, can be easily modi- fied (Chapter 4) to build source files for the compiler which are free of syntactic errors. A similar analyzer constructed to handle complete files can ensure that all source files passed to the compiler are syntactically correct. If either users are required to build their source files using the interactive sys- tem or all source files are preprocessed by a syntax analyzer or some combination of the two previous ideas is used, syntacti- cal error routines need not be included in the compiler. The insertion of semantic routines may be simplified by the knowledge that source input to the compiler will contain no syntactic errors 3.2 For the Language User The language user also stands to benefit from a syntax analyzer such as 0L2/PARSER. He will receive faster turnaround, more thorough syntax checking with better error descriptions, and a better understanding of the language. The user will receive faster turnaround while eliminat- ing syntax errors if his files are preprocessed by a syntax ana- lyzer because the syntax analyzer will use less memory than the compiler, allowing the analyzer to be scheduled more easily in a multi-programmed environment, and the syntax analyzer will be faster than the compiler in searching for syntax errors. The 26 claims of smaller memory requirements and greater parsing speed are predicated on the fact that there are no complex semantic routines in the syntax parser to manipulate symbol tables or emit code. He will receive more thorough syntax checking with better error descriptions because the function of the syntax analyzer is to find and explain syntactic errors, whereas the compiler is primarily concerned with generating executable code. He will receive a better understanding of the language because his errors will be more clearly explained, and because their explanation will be in terms of the syntax. He will begin to realize how the compiler works if he studies his errors and will thus be in a position to more fully utilize the capabilities of the language. An interactive syntax analyzer is especially useful since the user learns of his syntactic errors almost as soon as he makes them. An analyzer which works essentially line by line and ter- minates the parse after finding one error will describe those errors found independently of each other, so one error will not initiate a chain of error messages. The user can be certain that there is indeed an error when an error position marker and some messages are displayed. .11 27 4. EXTENSIONS TO AN INTERACTIVE SYNTAX ANALYZE i Syntax analyzers, as described up to this point, are fairly straightforward, are easy to code using a recursive- descent compiler-compiler, and have limited capabilities. Within the same framework, however, there are several other functions which might be incorporated into the syntax analyzer for a given language at the option of the language designer. The extensions which are feasible for all syntax analyzers include more accurate error location in the string, automatic error correction, seman- tic preprocessing, and global analysis; in addition, teaching and editing capabilities might be written into interactive syntax analyzers . 4.1 More Accurate Error Location It was mentioned earlier that it may be impossible to define the initial incorrect character in the input string. The approach outlined in Section 2.3 is to show the user where the scanning of the input string stopped, which places the error in that portion of the string prior to that point. Incorporating one position marker indicating a point after which the error occurs is not possible in general because the intentions of the user are not known. The initial error may force the parsing algorithm into the wrong parsing tree; consequently, some of the error messages produced will be of no value to the user. 28 It would be possible, however, as the algorithm inter- rogates successive nodes, to save the position of the last char acter successfully scanned when a node is interrogated on the stack with whatever other information is necessary for backtrack- ing through the parse. Then, as the errors pertaining to each unsuccessfully interrogated node are listed, a position marker could be displayed which would indicate that no error had been found at the time the particular node was interrogated. The user might be overwhelmed by pointers if an exceptionally long path through the parsing trees was taken, but the pointers still con- vey information about the parse up to the point of the error. Usually only two or three error messages are displayed under an error, so that the portion of the string containing the error will be made fairly clear. 4.2 Automatic Error Correction LaPrance (3) has developed an algorithm for correcting syntactic errors based solely on the syntax of a language. His method was developed for syntax specifications using Floyd pro- ductions; however, he states that it could be adapted to recur- sive-descent parsing methods. 4.3 Semantic Preprocessing Obviously, semantic routines can be included in the syn- tax analyzer written using a compiler-compiler. The more seman- tic routines included, the more like a compiler the syntax analyze: becomes. The syntax analyzer could be extended so far as to be a quick-and-dirty compiler with good error messages or, even 29 farther, to be the language compiler. The insertion of a full complement of semantic routines into a structure such as defined in this paper, which contains error routines as alte latives in the syntax, would undoubtedly be a tricky problem. Also, the resulting program would become very large and unwieldy. Although the objections to trying to do everything in one program are many, there are good reasons for putting limited semantic routines into the syntax analyzer. There are some se- mantic problems which are so easy to catch that including the routines necessary to find them would be simple. This group of problems includes insuring that identifiers are used con- sistently with their definitions and checking for proper block structure . In OL/2, for example, variables may be declared as scalars, vectors, matrices, or higher dimensional operators. Operands cannot be arbitrarily combined in an expression because they may violate the rules of matrix algebra. Some of the pos- sible errors in expressions can be classified as syntactic; but with dynamic arrays most errors would be semantic. A simple symbol table maintained by the syntax analyzer with a list of attributes would allow it to determine a more inclusive set of syntactic errors as well as some semantic errors similar to those mentioned above. 4.4 Global Syntax Analysis Syntax analyzers as defined to this point in the paper can be considered "local" syntax analyzers since they are con- cerned only with detecting and describing errors at the statement 30 level. Higher level, or "global", syntax analysis would in- volve errors at the block or program or other defined levels. A syntax analyzer could be programmed to continue ana_ysis at each higher unit level upon deciding that a new input string caused no error at the current level of analysis. The user would then discover after each statement whether it affects the syntactic structure of other levels of the program. Alternatively, an analyzer could be programmed to examine a user's source file for "global" syntactic errors after the final statement is entered. This would not allow the user to realize the full effect of each statement as he types it, but it would allow him to worry about only one level of syntax at a time . 4.5 Teaching An interactive syntax analyzer, such as 0L2/PARSER, could easily be appended to a teaching routine for the purpose of evaluating student responses. The teaching program could be one that leads the student through the features of the language, or it could be programmed to respond to student questions about various features. In either case, since the teaching routine would ask the student for particular types of statements, the parsing trees of the syntax analyzer could be modified to require inclusion of expected "signpost" symbols, thus enabling even better descrip- tion of student errors than with the previously developed syntax analysis techniques. 31 4.6 File Editing and Building An interactive syntax analyzer which is implemented on the same machine as the compiler for the language can easily build a file of the statements entered into it. A better pro- cess would be to build a file of syntactically correct state- ments entered into it; that file could then be passed to the compiler if the user desired. The most elegant possibility is that of providing editing features in the syntax analyzer. With the capabilities of adding and deleting characters and lines from a disk or memory file available, the user could create a source file for the language, enter statements, cor- rect syntactic errors as they are found, alter previously entered statements, and add and delete statements to and from the file. When the user is satisfied that he has constructed a complete program, he can pass it to the compiler and be cer- tain that it is free of syntactic errors. 32 5. CONCLUSION This paper has shown that the language development pro- ject using a recursive-descent compiler-compiler can use that vehicle to thoroughly test the syntax of its language, to separ- ate the problems of handling syntactic errors from the problems of semantics, and to create a syntax analyzer that can be of significant value to the users of the language. The compiler-compiler can be used to develop a syntax analysis algorithm which can locate syntactic errors and des- cribe them with a fair degree of accuracy. The syntax analyzer can be coupled with as many other functions, including automatic error correction, semantic error detection, teaching, and file editing and building, as desired. This approach is limited primarily by the limitations of syntax-directed compilers, which have not been discussed; however the approach, if used with imagination, can produce many worth- while results . 33 LIST OP REFERENCES (1) Trout, H. R. G., "A BNF Like Language for the Description of Syntax Directed Compilers," Report No. 300, Department of Computer Science, University of Illinois, Urbana, Illinois (January, 1969). (2) Trout, H. R. G., "TWST Users' Manual" (preliminary draft), ILLIAC IV Project, University of Illinois, Urbana, Illinois (January, 1971). (3) LaFrance , J. E., "Syntax-Directed Error Recovery for Com- pilers," Report No. ^59, Department of Computer Science, University of Illinois, Urbana, Illinois (June, 1971). (4) Gaffney, J. L. , Jr., "TACOS : A Table Driven Compiler- Compiler System," Report No. 325, Department of Computer Science, University of Illinois, Urbana, Illinois (June, 197D. (5) Abel, N. E., "The Little Golden Book of the B6500," ILLIAC IV Project, University of Illinois, Urbana, Illinois . 34 APPENDIX A DOCUMENTATION OF OL2/SYNTAX OL/2 is currently implemented only on the IBM SYSTEM/360 MODEL 75 in the Digital Computer Laboratory, where it is main- tained using TACOS (4), a PL/I based compiler-compiler. OL2/ PARSER, an interactive syntax analyzer for OL/2, is implemented on the B6500 currently in the Coordinated Science Laboratory. It is maintained using TWST65 (1, -2), an ALGOL based compiler- compiler, as documented in Appendix D. The file 0L2/SYNTAX defines the syntax of OL/2 in the metalanguage of TWST65, a modified form of BNF called TBNP, as described by Trout (1, 2). It is constructed directly from the IBNP listing for the generation of OL/2 by TACOS dated May 1, 1971- It is as consistent as possible with the IBNP definition; although the norm declaration feature, which is not defined, is omitted entirely, and the definition of <0L2/LEPTHANDSIDE> is somewhat simplified. Any differences in character use are due to the different character sets on the two machines, and to special characteristics of some symbols on the B65OO. For example, the characters '[' and ']' are used in place of ' |_' and '__| ' respectively. Also, the symbol '#' is used instead of '%' to surround PL/I statements and the "" symbols around 'NULL' in are not used be- cause the characters '$' and ' ,M have special string handling meaning to the B650O system. 35 Figure A.l defines the reserved symbols used by TWST65. The usage of most of these symbols should be evident from their usage in 0L2/SYNTAX; the following examples should el3 Inate any confusion. Usage of '%' In the definition of , 'CONCATENATION ALLOWED HERE' is a comment since it follows '56'. TWST65 ignores everything following a '#' character in a line. Usage of '#' In the definitions of and , 'OPERATOR' and 'ON' are defined as terminal symbols since they follow a '#' character. 'OPERATOR' and 'ON' are normally re- served words . Usage of and BUT The definition of uses , BUT, '#', and '*' to cause any string of characters surrounded by '#' symbols to be accepted as a . 0L2/SYNTAX is maintained as described in Appendix D; a listing follows Figure A.l. 36 TABLE OF TWST65 RESERVED SYMBOLS USED IN OL2/SYNTAX TWST65 SYMBOL MEANING / > * [ ] % # LIST SEPARATOR <*I> <*N> <*R> BUT 'Angle' brackets used to surround non- terminal names Is defined as Separates alternatives within definition Terminates definition Optional element ? ::= / empty; Kleene star * ::= empty / * 'Square' brackets used to delimit groups of elements to be treated as a unit Stop scanning this line Use following reserved symbol as terminal symbol LIST : := * ; LIST SEPARATOR ::= []* ; Identifier scanning atom Unsigned integer scanning atom Unsigned real number scanning atom Any character Modifies preceding construct to exclude following construct Figure A.l. Table of TWST65 symbols 37 pl2 SYNTAX AS DEFlNEO F UK THE 0L2 INTERACTIVE SYNTAX PARSER THr STNTAx IS WRITTEN IN TBNF (TRANSLATABLE BACKUS NAijR FOKM) AS DESCRIBED IN DC* RtPORT NO. 300, «A BNF LIKE LANGUAGE FOR THE DESCRlPTlUN OF SYNTAy DIRECTED COMPILERS"* PY H. q. q. TROUT. TkNF IS ThE INPUT LANGUAGE FOR ST65. A COMPILER-COMPILER ON THE H6SO0 SYSTEM CURRENTLY IN CSL« THTS HlE IS A DIRECT TRANSLATION OF THE SYNTA< OF OL/2 AS WRITTEN IN IhNF FOR TArOS' EXCEPT WHERE DIFFERENCES IN THF CAHARAcTER SET NEcESSI T A TED CHANGES. <0l2PK0GRaM> ti» LIST ; Ma / <0L2STATEMENT> I »»« ft KAny> RUT ## I* *# I <0L2s'i'ATEMEnT> »*■ ? t// ///<0L2lFS>/ <0L2I0STATEMENT>/<0L2FURSTATEMENT>/<0L2lTERATIvErLAUSE>/ //< ASS I GNMt NT STATEMENTS I h» r <*i> » i* t l»» LIST < I OENT I FIERDECLARAT ION> SEPARATOR #1 I :t= ? > «|a LET / DEFINE / DENOTE BY I T> |I- LIST SEPARATOR J it" TO? [BE / DENOTE ]? [ AN / A / THE J? 1 tl = ? t FINITE DIMENSIONAL I? VECTOR [ SPACES / SPACE ] QF DIMENSION C »? t WI T H / WHICH t HAS / CONTAINS ) AS ]? THE [ ELEMENTS / ELEMENT'/ MEMBERS / MFMBER ] [ A / THE 1? ? C VEC'ORS / VECTOR 1? ]? / i///]*

? r [/]? ? ? ? ? / v ] / SCALARS / SCALAR ; I la ( ) ; |H C WHICH t ARE / IS A ]]? C SEQUENCES / SEOlJtNcE 3 OF? ? / J Its OF? [ MODULUS / MOD ] ( LIST <*N> SEPARATUR » ) OF? | t:= I <*N> / fll / TRI 1? -? LINEAR j XCONCATF.NAT I ON ALLOWED HERE n> ( LIST [ / / / ] ) I 38 It. REAL / COMPLEX / CPLX 1 n». BINARY / BIN / DECIMAL / DEC ; U* FLOAT / FIXED J «» = ( l I ST U+/-J? <*N>) SEPARATOR » ) ) U* ? t ARRAYS / ARRAY / MATRIX / MATRIct-S / OPeRAT ok S / #UPLRATOR / OP ] ? / C VECT U RS / VECjOR / VECS / VEC ] » U= IDENTITY / IDENTITIES / IDENT > 11 = [ WITH / DF 1? C BFIUNDS / BOUND / HRDER ] ( <80uNDPAlREXpRESSH.)N> ) > »j= [It IJPPFN / LOWER ] DFF? ]? DIAGONAL i? [ BLOCKS / BLOCK I OF <*I> } m° *0N <*I> / FROM (? LIST SEPARATOR X )? t INTO / TO / ONTO 1 (? LIST SFPArATOR * )? / [ ELEMENTS / ELEMENT / MEMBERS / MEMBER ] [ OF / IN] THE? VEcTDR? SPACE? <*I> i »|* ( <*!> ) / <*!> > t»= END <*i>? #> i ,.= LIST sEpARATOR » C » / #<- ] #> I
    Ms / J <0l2AkITHmETICEXprfSSIUN> j:= LIST <0l2TFrm> SEPARATOR l*/"} i <0i.2TtRn> tj= LIST SEPARATOR »* I <0t.2()JiVIUE> «« = [ #/ I < mUDlF IEDEXpRESSl ONijNI T> / / ]]* J u = <0L2PRlMARY> [ **«* <0L2EXTRA> ]? J <0| 2EATRA> |t s [ / ) t **** <0L2EX1RA> 1? ; <0|_2pKl M ARY> l« = / / ; 11 = [ + /-)? ( ) •? 1 M = [ + /-]? t *t tfj J? t LIST [ *< LIST -39 SEPARATOR . #> ]]? •? I <0l2IUENTtFIDR> II* <*!> J lis (♦/-!? I |l* ( !♦/-]? ) / / / / I ««« LIST SEPARATOR [-#>] 1 n« LIST <(JNQUAL> SEPARATOR , ) it* <*I> t *[ #] ]? •? [ LIST [ #< ilSJ SEpAhATdR »#>]]? t ( LlSj SEPARATOR » ) J? I | la ( <*R> / <*N> ] [ E [♦/•] <*N> I? ]/ I in |l <0L2ARITHMETICEXPRESSI0N> II j t»« ( » <0l2ArIThMET!CEXPrEsSIUN> ) I Ma INTERCHANGE ANo C IN / #ON / OF 1 #1 I H* PARTITION AFTER LIST SEPARATOR ( » / AND 3 I AND A F TER? LIST SEPARATOR I » 1 AND ]]? t\ I ||* ROWS / ROW / COLUMNS / COLUMN / COLS / C^L J |t> LIST SEPARATOR J lis SET LIST SEPARATOR [ SET? ) t\ I II* It EQUAL? TO? THE pART Of I / I EvJUAL / = / tO l 1 I lis
    ? [ SCALAR / [ ROW / COLUMN / rOL I t VECTOK / VEC 3? / MATRIX ]? ; It* <*T> t *[ «1 1? f #< LIST SEPARATOR ,#>]*» II* <*!> t #[ #] ]? j t|* BLOCK? TKI? I DIAGONAL / DIAG ] / [[ STRlCTLT / St / S I? If UPPER / LOWER ]? C TRIANGULAR / TKIANq J / 40 [ UT / U.T. / LT / L.T. J]] / t SYMMETRIC A SYM ] / [ SELF t ADJOINT / AIJJ I / [ RECTANGULAR / REC / SQUARE ]J I ij= [ PRINT I L) TAhLE / PRINT TREE NOOtS / NOnE PRINT OFF / TRACE fUN / TRACE OFF ] *l I <0l 2 P ku CEdUrESTATEmFnT> s:= C MAIN / RECURSIVE / REENTRANT 3* t PROCEDURE / PROC ] i ( LIST SEPARATOR • ) ]? *J » t J= #*? <*T> > <0t.2lFS> »j= IF <0|_2rOULEANExP> THEN [ ELSE ATEnENT> 3? j <0l 2 BUUlEaNEXP> U= LIST SEPARATOR I J »« a L*ST < lOOLE ANFACTOR> SEpARATUR «& J »« = ( <0L2rU0LE ANf XP> ) / "•< qOOLE ANf Ac TU»> / [ cCHMP AREEXPRtSS 10N> I? ; t:= #>= / *<= /-,?[ = /*] j t; = »* / NULL / <0L2ArI THMETI CE J <0l.2IUSTAtEmENT> :j= r INPUT / OUTPUT ] #> > u= list < io I d> SEPARATOR t t j= <*i> i
      il- fur = ? #> ; il= <*I> \ JS= <(|NIT> » LIST SEPARATOR * *'l .. .? \ t« = ; U= [ WHILE / OR? UNTIL ] <0L2B0f]LEANFxP> I <0|.2ITERAtIvECLAUSE> «» s *\ i Hi l|a LIST [ <*N> / C [♦/-]? <*N> I [♦/-]? <*N> ) ] SEPARATOR it I lis • ANO? / ANO » lt B LIST SEPARATOR t ♦ / • ] I »»* LIST SEPARATOR [#*/#/] ;

      us I #*** ]? / [♦/-] J H« ( ) / / I ««* LIST SEPARATOR t-*>3 I |l« LIST SEPARATOR . \

      ,,x <*I> t ( LIST [ / f* ] SEPARATOR , ) ]? I |la [ <*R> / <*N> ] [ E [♦/-] <*N> ]? ; rNO» 42 APPENDIX B DOCUMENTATION OP OL2/TWST The TWST65 compiler-compiler available on the B6500 uses two input files, known internally to TWST65 as SKELETON and CARD. The SKELETON file contains the basic routines for the compiler to be generated, including I/O and string, stack, and table manipulation. The CARD file contains the syntactic definitions and semantic routines which define the language involved. TWST65 produces an ALGOL source file called LANGUAGE? NAME/SOURCE by concatenating procedures to parse the language developed from the file CARD and the procedures contained in the file SKELETON. This ALGOL file is then compiled, yielding the final program. 0L2/TWST is the file equated to the CARD file in the generation of 0L2/PARSER. Since 0L/2TWST gives '0L2' as the language name in the second line, TWST65 produces the ALGOL source file 0L2/S0URCE, which is compiled as 0L2/PARSER (Appen- dix D). 0L2/TWST is written in TBNP (1, 2) to define a parsing algorithm which will accept correct statements as defined in 0L2/SYNTAX (see Appendix A) and describe errors found in incor- rect statements. The purpose of this appendix is to explain the specific constructs used in 0L2/TWST, especially to those who may wish to modify 0L2/PARSER in the future. 43 For those who are not familiar with TBNF, Appendix A contains a brief description of that form of BNP. The "TWST User's Manual" (2) is the best source of information ■ garding how a parsing algorithm produced by TWST65 will be affected by the use of various features in TBNP. TWST65 is normally used to generate compilers; however, it served very well in generating 0L2/PARSER. There are no semantic routines in the usual sense in 0L2/TWST, for 0L2/PARSER is concerned solely with the recognition of proper OL/2 state- ments. There is no definition of because an OL/2 program, syntactically, is only a list (to use TWST65 terminol- ogy) of OL/2 statements. Future modifications to 0L2/PARSER could very well include semantic procedures to incorporate fea- tures as described in Section 4 of this thesis. Errors and Other Messages Those sections of 0L2/TWST which have the form of seman- tic routines are almost exclusively concerned with displaying appropriate error messages. There are approximately one hundred and fifty separate error messages and another dozen messages identifying statement types. They are all encoded as semantic routines which write the appropriate format to a file named STATION. For example, ::= @S[USEPOINT; WRITE (STATION, F0101);]; causes the message in F0101,- : TERMINAL ';' MISSING , 44 to be displayed. USEPOINT is a procedure contained in 0L2/SKELET0N (Appendix C) which displays an error marker under the first character not scanned when an error is found. All of these message-producing routines are defined as nonterminals; the error routines are all alternatives within the syntax. Consequently, they are treated exactly as the syn- tactic nonterminals are treated, except that they are always satisfied unless action is taken to cause the parse to fail. It is desirable to cause the parse to fail to prevent one error from precipitating a large number of subsequent non-informative error messages. Consider, for example, what would happen if the following string were parsed as a if errors did not cause the parse to fail. A - ( B*/C) The routine would expect a following the "*". The "/" does not parse as a , but an error routine () would satisfy the parse. Since the parse did not fail 'C would be examined, and because 'C is not an operator symbol, the parse would expect a closing parenthesis. would satisfy the parse at this point and the ')' would be examined. The parse would continue spewing forth error messages until it ran out of input. Therefore, all error routines except those concerning terminal semicolons are of the form ::= @T[USEPOINT; WRITE(STATION, Fxxxx);]; . When TWST65 inserts the ALGOL code from an ' @T' semantic routine 45 into 0L2/S0URCE, it provides code to cause the alternative con- taining that semantic routine to fail if a Boolean variable called SEMANTICTEST is FALSE at the conclusion of the : utine. USEPOINT always sets SEMANTICTEST to the value FALSE. Conse- quently, most of the error routines cause the parsing algorithm to examine the next alternative in the syntax. The effect of the above is to produce a series of error messages related to the first error found. The error messages begin with as specific a message as possible and continue until the most general message concerning the error is displayed. The effect is to indicate the path taken by the algorithm through the parsing tree to the point of the error. After the algorithm backtracks to produce the most general error, all subsequent alternatives are preceded by a semantic routine of the form @T[ SEMANTICTEST := USEPT ; ] ; , which prevent the algorithm from examining any following alter- natives. Eventually, the parse will fail without attempting to locate any further errors. Semantic routines of the form @T[ SEMANTICTEST := USEPT ; ] ; prevent the algorithm from examining the alternatives they pre- (cede since USEPT is set to the value FALSE by USEPOINT when an error is found and is not set to the value TRUE until the next line of input is accepted. This semantic routine is used through- out 0L2/TWST for the stated purpose. For example, in the defini- tion of <0L2STATEMENT>, each of the last eleven alternative 46 statement types are preceded by this semantic routine. Thus, if an error is found in a , the last ten alternative statement types are never examined. Other Constructs in 0L2/TWST The remainder of this discussion will cover various syntactic definitions in 0L2/TWST in the order in which they occur in the listing. The definitions chosen will illustrate features that are not straightforward; they usually offer in- sight into the workings of TWST65. is included as the first alternative in so that the entry of the word 'FINISH' at the terminal will cause 0L2/PARSER to terminate as quickly as possible . Labels may occur before any statement. When an identi- fier string followed by a colon is found, the semantic routine sets bit 46 of the first word in the table entry created by TWST65's table building routine to indicate that this identifier is a label. The table maintained by standard TWST65 routines, contained in 0L2/SKELET0N, and the use of the variable 'PI' is discussed. in Trout (1, 2). This method does not allow for catching duplicate labels, although it could be expanded to insure that the same identifier is not used previously as a variable (see ). 47 is placed immediately following so that the user will learn as soon as possible when 0L<- PARSER considers his entry to be a . The same strategy is used for each statement type. All possible combinations are spelled out since the string handling procedures used in OL2/PAKSER expect defined words to be delimited by non-alphanumeric characters. They will not recognize 'BILINEAR' as 'BI' followed by 'LINEAR'. The character 'X' is used instead of 'x', mathematical multiplication operator, because of character set limitations. Since 'X' is alphanumeric, 'AXB' is not equivalent to 'A X B'. The use of optional parentheses around LIST'S of , and the possibility of parentheses around the <*I> in prevents 0L2/PARSER from recognizing all correct constructions, since the first parenthesis found is always assumed to be the optional left parenthesis. Thus, FROM (A) X B INTO C will not be accepted, although syntactically correct. The right parenthesis is parsed as the optional right parenthesis, so the parse expects 'INTO' or 'ONTO' or 'TO' when it reaches 'X' . 48 This nonterminal is introduced to reduce the amount of typing, although it does introduce one complication (oee ) . This nonterminal contains the semantic routine to mark the identifier table for correctly declared new identifiers. Future modifications to this routine should probably include marking different bits for different types of identifiers. The available bits accessible through 'TABLE[P1] T (see (2)) are the six high order (42-47) bits of the initial table entry. This nonterminal contains the semantic routine which checks to see whether a given identifier has been previously declared in a , , or <0L2P0RSTATEMENT> , in which is used. Future modifications should probably include testing routines to see if identifier usage is consis- tent with identifier declaration (discussed above). ', AND? / AND' is used instead of in this produc- tion because, in a statement which partitions after both rows and columns, the single word 'AND' must separate the row and column designations. If were used in the previous SEPARATOR construct, the word "AND" would always be reduced to , and the word would not be recognized, causing the parse 49 to fail whenever a double (row and column) designation is used. The series of 'NOT terminal' 's serves to condition the SEPARATOR so that the word 'AND' separating row and c umn designations will not be reduced as a separator in the preceding list. <0L2F0RSTATEMENT> The integer variable ALTERNATIVE is given the value '2' before scanning for to suppress the message of if is indeed found. <0L2ITERATIVECLAUSE> Since this nonterminal is nothing but a followed by a semicolon, there is no use in constructing an equivalent definition and set of error messages. ALTERNATIVE is given the value '1' before scanning for so that will display the appropriate statement type message. <0L2B00LEANEXP> [| ]* is used instead of LIST SEPARATOR | because the second form would not force the algorithm to find a following a ' | ' character or produce an error. The second form would lead the parse to identify the ' | ' as an incorrect syntactic unit following a correct <0L2B00LEANEXP> , since the LIST-SEPARATOR construct does not consider an occurrence 50 of a separator element to be a separator until the following list element is successfully found. The first form at least will yield a message placing the error after the previous ' | ' . A similar approach to errors following separating symbols is used in , , <0L2ARITHMETIC- EXPRESSION> , and . 1 #< NOT - NOT = ' is used in the third line so that '<-', a replacement operator in , and ' <= ' , a comparing operator in <0L2B00LEANEXP> , cannot be con- sidered the '<• at the beginning of a subarray designation. RESERVE Usually TWST65 reserves all defined words (alphanumeric strings beginning with an alphabetic character) found as ter- minals in the syntax for a language. Reserved words will cause the identifier scanning atom, *I , to fail. 0L2/TWST contains such defined words as 'A', 'I', 'E', and 'X', which are commonly used as variable names. Inserting a line 'RESERVE ; ' just before the 'END.' line in 0L2/TWST would prevent TWST65 from reserving any of the defined words found in the listing. If this were done, however, the keywords which are specific to the various state- ment types would be recognized as identifiers during the scan for , and would not be recognized to direct the parsing algorithm. 51 Inserting a line 'RESERVE word list', as in 0L2/TWST, causes only the words in the list to be reserved. The word 'END' cannot appear in this list because of a bug ir TWST65, but another bug in TWST65 causes the first word following the reserved words in the identifier table built by TWST65 to be reserved also. Therefore, is placed before so that 'END' is the last word defined and the first word after the reserved words. REMARKS ON ALTERNATIVES It is often important to consider the order in which alternatives are listed, for once the parsing algorithm re- duces a portion of an input string to a particular nonterminal, that portion of the string is never again examined. Backtrack- ing can succeed only if subsequent alternatives specify the same nonterminals in the same order over that portion of the string . For example, if a production contains the alternatives ( <0L2ARITHMETICEXPRESSI0N>' ) / ( , ) then the string "( A*B , C/D )" will not be parsed as the second alternative since "A*B" reduces to <0L2ARITHMETICEXPRESSI0N> before the "," fails to parse as a ")". 52 INSERTION OF SEMANTIC ROUTINES Approximately half-way through the listing of 0L2/TWST, which follows this discussion, an 'END;' line separates the syntax and inline semantic routines from the format declarations for 0L2/PARSER. TWST65 uses everything preceding the 'END.' line in generating the parsing algorithm of 0L2/PARSER. Anything following the 'END.' line is inserted into the ALGOL code file 0L2/S0URCE produced by TWST65. Large or often used semantic routines may be inserted in this manner; for example, USEPOINT (discussed in Appendix C) could have been placed after the 'END.' line rather than in 0L2/SKELET0N. Large semantic routines must be handled in this manner, since TWST65 enforces a limit on the length of inline semantic routines. If the TWST65 generated variables FIRST, LAST, or any of the related PMx or Pxx variables (2) are needed, then the semantic procedure must be called from within a short inline "@S" or "@T" semantic routine. Also, more efficient procedure linkage will result if semantic procedures are placed after the 'END.' line than by defining them as nonterminals within the syntax, since TWST65 will not set up all the tests associated with nonterminals. FILE LISTING The file 0L2/TWST is maintained as shown in Appendix D; a listing follows this page. -53 S r*« u LIST SYNTAX nL2 »»s / / <0L2STATEMENT> H> lis FINISH PUt FINISH I* TRUE I 3 I «* a *# 1 BUT »* J* ** I <0| ZSVATEmEnT> Its [ / PT[ »T[ PT[ • T[ *T[ pti «TC pT[ PT[ PT[ ■ Tl SEMANTlCTtST SEMANTlrTE-ST SEMANTlCTtST SEMANTlrTEST SEMANTlCTEST SEMANTICT^ST SEMANTICT^ST SEMANTlCTEST SEMANTlCTEST SEMANTlcTtST SEHANTlCTtsT t la [ <*!> / / <0L2IFS> / <0L2I0STATEMENT> / / <01_2ITERATIVECL.AUSE> / <0L2pRncEDl)RE STATE Mt USEPT I 3 IS USEPT J ] t* USEPT I 1 ja USEPT ) l is USEPT ; ] 1* USEPT ; ] 1* USEPT J 1 13 USEPT ; ] la USEPT J 3 »■ USEpT I 3 13 USEPT I ] II s LIST £ f> / 3 »

      ( ? [ / 3 ? I 1j= LET / DEFINE / DENOTE 8Y J |l= LIST r / ] SEPARATOR < lis TU? I BE / DENOTE ] C AN / A / THE ti = ? [ FINITE [ DIMENSIONAL / VECTOR I SPACES / SPACE / 3 [ OF / / T> / / NT> / > 1 I I ND> / ] ANO> I 3? I ]3? 3 ERS / MEMRER ECTOR 3? 3? EX> J* U> 3 > ES / 13 l DIMENSION / 3 [ / ] ,? [ WITH / WHICH [ HAS / CONTAINS / 1 AS / J]? THE [ ELEMENTS / ELEMENT / MEMri 3 [ A / THE 3? ? C VECTORS / V / / / ? [ [ / 3? ? ? ? ? / ? 3 / flT[ SEMANTlCTEST la USEPT J ] SCALARS / SCALAR I lis ( [ AlKFXPRESSIUN> / 3 [ ) / jls [ WHICH [ ARE / IS A / 33? £ SEOUENC SEQUENCE 1 Of-? ? /»TC SFMANT I CTFST I aUSEP • »l» DF? [ MODULUS / MOD 1 C ( / < E 1 1 6 > 3 list c / 3 separator » [ ) / 3 OF? I 11= LINEAR / BILINEAR / TRlLlNEAR / <*N>LINEAR <*N>-LlNEAR / BI-LlNEAR / TRI"LInEAR ; t:= C LIST [ / ] [ ) 11= / / ; l|" ? [.ARRAYS / ARRAY / MATRICES / MATqiX / OPERATURS / -OPERATOR / OP 3 ? / t VECTORS / VECTOR / VECS / VFC 3 i«= IDENTITY / IOENTITIFS / IOENT S I la RFAL / COMPLEX / CPLX I II, BINARY / BIN / DECIMAL / DEC J / ] I TORFlXED> / 54 t < wSK)N> t < *UF> i i [ B t INASpAc / P frh )? (? / » r f THE lis » tID> >t t * r * V> I | = *IO> *l *S[ D> « t t I* ( *N> / ll* ( NBYN> = [[ LOCKS F / < E> U T[ SE M (? C INT LIST Tt SE LEMEM ? VEC ANn? s ( [ 142> II 3 C [ < ER> i C t < <*I> = <*I = FLOAT [ + / " WITH / / 3 s tfriN [ MANTICTE LIST t < o / onto C IF TAHLEC PT I" RFPLAC IF TAb replac else, r write » [ ♦ / - j? ORDER 3 / FIXED j ]? [ <*N> / ] [ ]]?[)/ ] I nF i? [ Bounds / bound / 5> ] J / LOWER ] OFF? 3? DIAGONAL ]? / 3 [ / ] [ / ] ; / -j ST J= USEnT I I SPACEID> / I SEPARATOR X / TO / ] ID> / ] SEPARATOR X )? ST 1= USEPT » ] MENT / MEMBERS / MEMrER ] [ Of / CE? [ <*!> / ] j iN / J D> / 3 [ ) / ) / / ID> / ] SSI0N> / ] [ #3 / 3]? I «ID> / 3 S S 1 (1 N > / 3 t *] / ] ]? > EtPlLCAf ill l= 1 | 3 ; TAHLEtPll.Unn = O THEN BEGIN PI ).[47ll ] Is 1 J POINTERC IDNAMECO] ) + 10 I E PT BY " " FOR 26 I LE[P1 ] .COMNTFIELI) LEO 26 ThEN E PT BY PnlNTER(TAHLF[Pl + 1]) FOR TARLECP1 ] .COUNTFIELO EPLACL PT BY PO I NTERf T ArtlE [ p 1 + U) FOR 26 I (STATION. 12. IdnAMEI*!) i END 13; |i= PARTITION r / ] f AFTER / 3 t / 3 L^ST [ / NOt AFTER Not ROw NUT ro NOT COL 1 [ AND AFTER? [ LIST [ / [ ni / 3 i l»= ROWS / RO* / COlu M NS / COLU M N j:= list r / ] ] SEPARATOR [ [ » AND? / ANn S NUT COLUMN NOT COL.UHNS N 0T COLS / J 3 SFPARATUR 3? 55 / ] SEPARATOR / TRIUIAG 1 / t t *< NOT ■ ] LIST [ r #> / n* * «»■ block? t diagonal / tridiagonal / oiag [[ strictly / s. / s ]? tr upper / lower ]? [ TRIANGULAR / TRIANG ] / [ IJT / U.T. / LT / [ SYMMETRIC / SYM ] / SELF [ ADJOINT / AOJ / ] / t RECTANGULAR / «EC / SQUARE ] J L.T. ]]] »:= INTERCHANGE r / ) C / I [ ANO / ] [ / 1 [ jN / OF / *ON / ] [ / ] I #1 / ] ; <0l 2 I*'S> i»= IF t / ] [ ThiF.N /) [ / ] [ ELSE C / ]]? I <0l 2 I u STAtEhENT> «:= t INPUT / OUTpUT ] C / ] [ «l / 3 J ■ »« = LIST [ / 1 SEPARATOR # I j U > <0i.2FURSTATEMENT> |t> FOK [ / ] [ * / I [ /" ] PQ[ ALTERNATIVE ',= 2 » ] ? C #> / J J »! = j its r / i t / ] [ [ , NUT [ .. / ].*.?t / ] ::=» ; [ » / ] ] [ < ijN I T> / ] 1* \ <0| 21 IERATlvECLAUSF> :«= »Ql ALTERNATIVE 1= 1 j] [ tl / ] I l«= C WHI L E / OK? UNTIL 3 f / ) I <0l28U0LEaNEXP> I : 3 [ / ] t r I NOT I 1 t / ] ]* I <8 n UL L ANTFRM> «' = r / ] [ #ft t / ] 1* I <8n0LLANFACT0R> :i= ( I <0L2R0UlE ANE XP> / ] [ ) / ] / • Tt SEMANTICTEST »■ USEpT J 1 - [ / J / »Tt sE M ANTlCTEsr » = UsEPT J 1 I / 1 f C / ) ]V J t:« *>» / *< = / ->? [=/#>/*< ] i M= *P / NULL / I «:= [ PRINT [ ID I TABLE / J / £ TREE / ] t NODES / ]] / NODE [ PRINT / ] [ OFF / ] / TRACE [ «ON / OFF / ]) [ #j / ] » <0l 2 P k UCE0UrESTATFmEnT> :«= [ MAIN / RECURSIVE / REENTRANT )* t PROCEDURE / P^no ] f ( LIST [ / ] SEPARATOR . C ) / ]]? t #J / J * j»3 «*? [ ] ) 56 iEF> t .> I « = [ * r t se> t t US <0 L 2LtF R| < 1. 2 A « I <0l 2 T^R <0| 2D1V <0l2FAC <0i_2E*T <0l 2 p^i : j IOF> TUR> t * RA> J r # MARY> t 1 = PT[ aTr < C n N S .i A r : r < 'Ronuc t ) : j= 3 = / T> : : = / !!■ # [ = EEXPHES Its PVJ[ ASIC^EF QUAL> [ Kln> LlFXPRE T - NOT . t *> If ALT L2ARITH t ) ESSTUN> 3* I mviUE> L2FACTU <0L2PHI THmFUC fTfp> I r> '? RESSlUN > / TlcTESi TICTEST TlCTEST TlCTtSF L2ARI1 H 12A1> J *R> / < ( r < u 236> ] 23R> ) DN> • 5 = ? r SION> / ALTERNATIVE««3I >[[-#>][< . [ / SS10N> / ] 1* ERNATIVE a 4 TH meticexpression / ]]? M= <0L2TERM> t #* [ [ #/ C / RA> / ] oscaLahexprfssi RA> / ] r)0L2I0ENTlFlER> IONi|NlT> ; ::=[+/-]? EXPRESSION / < THAN0SI0E> /' ] ] 3 t *> / J \ I [ / ] I BASICREF> / ] J, ; 1 ]* I >][#]/ 33? •? 1EXPRESSI0N> / ) EN SEMANTICTESl «* rALSE J 33 > / 3 SEPARATOR* J [ C + / - 3 C / IDE> / 3 ]* ; RIMARY> / J ]* j 3 3? ; on> / 3 3? J / / ( El227> 3 t ) / 3 •? \ Q[ ALTERNATIVE »* * t J > I !■ t ♦ / ■ 1? ; USE USE USE / < USE : = [ 3 « = heticex J *N> 3 t 3 I? ] L2AR1TH f <0L2A LIST I 1EXPRES 1 E X P R E S PT X 1 / PI J ] / PT | j ( [ ♦ / - ]? F.1234> ] / PT » ALTERNATIVE := 3 J] <«EfEREncE> J PRFSSION> / I E C + / - / 3 ? > METlCEXPRESSInN> AHEAO » 3 ' RITHMETICEXPRESSI0N> / ] / t ( / 3 SI(IN> / 3 [ I / ] S 1 N > / 3 1)/ 3 3 ««= ENn ? [ HI / ] j : j= <*I> SSf If I AHLECPl ].[4M1 1 = THEN HFGIN 10 I PT »= POINTERC lnNA:iE[01 ) RFPLACF PT BY " " FOR 2* J IF I AK.LECP1 I.CHIIMTFIELO LFO 26 RFPLACf PT RY P[)I NTER( T ARLE [ PI FUR TABLElPl 3 .CfliJNTFIELO ELSE REPLACE PT BY PO I nTER ( T ABLE [ PI ♦ 1J) WRIJE (STATION* 12» IDNAME[*3) > END 1 THEN ♦ 13) FOR 26 3 I 57 lla t t ♦ / - J t 1 J* I lj= [[«*/*/][ / ) 1* I

      Mi [ ♦ / • 1 I / J / t **** t / 1 ]? | t:» ( [ / ] I ) / ] / J ««= I C -*> ] t / ]]*I « Is [ . [ / ) ]* \ »»» [ ( LIST [ / #* / ] SFPAHATDR . I ) / 1 ]? I !'■ I <* H> f <*N> J [ E £ ♦ / - 1? [ <*N> / ] ]? I J I « »si usEpni Nl 'MRI I |S ?T! usEpni M* »"RI 1 1 = «T| usEpni N I > WRI I | s PT( USEpfJl Nl ; >vri > 1 1* PTt usepdi N I ; iv r i > » t s »Tl UsEPni Ml »wrI t 1 = aT[ USEpfJl Ml > .MR I j 1 = »T( usEpni Nl ; wri 1 : = »T( USEpOI '|1 5WRI : | s »T( usEpni H > rtRl i | s PT| usEpm N I J >"i R I « 1 = »T| USEnni N } wRl » J = »T[ USEPO! Nl 'MrI i | s OTI usephi N ; rfRi x i = »T| usephi N ' J W W 1 » I s «T USEPfll N MR! j 1 = »T| USEPO] N r 5 /m R I I t = »T Usephi Ml > w p I J | s eT :usepoi Ml r ; /» r i > l t — »TI USFPI1] N ; rtRl t t = PT 'USEoOl M [ i d r I I | s PT [USEPOI Nl ; rtRi J | s PT rusEpn 1 M r? wri J t = PT :usE°n [N N l 1 = 8 T :usF^n N »«Rl J 1 = PT [USEpOI [M r ; rtRi l t = PT : usepo [N r Mrt I « : = ®T [USEpO rj rJ«Ri J | s 8T [USEPO 1 N r ; wri : t s «T [USEPO N' r ; rtpi l ( 3 *T :usepo :n r ; w r i j t = «T [Usepo ; M r**Ri J t = aT [useph N [ J wri J 1 = PT [USEPO f N 1 M R I I | 3 »T [USEPO f N r ? w.r i i | s f*T [USEPO f N i ; wri 0 J I s PT [USEpn 1 M r i w r i : | 3 ST : usepo ■ M f ; w r i l | 3 PT rusEPo r n r;*Ri I | = «T [USEPO [N 1 ) W R i TE(STAT TECSTAT TECSTAT TE(STAT TECSTAT TE IUN ,F01/iO)l ION .F0141 >; TON . F 1 4 2 ) ; ION .F0201 ) J ION .F02O?) { TON »FO?03)I ION . F ? '4 ) J IUN .F0206) J write(STatiom»fsep)jt; n WRITE(STATION.FSEP) J ]l i; i j ii u l; u li ii i j WRITECSTATION.FSEP)! ]l 1 J II l : WRlTECSTATION»FSEP) J ]l 1 J 1 : ] ; )i WRITE(STATI0N»/SEP)I ] J 1 I 1> i ; M M u II WRlTECSTATlON»FSEP) J ]l 1 J 11 11 1 I 1 J 11 i ; WRITECSTATI0M»FSEP)| ]l 1 ; i; II 58 30e>> Ol>

      0*> > > > l> 1> 1 1 = »Tt usephi Ml ; WRITI ! | 3 PSf USE P 01 N 1 » WRIT) | | s PT[ usEpni Ml }-i R I T I | IC »T( USEP01 M JWRlT S ! = »St USEPUT Ml ; ariti | | = »T( usEpni N ( } rlH I T < t = ST! USEPfll N 1 J w R I T I ; = PTI USEPO [M r t » r I r ! | = PT 'USEpO [Ml ; * r i t 1 t = PTI usfphi r n 1 r ; writ ! ] a PTI USEoO N r ; •< r n • ( = »T •usephi [M r; writ ! J = PT| usEpni r N 1 ; h r I T i t = a TI USEPO [Ml r ; rt r i T J | = «Tl USEPO [M 1 ' rt « I T ! j = PT 'USEPO [M » wRI T 1 t = PT| USEPO N [.WRIT | ; = PT ;usEpo [ N ; w r i t t { = PT [USEpO [Ml ; rtRiT I S = PT ■USEPO [Ml » *RI T » : = PT USEpO [M 1 ( » w R I T ' i = PS "UsEPfl [Ml r>* I s PT :usepo 'M" r ; » r i t t • = e T 'USEpO ! M » ^ 4 I T 1 1 = »S [USEPO ' m ; w r i t I I a PT [USEPO ■ M ; .v r i r ) > a PT jUSEpfl F N f ; WRIT } 1 = »T :usepo [M ; w n i t i t S PT [USEPO rM f » «R I T i t ~ PT [USEPO i M 1 ; W R I T » : = »S [ USEpO f N i ; w r i t ! | s eT [USEpO rM > J rt Rl T t ! = PT rusEPO [M f ; ft r i t i : = »T :us£pn ' Ni > h R I T » j = PT [UsEPf] rM I '' « H I T < t - aT [USEPO r v i r j .-j r i t | ; = 3 T r usepo [ M r J WR I T » 1 = e T [USEPO r m ri*RiT » I = PT [ U 5 E P I M 1 S flR I T ; : - PT [USEPO [N r ; .1 p i t t • = PT :usepo IN r; /,rit » j = PT [UsrPii TM n « r it | | r PT [USEPO T M r ; « r i t tecstat tecstat TE(STAT TECSTAT TECSTAT TEfSTAT TE(SIA1 TE(STAT TECSTAT TECSTAT TECSTAT TECSTAT TE(STAT TECSTAT TECSTAT TECSTAT TECSTA1 TECSTAT TEfSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT F ( S T A T TE(STA1 TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECS1 AT TECSTAT T E C S T A 1 TECSTAT TECSTAT TE(STAT TECSTAT TECSTAT TFCSTAT T F C S T A 1 TECSTAT TECSTAT TECSTAT TEC STA1 TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TECSTAT TFCSTAT TECSTAT ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON (JN ON ON ON ON (IN ON ON ON ON ON ON ON ON ON ON ON II M ON ON ON ON ON ON ON F0207 F0209 F0210 F0301 F03O3 F0304 F030b F030A F0307 r03oa F0309 F0310 F0312 F0313 F0314 F0315 F0316 F03l7 F031« F0319 Fo^Ol F0402 F04O3 F '4 '4 FO^Ofj FO'4 06 F a t FOiiOl F0601 F0^>02 F0603 F0 60 4 F0701 F0^02 F0703 FOHOl F0fln2 FOR 3 FOHOa Foaos F0H06 F0607 F080rt F0HQ9 F0901 F0902 FOV03 F09oa Fl)9ob F09oiS F0907 F090H F09O9 F0910 F091 I F 1 1 FIOQ?. 1>WRITECSTATI0N»FSEP)J ]i ); l s );write(station.fsep)i h )M> ); i j )iu )M > )n; ); i j )iii ))ii )n; )>WRI TECSTATI0N»FSEP) J] J )! II ); i j )IWRlTE(STATIflN»FSEP)| ]> ); i i )J 11 )!]! )SWRITE(STATIUN»FSEP) J) I ) 111 )JWRITE(STATI0N»FSEP);]I MM );i; ); i t )iii )}WRlTECSTATION»FSEP)j]J ) i 1 J i i ); WRITECSTA1 I0N»FSEP)I ]l ): 1 J ); ii ) ; 1 1 )JWRITECSTAT10N»FSEP)| h ) ; i i )i i ; )l W s ,ITE(sTAT1on»FsEP)I M ) JWRITFCSTATION'FSEP) J ]l )!1 I ) JWhITE(STATIUN»FsEp)I m ) J 1 J ) 11 1 )PI )MI ); i : )lll ) ; ii in; )»l; ) ; u )} u JMJ 59 t 00 J> 1 1 n PTt l00'»> J | s *T[ 1 003> » | s PTC iOoe> i | s en 10(K> I | s est 1 101> t • B en ll0*> I I = PTC 1 10J> » | S est 1 20 1 > 1 | S PT( ,20J> 1 | = PTC 1 20<»> « |S *n 12(P> « ! a PSC 1 20O> 1 l a PTC 1*00 » | s PTC i2ll> « ! = a Tt 1 2 1 *i> | t a PTc i21J> 1 J s PTC 12P> J ] s en l2l«)> 1 t s en 1210> t t - PT[ j21V> 1 J = PTC 422^> » | s a n 1 22*i> « t s PT r !22J> 1 | s PTC f22<»> 1 J = an i22«>> t t s »TC l22'> « |S en l22»> I 1 a PTC i23<4> I | s »TC 123«>> i t = «Tr )23f> i | s PTC 123°> I t = a TT l2«u> 1 | s »TC lZ4*> i | s «TC 1 2a^> i 1 a PTC i2a J > « J s »T[ i24«> » | 3 »Tr ,243> 1 I a PTC y2H*> J | = M T [ )'dUf> 1 1 a PTr ,240> t ; a PTC ,30U> I { a P0[ 1 J01 > 1 1 a »TC 1 30^> J 1 = PT[ ^30J> J : s a TC 130**> » t = a Tt i30^> : • a aTC ^ 30<3> , .2 »TC 1 30^> 1 | = PTC l30o> 1 t a «T[ 130V> , { B «T[ i3iu> l | 3 a TC 1 3 1 1> J 1 a a TC »A«St01> ' A KSt.02> 'A«St03> •AHStOa> USEPO' usepo; UsEPO' usepo USEPO' USEpU USEPO usepo usepo: usepo USEPO' USEPO' USEpO' usepo: USEPO' USEpO' U S EP0' USEPO USEPO' USEpO USEPO usepo: USEPO' usepo USEPO' USEPO' USEpO USEPO USEPO USEpO USEPO' USEPO USEPO' USEpO usepo; USEPO' usEpir UsEPO' USEPO USEPO' WRIT! USEPO usEpiv USEpO USEPQ' USEPIV usEpni USEPO' USEPO" USEPO' USEpO USEPO' » i = » Q c w r : I , a » U C W R ' > I = »UC WR' » t = eUC WR: TNl ; wri TNT 1 WRI tnt i WRI TnT »WRI TNT J WRI TNT ; wri TNT ; wri tnt ; wRi IN 1 ; wri I N T I WRI TN|I t«xl I M T > wRI TNT ; wri TN' J WR I I M T J WRI T N 1 1 WRI T N T 1 wRl T Ml '"Rl I NT J WRI TNT jwri TNT J wpl T NT 1 WRI I N 1 I WRI T N T i W R I I Ml *«Rl T N 1 ; wri TNT ; wri TMl 1 WRl TNI J WRI I NT ; w«i TN 1 >wRI TNT 1 WrI TN' ; in h i TNT 1 WRI TNT J WRI I NT 1 WRI int 1 .VR I TN 1 J WRI TNl M R I TN 1 J WRI I NT t W R I STAT IN 1 ; wri T NT J WRI T N T 8 W R I T N r **Rl imt J WRI T mT ;wRl T Ml * « R I T Nl ; w r i T N T » WR I TNl ; iri T N 1 f W R J ITt (ST T TL (ST ITL t ST ite (ST ITE(STA ITE(STA I T EC ST A ITE(STA ITE(STA ITE(STA ITE(STA ITE(STA I TEC STA ITECSTA ITE(STA ITE(STA ITE(STA ITE(STA I TE ( STA ITE(STA ITE(STA ITE(STA ITE(STA ITE(STA ITECSTA ITE(STA ITE(STA ITE(STA ITE(STA ITE(STA ITErSTA ITE(STA ITE(STA ITE(STA I T E ( S T A ITECSTA IT E ( S T A ITE(STA ITE( STA ITE(STA ITE(STA ITF(STA I T E ( S T A I TEC ST A ITE(STA ION. F I TEC ST A I TEC STA ITECSTA I TEC STA I rEC ST A ITEfSTA ITECSTA ITECSTA ITECSTA ITECSTA I TEC SI A TATION, T A T I N . TATION. TAT I ON, ON ON ON ON ON ON ON ON ON ON ON UN ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON 00 ON ON ON ON ON UN ON ON ON ON ON FNEW) FPAR) F1003 FIOO'4 F1005 F1006 F1007 Fl 101 F1102 F1103 F1201 F1203 F120'« F1205 F1206 F1207 E1211 F1212 F1213 F1215 Fl 21 6 F1216 F1219 F1220 F1222 F1223 F12?4 F1226 F12P7 F1226 F123a F1236 F\23f F123^ F1210 F12al F12«2 F12/j3 F1244 Fl2^5 F12^6 F1247 F12^8 ; ] F1301 F1302 F 1 3 3 F130'< F1305 F1306 F1307 F130fl F130V F 1 3 1 F 1 3 1 I : 1 i 1 FSET) F 1 N T ) II II II II II 1 J WRITE(STATI0N»F$EP)I ]l II II WRITE(STATI0N'FSEP>> ]l II WRITECSTATION.FSEP)! ]l 1 J II 11 WRITECSTA1I0N»FSEP)I ]l 1 I w,,lTE(sTATlON'F s EP>l ]l II WRITECSTATION'FSEP)! II II T I II II 1 I II l ; WRITECSTATION'FSEP)! ]l I i ] I II W:-ITECsTATION'FsEP)l Jl i ; writecstation»fsep)>]i 11 I I 1 J 1 1 W.ITECsTATION»F S EP)l ]l II WRITE(STATI0N»FSEP)|)I II i; I i I I i ; WRITECSTATION'FSEP) jl I n WRITECSTAIION.FSEP) I ]l II II II 60 rNO COMMENT FOrMAI TArT I U P-01U1 r 0lU5 4"n0".> # r 01U6 r 01U6 r oiIo 4"n0">» F 0li2 HE» n ."" r 0113 a"7U4u7 F0H4 ,4"00 n ) r 0115 r 0H6 4"n0"J» r on/ r on9 a"0 Tn P The 4"4 4"5 4"7 IT I Of t FSFP U N T T •» (" : TERMINAL •;' M I SS I NG" » 4"00" > . OENTlFlEc?nfcCLARATinni>» INCORRECT < I OL I ST >" » 4"00" ) * ' DENTlFinpDfcCLAHATION>» INCORRFCT » , 4"00" ) , D L I S T > : TMCOKRECT < I QEnT I FIER>"» 4"00" ) . EfINITTON>: •DIMENSIONAL' MISSING FOLLOWING 'FINITE'"* ("» 'SPACF:' MISSING FOLLOWING ' VEC TUr • " . 4*00" ) , (": 'OF' MISSING FOLLOWING » SP ACE ' « » 4 "00" ) , (» : 'DIMENSION' MISSING FOLLOWING ' OF' "» 4 M 00*» ) • ("« INCURRECT FOLLOWING ' DI ML NS* ON '" » 4"00" ) » ("« 'HAS' OR 'CONTAINS' MISSING FOLLOWING 'WHICH'". t" J 'AS' MISSING FOLLOWING 'HAS 1 OR • C^NT A I Ns • "• ('-': 'ElEMENT' OR 'MEMBEr' MISSING FOLLOWING »T 00"), (»J INCORRECT FOLLOWING «• , o " ) • 1": ''.4"^{)5n7 IJ «,« MI SS ING F[)LLO w ING " C: 'ARE' OR 'IS A' MISSING FOLLOWING • wH I CH »" . 4 "00" ) . ("1 "»<4"7Dbi)70"»" MISSING FOLLOWING, LIST Of <*N>"» (" : INCORRECT <*N> IN L I ST" » 'J "00" ) , C"| »".4"b0"."' MISSING FOLLOWING LIST OF <*N>" » 4"00" ) » 61 r 01*0 («« INCORRECT iti LI ST"# 4"00" } » r OUl ("» RIGHT pArENThEsIS MISSING FOLLOWING LIST OF ".fl n OO"). r 01*2 ("t INCORRECT <*N> FOLLOWING "» 4 "7041)70^0" ) . r 01*3 (" , INCORRECT <*N> FOLLOWING '.'"»4"00">. rOl" ( M l RIGHT PARENTHESIS MISSING FOLLOWING LIST OF <*N>" ,a«oo M ) , r OUb (« j INCORRECT FOLLOWING '600ND' OR ♦ORDER'" ,4"00"), r OUd («l 'a L oCK' HisslNG FOLLOWING FIrsT < SLQ ijENC E>" » 4"n0">» F U1i INCORRECT FOLLOWING • BLOCK • "» 4 "00" ) » r 01J0 ("» 'Of' MISSING FOLLOWING SECOND "»4"00")» FOlJl ("! INCORRECT <*I> FOLLOWING »OF'"m"00")» r 01J2 (»« INCORRECT <*I> FOLLOWING ♦ ON '"• '4 "00" ) » P 01J3 («<0N0RlNAsPAcL>» INCORRECT IN LIST FOLLOWING 'FROM'"* 4 w nQ w > • pOl-JS ("< n NORlNA.sPACt->» 'INTO' Op 'ONTO' OR 'TO* MIsSlNG FOLLOWING LlS y» t a«uo" /"Following ifrom»".4"00"), ^01^6 (HJ INCORRECT IN LIST FOLLUwlNG 'INTO' p" f 4"U0"/» , oNTo' 0-j •TU ,M »4"00 M )» F0138 ("J 'OF' Or 'IN' MI s sInG FOLLOWING • L L EMENT ' OP » M EMBER'".4"00»), r 01J9 (n J INCORRECT <*I> FOLLOWING 'OF' OR ' I N ' " , 4"00" ) » r 01<*0 ("« INcURREcT <*I> FOLLOWING " » 4"7o4|)7 (}00 n ) # r Oi«*i ("<^PACEID>J »",u"5D","' MISSING FOLLOWING <* I >" * 4 n 00" ) » r014<> (»t INCORRECT <* 1 >" » 4 "00" ) » r 02"l (»j INrORREcT FOLLOWING 'pARTlTlO •after' missing following ". incorrect following 'after INCORRECT IN first list" INCORRECT FOLLOWING 'AND'" INCORRECT In SECOND LIST N ♦ " » 4 " rt ) » r 02«2 ("« «"oO"; , r 02U3 ("I i",4"U0") . F 02W4 (»» ,4*00"), r 02^6 («I ,4«00">, f02«7 ("» ",/l"OU"), F 02W9 (»ti TERMINAL •;' Ml SS I NG". 4*00" ) , r 0210 ("» INCORRECT IN 1. 1 ST" » 4"0U" ) , f03ui ("» incorrfc t IN L. i S r followi n g »S FTi"»* ,i, 00«»), r 03U3 (": TERMINAL 'J' Ml SSI NT," » «"00" > » F0304 ("< S IMP L EsrT.<;T M r>« INCORRECT < I [)ENT I F I ER>" » 4"00" ) . incorrect

      following • the '".4"00") , 'part' missing following < sect i on>"t 4 «00 « ) , 'of' missing following ' par i ' " . 4"00" ) , incorrect following 'of'". INCORRECT FOLLOWING •EaUAL* OR r 03W5 (« j r 03^6 (« j r 03U7 ("l r 03^» («j 4"p0"^ » r 03«J9 (" j o' OR 'T0'",4"00") . F0310 (" ! INCORRECT < ROOTR ArT SE^>" » 4"00" ) » r 0312 («» INCORRECT IN LIST FOLLOWING ♦[♦ "./i"0'J"). r 03i3 (": M' MISSING FOLLOWING L I ST" » 4"00" ) . r 0314 (»» INCORRECT IN LlST FOLLOWING •<• 62 »t INCORRECT FOLLOWING MNT w , 4 •» o " ) » »i INCORRECT FOLLOWING " » 4 " " ) , "j «ANO» MISSING FOLLOWING FIRST J INCORRECT FOLLOWING 'A ">, ": «IN» OR 'OF' OR 'ON* MISSING FOLLOWING a"00 , '/""»4"00' f )» «< I N T FRCHANr, F: STATEME^T>« INCORRECT " » 4"00" ) . wTATEMENT>! TERMINAL W» MISSING UR INCORRECT J TERMINAL '»' MlSSlNC, OR iNCOKREcT <*I>". "J INCORRECT <0l2R00|_E ANFXP> FOLLOWING • IF • « , 4"00" ) » »: «THEN« MISSING FOLLOWING <0L2R00LE ANEXK>" , 4*00" ) , «t INCORRECT FOLLOWING ' THEN • n » 4"00« ) » "i TNCURREcT FOLLOWING ' ELSE • " » 4"00« ) » "<0L2I0STATEMLNT>J INCORRECT FOLLOWING iINpuT* OR ,4«00")» "! TERMINAL »»• M I SS I NG" . 4"00" ) . M » INCURRECT < * I > I IM I. I ST" • 4"00" ) , "<0L2fURSTAtEMEnT>i INCORRECT FOLLOWING »FOR» " t •=' MISSING FOLLOWING " » "J INCOhrECT FOLLOWING 'a'", "J TERMINAL ' >' M I SS I NG"» 4*00" ) » ": INC.ORRErT INITIAL "» 4 r, 00" ) * "< S PECIFlCATTON>» '»' MISSING FoLL^lNG F I l? ST * , »4"00">. " t INCORRECT FOLLOWING • » t "» 4*00" ) * w . ♦,.' MISSING FOLLOWING LAST " » 4*00" > » «» incorrect terminal following ♦..•"» »<0L2I TERftTl VLCLAUSE> I TERMINAL ' I » - MISSING"* « n OO B ) • "i INCORRECT FOLLOWING 'WHILE 1 OR , UNTI ) » - J INCORRECT IN L I ST n » 4 "00" ) » " j INCORRECT < qnOLE ANFAc TOR> IN Li ST W » 4"()0" ) » ": incorrect follo w ing "» 00"). «. j » %f , /* »» 5 D " » « * MISSING FOLLOWING "J INCORRECT FOLLOWING ' i ♦ " » 63 F-0910 4"n0" n r 09H 4" 0">» r 10Ul 4"n0">» r l0O3 r 10U5 riowfe 4"nO M i# r UU2 r ll03 r 12ui r 12U3 r 12ua F 12U5 r 12U6 F 12U/' J.12H rl2i2 r 12i 3 4"n0">» r 121b r 1216 r 12ia express: r l219 R »-»".< rl2^0 r 12^2 r l2*3 r 12<<4 rl2^6 ■ r 12^7 • 4«t00") , Fl2^« pi2*9 f • h . a " o I r 12J0 " » A " " rl2^1 r 12->2 r l2->4 rl2J6 >•♦, a w oO' r 12->7 i , ,%<♦", r 12JO 4»t 0"»/ r 12<*0 4 " n " J # "» INCORRECT FOLLOWING »|»»» "l incorrect FOLLOWING '8»"# "l 'TABLE' MISSING FOLLOWING • ID* "• 4"00-) • «l MO* OR 'TREE' MISSING FOLLOWING 'PRINT'", "j 'NODES' MISSING FOLLOWING * TREt '" » 4"00" ) . w <0ER||GSTATFMENr>l 'PRINT' MissInG FOLLOWING • NOnt •" » 4"00" ) • "i 'OFF' MISSING FOLLOWING ♦ PR I NT ' " ,4 "00" ) , «J 'ON' UR 'OFF' MISSING FOLLUwlNG 'TRACE 1 "* ": rFf>: I L>» INC L>t •]» L>i INC NT>« TF. STATED ST4TEME STATE, iE ATEMEnT ATEMENT ATEMENT ATEMENT INCORRE NCORREC URRtcT MISSIN ORRECT : •>' MISSING FOLLOWING LIST OF " » «! INCORRECT IN L I ST ". 4 "00" ) » "« • "^"So"'"' MISSING FOLLOWING LIST Of <0L2ARI THmETI r, N > " , u " " > , «<0L2ARIThMFTICEXPRESSI0N>: INCORRECT <0L2TERM> FALLOWING •♦' 00"). "<0L2TERM>: INCORRECT FOLLOWING • * '" , 4"00" ) # »<0L2nlVlnE>| INCORRECT <0L2PRIMARY> FOLLOWING '/'",4"00")» « : INCURRECT "» 4"00» ) » "<0L2FAcTnR>l INCORRECT (•OLLOWlNG '**'", 4"00" ) . "! INCORRECT FOLLOWING ♦ ** ♦ " M"00" ) . "l INCORRECT <0L2AR I THMET 1 CE XPRESS I 0N>" "« • " • 4"50" » " ♦ M I SS I NG n » 4"00" ) » «: INCORRECT FOLLOWING ' )• "« ']' MISSING FOLLOWING "l INCORRECT IN [.1ST F0| < • " , 4 " " ) , " J •>• M I SS I NG"» 4 «00" > » "» »"»4 M 50"» ,M MISSING FOLLOWING " » 4"00" ) • "J ',' MISSING FOLLOWING <0L2 A Rl T HMtT I CE XPRE SST OM •»l INCORRECT <0L2 AR I THMET I CE XPRESSI UN> FOLLOWING 0"), "» RIGHT PArENThESIS MIssInG FOLLOWING S^CONo"' <0L2ARlTHMFTTCLXI J RESSHJN> n ,4"00"), "t INCORRECT < 0L2 AR I THmE T I CExPRESS I 0N> FOLLOWING 'l'"» 64 r 12**l ("l • I I • MISSING FOLLOWING ". r 1242 ("j '♦' OR •-• MISSING FOLLOWING ' E • " » 4"00" > . r 12**3 ( «: INCORRECT <*N> IN E XPONENT" ,4 "00" ) , r 12M (tt< R fJUNOPAlRFXPKtSSiaN>l • "» 4*40", »« MISSING OR INCORRECT <*N>". r i2^b («: incorrect in l*st follo WInG ",4"7D407000"), r 12^6 ("| •}• MISSING FOLLOWING I N i'lS l^^awOo" ) • ri2^7 (»tl INCORRECT

      In L j ST FOLLO wimG ' » «".4«oo"), F 12**d (« : ••^"SO"," 1 MISSING". <»"00")» r 13W0 C« ENCOUNTERED* NO SYNTAX PARSING PERFORMED"* r 13^1 («: INCORRECT FOLLOWING •♦« OR »-•«. 4"ft0"'» r 13W2 ("t INCORRECT FOLLOWING »*• OR ' / ' " . 4"00" ) » rl3^3 ("i INCORRECT FOLLOWING UNARY •+' OR • - ' " ,4*00"), r l30a ("i INCORRECT FOLLOWING '**'", 4 W 00" ) # rl3» INCijrrECT FOLLOWING ". r 13U6 (" t ' "» 4"5D"» "• MISSING FOLLOWING : incorrect or •*' in i..ist"»4"oo">» rl3^8 ("t '",4"5n"." , MISSING FOLLOWING LlST".4"00"), r 13U9 ( « t INCORRECT <*N> IN E XPONENT "» 4 "00" ) » r 1310 (« 1 INCORRECT FOLLOWING »->»"» 4"n0">» r l 31 1 ("J INCORRECT FOLLOWING • . » "» 4 "00" ) t rNEw ("STATEMENT PARSES AS "" AN Y ERRORS NOTED BELOw". 4"nO">» pPAK ("sTATEMLNT PahSES AS

      -~ ANY ErrUrs NOTED BELO W" # 4"U0" ) , rSEI ("STATEMENT PARSES AS -" AN Y ERRORS NOlEO BELOW". 4"n0">. riN» ("statement parses as --any errors noted be L0'.i"»4"00"), r ENU ("STATEMENT PARSES AS " AN Y ERRORS NO(EO BELOW". H»^O n i , rIFi ("STATEMENT PARSES AS <0l2 I F S>'" A N Y ERRORS NOTED RFLOW" . 4«00" ) , r IO^ ("STATEMENT PARSES AS <0L2 I OST ATE MENT >--AN Y ERRORS NqtED PFLOW". r FOK ("STATEMENT PARSES AS < QL2 FORST A TEMENT>-- AN Y ERRORS NOTED bELOw". 4"n0">» rllt- ("STATEMENT ParSES AS <0l2ITEraTIVEClAuSE>--ANY ErrUrs NOTED 8EL0 W" t 4"U0") , rDEB ("STATEMENT PARSES AS < DE RUGST A TE MENT>-- AN y ERRORS NOTED BELOW". 4"n0">» rPKU ( M S T&TEMENT PArS^-S As <0l2Pr0CE[)URESTATEMEnT>--ANY Errors NOTEq « ELnW"»4"Oo'M, r AS^ ("STATEMENT PARSES AS < A SS I GN 1ENTSTATE MEN T>-- AN Y FRKORS NnTE[) REl W « » 4 " " ) i 65 APPENDIX C DOCUMENTATION OF OL2/SKELETON The TWST65 compiler-compiler available on the Burroughs 6500 computer system currently in Coordinated Science Laboratory uses two input files, known internally to TWST65 as CARD and SKELETON. The CARD file is expected to contain the syntax and semantic routines for the user's project, as described by Trout (1, 2). 0L2/TWST, the file used for that purpose in generating 0L2/PARSER, is described in Appendix B. The SKELETON file is expected to provide the basic procedures for the parsing mech- anism, such as input and output, string scanning, stack manip- ulation, and table building and searching. The TWST65 system contains a standard file, TWST65/ SKELETON, which contains these procedures; however, a program generated with these routines included will expect card input with merged patches from tape files, and it will parse the entire input file as a single syntactic unit (usually a pro- gram) . 0L2/SKELET0N is the modification of TWST65/SKELETON which was used in generating 0L2/PARSER, which uses remote terminal files for input and output, and which scans each new input string reentrantly. That is, 0L2/PARSER parses input characters from the attached terminal until either it recognizes a complete OL/2 statement or it finds a syntactic error, at which point it starts over. 66 Interactive Features The first modifications, those to make 0L2/PARSER inter- active, are contained in the procedure READALINE. READALINE is substituted for the procedure READACARD found in TWST65/SKELETON. It is the only procedure in 0L2/PARSER which accepts, input , and it accepts data from the file STATION. Whenever a remote terminal user on the B6500 executes a program containing a file named STATION, the data communication system will equate his terminal with that file. Since all output from 0L2/PARSER except a final listing of statements and error markers is written to the file STATION, 0L2/PARSER is interactive. READALINE (at line 48200 in the listing) fills the one dimensional alpha array CARDBUF with the characters entered at the terminal, places a ^-character in the last position of the array (to prevent the scanning routines from scanning be- yond the array and to signal when more characters are needed), and initializes NCR (an integer variable which is used to point to positions in CARDBUF). READALINE also causes error markers for incorrect statements to be placed under the incorrect statements in the printer output file, LINE, and inserts the new input string into LINE. The Boolean variable USEPT is set TRUE to cause the procedure USEPOINT (discussed later) to ad- just the error marker when errors are found. READALINE can be invoked from only two procedures in 0L2/PARSER, ENDOFPROGRAMDEFINE and NEXTCHAR (at lines 889OO and 67 51^00 of 0L2/SKELET0N). ENDOPPROGRAMDEPINE calls READALINE whenever a new statement is needed, and NEXTCHAR calls READALINE whenever more input is needed to determine whether a current string is a complete, valid statement. Reentrant Scanning The second modifications, those to cause 0L2/PARSER to parse each new string independently, are contained in ENDOPPROGRAMDEPINE and TWSTINITIAL. It is much easier to let STATEMENT be the largest syntactic unit and restart the parse for each statement than to let PROGRAM be the largest syntactic unit and set program parameters back to previous values when errors are encountered. A TWST65 generated program has only one significant executable statement, that which calls an initial procedure. All work is accomplished via calls to procedures which scan strings, manipulate stacks, use the identifier table, and recognize various syntactic units. The procedures are re- entrant to allow recursive parsing. The simplest way to handle errors is to identify the error as precisely as possible, terminate the parse of that string, call for more input, and start over with the new data. ENDOFPROGRAMDEFINE and TWSTINITIAL were rewritten to achieve this method of operation. The only key change is explicitly setting an integer variable LRS to zero for each input string. LRS is a stack variable used in manipulating recognized syn- tactic units. Setting it to zero is the same as emptying the 68 stack. LRS Is the only variable that was not explicitly initial- ized before use in TWST65/SKELETON. ENDOFPROGRAMDEFINE (line 889OO) contains initialization for the program, including setting up the warning message for undeclared identifiers and the heading for the listing of input strings and error markers produced at the end of the run. MASTERBOOLEAN is a word of storage whose bits are each used as Boolean variables. PIRSTCOL and LASTCOL define the maximum length of a string accepted as data; 7^ is used because the Hazeltine CRT's in the B65OO room have screens 74 characters wide. NUMERRS is an integer variable used to count errors (maximum of one per statement). Setting FINISH to FALSE allows the program to begin normally. The central loop of 0L2/PARSER is contained in this pro- cedure (lines 90400-90900). Until the word FINISH is entered by the user, setting the Boolean variable FINISH to TRUE, 0L2/PARSER will execute this loop. Each time through the loop, the program will prepare to parse a new statement, read a line from the terminal, parse that input, and display a message des- cribing whether the string was completely parsed. The initialization for a new statement takes place in TWSTINITIAL (lines 33100-33800). Here LRS is zeroed, and several variables (LSPACES, BASE, ENTERTOGGLE, CBPOI, and SYLPH) are set as they are in TWST65/SKELETON. ALTERNATIVE is an integer variable which is used within the syntax of 0L2/PARSER to control some alternatives in the grammer (see 69 Appendix B for a discussion of the syntax of 0L2/PARSER) . Input from the terminal is discussed earlier in the description of READALINE. The parse is initiated by the variable CALL, which is defined by TWST65 to equal TESTSTATEMENT(1 ) . TESTSTATEMENT is the TWST65 generated Boolean procedure which scans the input string for an occurrence of the syntactic unit STATEMENT as defined in 0L2/TWST (see Appendix B). Since CALL = TESTSTATEMENT(l) , the scanner begins at the start of the input buffer with an empty stack. TESTSTATEMENT returns the value of TRUE if a sequence of syntactic alternatives is encountered which allows the parse for a STATEMENT to be satisfied. Displaying an error message is often an alternative within the syntax of 0L2/TWST, so the message "PARSE COMPLETE" does not mean that no errors exist in an input string. TESTSTATEMENT returns the value FALSE when the parser cannot find an allowed alternative before reaching the end of the input string. Most error messages will cause the parser to backtrack in order to force a rapid termination of the parse. Otherwise, numerous useless error messages might be listed. (Appendix B contains discussion of this feature.) The final modification of TWST65/SKELETON in the con- struction of 0L2/SKELET0N is the procedure USEPOINT (line 86700). This procedure is called whenever an error is found in an input string. If the Boolean variable USEPT is TRUE, then the first error in the input string has been encountered; otherwise, the 70 error marker has already been positioned for this input string. If USEPT is TRUE, it is set FALSE and the alpha array POINT is filled with hexadecimal zeroes, which cause termination of a line of remote terminal output when encountered. Then, blanks are inserted in POINT up to the position of the first character not scanned, where the symbol "<" is inserted as an error marker to be displayed on the terminal and in the listing of statements Finally, the error count is increased. SEMANTICTEST is always given the value FALSE to force the parse to fail at this alter- native . File Listing The file 0L2/SKELET0N is maintained as shown in Appendix D; a listing follows. 71 COMMENT . ^CANNEK AnO UTILIT" ROUTINES FMM THE INTERACTIVE UL'2 SYNTAX iNALY^ER WRITTEN FHR PROFESSOR PhILLIPS Uf DCS. THIS fIi_E IS A MODIFICATION f J K T wSTa5/SkELET0N» *HlCH PRUviOE „ASlC RnUTlMES FHK c u '-1PII-ERS PR'JMJCED ^y THE T*sT65 CUmpIlER- THE COMPILER (1 n T H E R*500 S/S T rR. T HE RaSiC SC A mnImG» STACK HanOLj^G, ft ND TA^L E MANIPULATING ROUTINES ARE TOTALLY UNCHANGED. T HE UpTtUnAL PROcEni|«ES USUALLY PRD/IOED RY TwST» LISTprUcEOURES' r UpU HEADING' DijMpEH. AND 0ASS2. ARE NllT INCLUDED IN OL^/SKELETON , T N *Oni T l nN . REA'UCa^" ^AS RLE i REPLACED ** REaOaLJmE» rNDUppRnGRAMoEFlME ANQ TwSTTNlTlAL HAv/E BEEN REWRITTEN* AND USEPOINT HAS :?F£N INSERTED. VA| UE ARRAY LDnKAGAlM( 4"n0ouoooo0ooo». 4"r>00u000o0o0 0". A n r»ooo«o^'"a n 3r M » a w n 00UC0lF0036«. a«oOOuooonoooo". 4"oD0U00UO0n0O". A"ftOOUOOUO<>OOT'» 4" ri oouooooooor') »* V A | u E a R*a' aLF a ( 4«n00ooooooooo«< 4"n0ouoooooooo"» A w n OODOOOoOoOO , *» 4" ft OOUOOOOOOlO"» 4" n ooooooooooo"» a ,, ^DOuooooooon ,, ' 4" o 00O7FC o fFC "» flt» ooy3FCnoooo") ; VA| UE ARRAY ALFANljMf 4HflO0UUO0o0OO0"» ^♦♦nDOuOOOnooOn". 4"nO0U0O000000"» A H n OOUOOO()0000"» A"nDOOOOOoOOO')"' A"nOOUOOOOUOOO"» 4" n O00'FC o 7FC o "» ft^OO^FCoFFCO"); VA| UE ARKAY wF.TGHTSf fiHnO0UJF3F3F3F"» 4"nO0u3£iF3F3F"» UOW3F3F3F3E"« 4« a U0^3f.3f3f3E"» OOOOOIOO O000020't OOOOOIOD O000040O ooooosoo 00000*00' 000O070O 00000*00 00000901 OOOOlOOO oooonoo 00001200 oooonoo OOOOl/iOO 00001*500 ooooiaoo 00001700 00001*01 0000 19 On 000020 00 0000210-1 00002200 0000230O 00002 .00U3fr3f;3F 4" 4»» n 00U3 E 3f : 3f;3 tt"n00y3E;3F3f:3 Z»"n"0U3F3r3r3 4« ft O0UiF3r3r3 4t 00U3E3f3r3 4"*00U3e3f3f3 fltt n OOU3E3f;3F3r. (t|« ft 00U3E3F:3F3F." 4«nOOU3E3F3E3F" fl" OOU3E3r3F3F: 4" n OOU3F3F3F3F A"oOOU3f3f3f3f. 3F." 3 F « F" E" F" F" E" E" F" 4" o 00u3f3f3f.3f"" 4%00U3F3F3r3f.-" 4%00u3e3f3f3f"" 4« OOU3e3f3f *E" 4" ft U0U3E3F3r3E" 4« OOU3e3f3f3F" 4 M r»OOW3E3F3F3F." 4tt n oo^3E3F3F3F" 4"nOOu3F3F3r3F" 4" 00'j3 f 3p3p3E" 4" OOU3f3f3f3f*' 4"nOOU3E3r3F3f." 4" n 00^3E3F3F3p;" 4" n OOU3E3F3^3F. ,, 4"n00U3E3F3 F -3F" 4%OOU3f3f3f3f"' 4" n O0u3F3 F 3 F 3r" 4 " o u 3 f 3 F 3 F 3 f ** fl H 00W3p3F3 F: 3E" 4" o 00u3F3F3t.-3f " 4« n 00^3F3r3r3F " 4"n00U3E3 f ;3 F 3 F « ft " n U 3 p a r > r . " 4"nOOOor)OFOrl()» 4«r>00Ul 1 l?3r3r . 4" OOU3f3f3f3(-" fl" n O0U3F.l3Hl V 4 " n vJ 1 6 1 7 1 a 1 9 " 4%00Ul a1" 3 f3f v ' 4"r>00O3E3E3E3E" 4«oOO y 3E3rlr,l f •• 4"o<>Ou1f2o2i2?" 4" o 0()U23243j 3r" 4 M r ^O0U3F.3F3 F 3r' , 4 " « U 1 ? 3 " 4"nOOU040SO^O''" 4 M n00U0^D^3 r 3r">- 4 M r>00u3F3r3F3F") J V A l u t" AR^/\Y H f _XT("ol?^' DrF I N fc ScAMNERVERsInw ImTEwER . •' (i S 6 7 " » " f> 9 A m « , » c !) F F " » n » » 1 » ) •' = " ? 3 . ] . o 1 " tt ; C0005«n 000059Q 0000600 000061C 00006?o O000630 O0006'i0 00006'>o 00006*0 0000670 00006*0 0000690 oooo^oo 0000710 0000^20 0000^30 0000740 00007SO 0000760 0000770 00007*0 0000790 0000^00 0000*10 OOOO^O O000^'3o OOOOS'Ki OOOOBSO 0000^60 OOO0H70 00003^0 0000390 00009on OOOO^IO 00009?0> 0000930 0000^/40' OOOO^SO* 00009601 0000970- 00009*0' 0000990' 0001000' 0001010' 0001 020^ 0001 030^ 0001040! OOOlOSOr 0001060" OOO1O70" 00010*00' 0010900 Of) 01 lOOf) 0001110" 0001 1201 00011300 001 3500 73 NllMERNS. carocount caRdnum^r, firstcul. LASTr.DL* NrR, RSWOB N U» i =1 FIRST LINE COLUMN TT aE SCANNED * ='" LAST Li JF COLUMN Til HE SCANNtn rfal ALPHA 7 % ScANmUDE. B T A n P T R . BASE. WRK. FIRST' LAST. LRS. ALTERNATjvr, LSPACES. CHARcnUNT; TWSTI. I' J»K» MANTISSA. FXPONFNT j mAmEQi IF THE tfFSErtyED rtOHO OPTION IS TA!• A '\j . AN. a,g . A N . A iM . A N . An. A M . an. A N • AN. j 1 ! ? J ?: A: 5: 4: 7: P : 0! [in; ri2« [13: [Wit CIS: MM [17: ]*. ]*. ]*. J*. J«» ]*. J*. ] <■» ]«• ]#. ]*. la. I*. ]#. 3 -> U. It. l>t. 4* i if 0001 }ftOO 00013 7 00013*00 0001 3900 00014000 0001. '4 100 00 01 4?00 00014300 00 014/100 00014S00 00014*00 00014700 00014*00 00014900 00015000 00015100 0001520O 00015400 00015500 00015400 0001570" 00015*00 00015900 0001: BlGTAtJSTZE l» I V 512,0:511 i ; pODLFAm AR. : i n o ] > FjI.E ^A R0 UNT M n IJ E='4»K T . 4 tJ = 9»iiA XR ECS T ZE=l«»FiLf: T YPEsf7)j FtLE LINE (MYllSE _ ?.r,I.4i) = !35»hmfFERS = 3, MAXRECSKE = 20); FtLE STATlnN (KlNi) = J. iiYUSF = 3, MAxRECSl/F = 1 4 , INT-nUE = 4) ; Fo M Al FImAl C ,, N|jM- ; F'lRwlARO ; COMMENT A I 59300 J Pr>UC<-Oljr(r ALPHAGE'T i KUK.-jARn ; COMMENT AT ?9900 ; ppOC'-UURF STRINGGFT • FJRrfARn ; COMMENT AT 30900 ; DfFINE SFTo( S»E»T,SET'< >=REPLACE S+ ( E ) RY SETU FOP T* : DpFlnE L n nK(LnoKl.Lnf) K '2»LfJ0i<3}= R E AL ( L nrjK 1 +L no* 2 , LjqK 3 ) s j ImTE^Er pRncEOURE GPrmLEupInTEgER ( S» )j VALUE S } PnlNIER <;; INTEGER 0, BrGIH SCAN S FOR Qjfl WHiLE GEfc) ••<)..; o j = integer (5. (MJ-; -ii.t j j i *n F..FR j=«-Q) } ; EwD » I M TE b ER PR n CEOUR E G v ' oooi9 while True do BEGIN REPLACE U j RY U;ti FOR j; If Q--».t« rjf? g s "j[it THEN GO LI ENni hi GfiBBLEUPsTPlNG « =DELTA f S . Q ); REPLACE BY « n FOR 8i tNQ J ImTE^LR PR n CEnUR E G rTlJ E PnlfHER SJINTEGER CmaRj Bf<»I n SCAN SiS FOR Q|6a WHILE a ,. » , char: = real( S»D ; Getne x tC h aR ir,<;l71 )) + n NCR 1= «rR 4 J - 1 ; ;EX T CH A R( iOHLA'iKS) J SCANNERRIIR |= I > 63 | I |a I.[ 5:6i J END UNTIL NflKNxTCHR IN ALFANUHC 0] ) iCHARCUUNT |«I I tNn » PpoCtDURr St"inGGeti BEG I ■• STRlNGTESTj.TRUE^JAMEQt.STRlNr.TYPE; I t 3 0;NFXTCHARrFALSE w DO OEGIN ; ' lie (J:- GrmBLEUPSTRlNG(CBPnI + ( MCR-1 ,.f 6«7]» Sylph * I.C6i/]))+ T J NC R I s >r9 + J - i ; ScANNtRRfiR |s I , hi QK SOANNERROR ; I t= I.( 5I6}» End until ad^'a^cechar = „«» • CH A RcUllNT ! = I ' s T k InGtESt s = r A LS E I ,E x lCH A R(F A LSF) I EwD » ImTE^Er pRnCEnURF cnMPARF(S»n» n > j V A LUt S»n»N ; IN TEGrw NijPUINTEw S.'i. BEGIN IF S ) J CrPOI : 3 PnjNTER(CAR08UF') 5 SYLPH PnlNTERCSvMHUF) I EmD IrtsTlNiTI'AL t comment TivsTlMlTlAL CUNT rEfORE READING A COMPILERS WORK U wlLL HE HANOI Ei). s 1ATEmEnT Ir.| n EpF T Hp PaRSi,,G mLCH FOR EACH $tatEme ,-jIlL ENAfli,E pKUc f)R WHATEvFR TU H THAN EMnE|)DT!>iG T T WSt^>5 EfgF q MCLS IN AN I N |_ T M F SE SE M A\'Tlc ROuTlNE AlN$ NE -i MjEr Hf) MiEn Am IS N'T. FOUR E /. R hEh a Li AMI EiU n N L Y WAY n F r ALLlN«i qOnLEAN PROCEDURE, THE STA THE wE.vE M, P FUR ES H TTTE in n 'IT C RH FRE|) S 1 1 r H TNIT TEMEN ASSU R, d|_ ThT K jMftR FliTlJ AUDLI N INT L 7 / T ■:■ ■ >N T H UTlNE AS A A Rfj IALW T. M MPT 10 2/ PAR S is ILY 8 RE Mil NG HL mz ST AS F n'JM » A l»! [) N 1 1 f I T ATlON OST Ti N THAT SER Ex DONE T Y F fl KC DlrlCA UCK LE /SvELE SE-iAN *E* n E SINCE E R M I N A (jTIisiE FpnM I'ROCEU 5T65 G ONLY AMINFS n f a c! ING IT TIUNS* ,/ELS TON* ft TIC RU Line 5 T ,ST& L L N E rt A UNE I FACH LITAT Tn S TlUs R STM hICH UTINF. n F C 5 F.Nc CH 4 LA^S necessary TEO NPIlT STRING NEW E CONTROL Of TA P T n^EK FEATURE BOL TABLES IS BETTER S» SINCE t)OF aLL w e d ODES ANY OLD ^E THE ) AS A J RFAL PROCEDURE INjEfiEKtAO (SI GN» OEcrT ) ; VjLUt SlGH.DEfiPT . ImIE^ER DEcPT i JOnLEAu SIGN . H E G I N LAqEL LOOP'StfYPPj I : a j : s E X o n n E N T • = -1 A N T I S S A : = j IF (SIrN ! = MXT C HR = "-" } OR NXTrHR = " + " T H EN nE*T pHA R ( F AlsE ) I LOnP« IF NyTCHR a •».« THEN DECPT * sOECPT+1 ELSE «EGIN SCR a rC HI 01 : = ()! REPLACE P0INTERCSCRATCH)+5 BY NyTcHR FOR 1 wITH w f I r, H T S L 1 : If SCRATchIOJ gEU rlASE THEN GO TO SKypPJ HANTlSSA:s 1ANTISSA * ^ASE +SC R A T CH [ ... ] ; EXPONENT := FXP11NENT * DECPT ; fTHf)} . nextchar(false) ; go to loop; SkyPps INTFGFPEAO : = TF (SIGN) THEN -MANTISSA ELSE MANTISSA t SqAnnfrror j= dccpt > 1 ; EN!) i RrAL PRfiCEOURf n Um£P T CL J T ( '1 A iTlSS A , DrCP T ) ; VALUt- DEcPT»MANTIsSA : REAL ",ANTI SSA » DECPT : BrGIiN '•lANTTSsA 1= If m 00046UOO 00046500 00046600 OOO<*6700 00046HOO 00046900 77 j IF NEXTCMAK(FALSF) 1 * I j- EXPONENT " INTEGEREAD(FALSE.O) J SCANnjFRROR : = SCANNERROR OR EXPONENT NEq U EXPomFJNT :a T > FND I EXPPNENT a THEM rEgIN Ml) lFRTrL.Il j= Ij= ^ ft N T I S S A j NAMEQi* INTLGERTyPE END ELSE REqIN NOMFRIcLIT J= MANTISSA * RASE ** ( " r - X PONENT ) I NAMFO j= REALTY^E END I ARrOuNT :» 3 j PROCEDURE RFADALINE , BtGIN READ (STATION. 13. C, ARD^lFl * I ) ; REPLACE c^PHl ♦ LASTCDL * 1 UY M *" * N cR »» f t rs t i;,,l ) If NOT US^PT ThEN vRITE (LINE* 13. PfJINT[*i) ; WRITE LASTCOl. THEN oEGTN WRITE ( sUrTnw.<"GONTlN:iE J " » 4"O0"> ) J rEA-iALINE > END I IF Eo^AR* T rt EN ;jCR: = i! ENn else IF SKlPi) THEm HEGIN *F NxTcHR = »<« THE.N BEGIN WRITE f ST A T I ON . <"CUNT I NilE t " . 4 "00 "> ) ; REAiALInE ; END ELSE NCR := NCR + 1 » IF rnFMAR'N 'THfm iCR: = 1 ELSf NCR : = HCH + r,rTNFXTCH^R(CMPOl" ♦(NC I ?-1 ).TrtSTl ) % ENO UMTlL NKTCHR ) J REAOALINE i END ELSE NCR I 3 NcR ♦ 1 J UMTlL ivjXTCHhi jEQ "X" AND wXTCHR NEO " " Or nxtchr= " n and not skIpo;z EnO J ImTEViER pRnCEnURE An\/A(MCECHAR i BrGl* NEyTcHAR (FALSE ) ; ADvA-icECHAR j= RE AL (N xTCHR* 1 ) END j I M TE«"ER pR n CF.nURE ta rL E s EA«CM( S t R I ,^G . C ,iU n t. T yP E ) » VftLUt cUiiNt.TyPE . ImTEI»EH COUNT » TvPF ; A 9 K A T S T 1 ; nn s'esin I j= K ; J 1= TABLET. I ] . ClHi'MTFIELO J IF MANTISSA laSlG J THEN flEGIN J := I K := TAHLECI1 . RITELINiS -ENO ELSE Ir MANTISSA a IJR tANTISSA = 1 AND COUNT < I Then BE$t n J » a 1 i K := TABLET!] . LEFTLIN* END ELSE EXPONENT :* j END UNTIL NOT BOOLE Am ( F < PDNENT ) []R K a J END , COMMENT Nl) I CONTAINS THE LAST LlN.-EO ENTRY IN THE TA»4LE - Ir EXPONENT IS SET THEN NJ ENTRY NEEiJ E MADE SINCE ThE ITEM TS ALKEAP> PRESENT, IE i IS DIE THEN THE LAST LI N K WAS LEFT IE BOHLFANCFxPnNENTl THEM if Entertuggle then RFGIN If riTAh'PTw.t >i t Q] + COUNT Plv * gEq Sll THEN COkmENT NOT ENOUGH RHil i IN TmIS RU" J RTABPTR Is g BTABPTRf i pi i£8 4] + 512 J MQv E: (^ llI ' v>, TER(ST4lN;;)MM)I^TER(TAHLF[bTApKTR + l j )» % - (C0UNT+3)DI V ft) I 0^052900 000529S') 0C053050 O0053l0n 00053?01 00053300 00 05 3/401 000534S) 00053S01 00053601 0005365 . 00053^0 00053H0^ 0005390) OOO5'400'i 0005A10V 0005*4700 000^430" 00 054400 ooosasoi 00054600 0005A70'.) 0005480" OOO5A9 0n 00055n0i 0005510 00055701 O005530i' 00055'ion 0005550- 0005560;. 00055700' 0005540-1 0005590,) 0005600"' 0005610'' 00056700 0005630^ 00056400 0005650" O005660 ' 0005670" 00056AO'i 0005690'' 0005700' 1 0005710" OO05 7 70'' 0005730.1 :00057/i0r 00057S01 00057601 00057701 0005780" OO057901 OOOsrtOO'J 0005810H 0005870" 79 TABLElBTA B pTKl.COUNTYPE:FlELD|"(CiJii , flT*TYPBt;0,<» | bi)| K !« bTABPTH » IF BOULEAN(J) THEN TABLE[ I ] , leetlimk |. Ei.se ta.^ec i i . kiti-link ,- IF BTAyPTR is HTAnpTK + COUNT OlV 6 + 1 + «EAL(COUMT )On 6 NF« o> > BIGTARSIZf THEN TYPE l a l/(TYPEl=0)J »» K J BTA8PTR °TABPTP TE EmQ 1 NEq AND i ablesearch I ENJM ELSE I tAPLLSeaRCHI«i (TYPEalOENTTYPE I J ) THEN NAMEQtaU ImTE<>ER pRnCEnURE LASTCHARAcTFR j CnMMt-NT RETURNS ThE CURRENT VALUE OF NvT C HR THEN ADVANCES THF RFADER . BFGIN LASTCHARACTER, .NM.-IEO|»J:»RLAL(NXTCHK»n, NEXTCHAR < , rA L SE ) | ENO J ai pha PRqC^ouRE Scar «EGlN COMMENT THE ITE GLOpAL « pEad» VARIABLE NAME CON\/EyS THE TyPE Uf The IT IS SET IN EACH Or THE PROCEDURES ALPHABET. STRIN&ET»wiJ'iERlcLIT ANO HAS ThE Fl'LLWQlNG VALUES COMMENT NAME r i NAME = 4 NAHE a 1 NA^E ? ScANMnfJF SCANMOOE SCANMODE IF IDENTIFIER* STRIN",* INTE'.FR. REAL ; = o normal operating mode: assembles identifiers* nij^ers and striw.-s- followed by table look up. a 4 same as except table look mp is SUPRFsSEO. SCAR RETURNS THE slv CHARACTER BCD OF IDENTIFIERS AND STHINGS ANO ThF uALUE OF NUMBERS . ' 1 SAME AS 5 E/CEPT THAT MULTIPLE BLANKS ARE COhPRESSEO TO SINGLE HANKS . SCANMOOE s 5 RETURNS EVERY CHARACTER SCANMOOE 3 f)R SCANMODE = 4 THEN BEGIN NAMEO J= 0; IE NXTCHR = IF NxTChR SCAR. 3 IF NvTCHR TN AlfACOI THEN ALpHAgFT ELSE b E r, I n SCPAT^Ht 01 ' =(»: REpLACF pQInIER(SCRATCH)+^ WElGHTSr 0] ; IF SCRATCntm<4ttSE THEN SYMBUFIOJ := -jUHfrH yCL i t< 0. ) FLSE NXTCHR s »." THEN X SYMMHFI 1:=" wj " " THE nI NEXTrHAR ( TRUF ) IN LOOKAi^AlNin! THEN LASTCHARACTER ELSE TN ALFAtOI THEN ALPHABET BY NxTCHR FOR 1 WITH IF beg In T w s T I : - a n v a n c E C H a r ; SCRATCufni ! = «j| REpLACF P0iNTER(SCRATCw)+5 BY NXTTHR FOR 1 WITH WEIGHTSrn] ; IF SCRAlCHtO] < BASE THEN SYMRUFIOJ «= WUMERICLIT(0»1 ) ELSE 00058300 0005840O OOO^BsDO ;00058*oo 00058700' 00058800 00058900 00059000 00059100 00059?00 00059300 00059» IF NAME') < 10 THEN COMMENT OTHER THAN SIMPLE CHARACTER > SCaR:=^ ! = IF SCAN^nOE = 4 THEN SYMI3UF101 elsl TARLESEARCh( SYMqUF . CHARCOUNT » NAMFQ ) I ENn ELSE IF SCANHOnE = 5 THEN SCARj = LAST CHAW AcTEp ELSE lF SCANMOnE = 1 Then f)U S^Ap !=LASTCHARAcTFW UNTIL NXTCHR NEQ " " F.LSE SCANNEwRHRJa TRUE ; ENO ScAR ; UEfInE MSTACk = cOMMfft TETTL a SEMTM* ; UEFInE LEfTPRFC = [29I6]#. RlTtPHFC a [23»$j#, whicHPrF.C a [35:6l*» whiCHExec = rai:*si#» WDROLiNK c tl2»13)# • L I S T C 1 1 N T F I F L n = C A 5 ! 9 ] i , * L I S T c 1 1 m T f L I S T c u ^ T 1 ) = PS C L I ST cHiiNT 13 LASTEETCw = NAMF.OS, SECANT I CS{ SE;1 ANT I CSl , S^mANT I CS2 , SE-MANT PFC,lN FIRST :- SEMANTICS? : LAS ExEC(SEMA;gTlCSt \ EN[)#f PM9 = cUMMCfIRST -10]^.pM« PM/ = CuMMlF j^S T - rt]S»P'-16 P H 5 = c « fl 1 F I » S T - '-].-. P -i '4 P A 3 = c U M M I F T R S T - ft ] « » p ^ 2 PMl = cU'>'.i^ f IRST - ?J*.pO = C U M , i [ r T R S T 1 a , P ? = C U l I ■ i r F I " S T + 3 i ff , p/4 = cN'-inI fI RST + '4]«. pft = C u' 1 ' ' C f I»c,] ■■ ,p>? - Cmmmcf P?3 s CUMU[FIRST *2? ]»>??.<* = C'lMHlF I RST IHS T IRST IRST TRST IRST TRST IRST IRS T IRST IRST IRST IRST IRST I W S T TRS T IRST - 9 iit , - 7 J" » - 5J»» " 3 J * » - 1 i« , + 1 J** + 3 j#» + r i J 5 » + 7J«. + 9 J • » ♦ H Ji, ♦ 1 3 J " » +l s Jr, + 17 j", + 19J» . ♦ 2 1 J rf . +23 J ft* 0006A700 0006AMOO 0006A900 0006SnOO 0O0651 no 0006520O 00065l0:i 00065/iO^ 0006550^ 00065601 0006570" 00065HO"! 0006590m 0006600m 00066101 00066?00 00066301 00066 P35 = P37 a P39 s PLAsT CUMM[FlRST + 24i«,p26 CUMnU-IRST ♦ ;>*]#. p?8 CUrtilf FIRST +2ft]#»p30 CUMM[FIRST +3o]*.P32 C U M n [ F I R S T ♦ 3 ? ] * . P 3 4 C U M !1 C F I R S T + 3 4 1 * » p 3 6 cqM'U first +3aj*.P38 comhcfzrst +38]#»p«0 = CUMMtLAST)-- | CHMMtrlRSJ *?Sj#. CUMMlrlRST +?7U, CHM^ltriRST +?9J#, COMM[rlKST +31J#, CDMMfFlRST +33J«» CriMMlrlKST +3SJ*, C n MM[riRS T + 37 J ff . CHMMtrlRST +39 J tf , ? k S ( T w S 7 I i . % COhhC T w S T t 3 ; PPOCtDURF GAP <«i> VALUE N X INTEGER N j HEGIN ••OR TWsTIj=»LRS STEP -1 UNTIL H UU (?E G TN RS [TWSTUljjs CUMMtTWSTl + 1 1 1 = end » L « S t * L R S +■ 1 j CUMMtN] ; = RS[N] j- Uj END J ppUCt-OUWF DELETE ( M, in) . VALUE ,{ . N • INTEGER H'N, * WEgIm IF n = thFn BEr,lN gAPC") ;rs(*1 '"-l IFNO ELSE * BEGIN IF MU'l + N LEu LPS AND N|sN,i > 6 ' % THEN FOR lwSTIi"H STEp 1 UNTIL LRS UO X BEr.IN RSCT'VSTT-.m) J = RSCT^STI M % COMH[TrtSTT-N] laCOMiUTlnSTl H % ENn; * LRS: a LRS-N; % End; end; % RfAL PROCEDURE FEtCH(N-1)I * V ALUF MH. I ANTEr.ER MD 1 BEGIN IF NO > LKS THEN BEGIN COMH [ LRS := LRS + 1 ] := SCAR ; FETCH := RS [LRSl t= MAMEOJ IF MO > LRS ThEN Bfr,lN ''RITECLINF.IJVALIDRS^EFERENCE) I Nfl J» l./CNHlsO) ENin l END ELSE TF ND»LRS THEN FETCH! = LASTFF.TCHi s RStN'7:i ELSE W H 1LE FETcH'^LASTFETcH^RSlNais-l 00 nt-LETE(NO' End j RnCEUURE RtGi.j IF UsEPUlNT 1 USEPT THE r M >C 1 1 r- UsEPI := F/VLSE j PT la POTNTFHC PJlNTtOI ) C 7 7 4 00077S00 00077600' 00077700 00077800' 00077901' 00078000 00078100 00078?00 0007830O 000«270n 00082801 0008290') 0008300* 00083l0't 00083?0o 00083300 000 ^y "HASN'T BEEN REPLACE POlNTERf PUlMTCOl ) rsY " " FOR 78.; hh itf cl ime* < y 1 1> » "***** o l ?/ p a r 5eR ***** n I. ?/ PARSER ***** //// "ALL STATEMENTS ENTERED A E , IS.IED ** IncORRFct STATEMENTS ARE rsfR E ,1 OT SCANNED WITH A »', V f i)4cni"> ) PREVIOUSLY DECLARED" » f)L2/PARSE K ***** 0L2/P E ME ^TS ENTERED FLAGGED UNDER THE FIRST CHARACTER ***** BimLEaN "ASTE.^nnnLEAN : HRSTCnL 1= 1 t numErRs »« : *RITF (STATION. <" RE ;,£ D'lE K Tu TY pE 'FINISH* TO TERMINATE OL?/ PARSE ">> i WHILE LNn MOT FINISH DO 4EGIN TWSTINITIAI i READALI'iE : IF CALL TnfN ■RITE •( STATI 0N» O'PARSE CU'-iPLE TL "» t\ "00 «> ) E, s£ ""KITE t STATIDH»<" d ArsE lNrQHP|.ETE' , M ,, 00">) NRITF (STATION. <"A LISTING Of YOUR STATEMENTS IS i5ET«G PRlNTEU". /,ft n o«/"pIcK IT UP AT THE ROUTING •< T NO'.U" . /.i "00 "> ) , H RITE (STATION. F 1 rj A l • N = i"ERK,s> ; END : ENo : i; COmME^T ENnOFPROGBAitDEFl-ME . IS INSFRTEO RY T -/ST65 BEFORE THF FTNAL 'END IN ThE A I . - n ) SOURCE CODE rOH Ut.?/pARSER. EvcERT FOR THF TNSTR"C tI - mS SElTIw't T !) F ^ I '" E ; >F »lGTA& AN'J T*E LuCaTION OF THE LAST rE^EK-vLu t.u^u T - F] 1 G T A ^ AND TIUKE FILLING f-IgTAR* THE INSTRUCTION »EN L )iJFPRnGRAMi>EFTNE« IS T HE FIRST L /,F CUT A RLE INSTRUCTION IN UL2/RARSER, n L?/P^RSER C.inSiStS i,F a ^E R IES r)F PRnCEDURE CALLS. ENnOFPRO^RAitnEEl .it C f 'NTAI'iS THE INITIALISATION NFCESSARy FOR THE ENTIRE nR'Jr,! 00087S01 0OO8760'i 00087700 00087300 0008790 ) 0008800^ 000881 0" R000 R 8?nn .00088101 O0088'i00 00088S00 0008«600 00088700 0008880^ 0008890') 00089QOO 00089100 000«9?0r> 00089l0n 00 08 9/100 00089SO" A00089AOO R0008970 U00089HOO 00089900 00090000 0009 0100 0009020') 00090100 H00090/iO'T 00090SOO 00090600 00090700 00090800 000 9 9 0009 1000' OOOQl 10M 0009170 >' 0009110^ 00091/(00 ono^lson 916 '0009170D 00091^01 00091900' 9 ? 1 > 9 210 00092P0T 000^2 3 00 0009?/i00 9 2 s 9 2 6 0.') 0009?70n 00092800 83 nEr,lN UNTIL THF. "HRl) 'FINISH' Is FmTFRFO AS INc-Ht, •CALL' IS rjFFlNKO BY T Si**) Tn MF TMf* BOOLEAN PPfjCEDUWE ♦TFSTsTATrorMT 1 » A in TuERrrnpE _ . I LL T Nj T I A TF IhE haps*" rPR *tatf'\nt a< Mine" i«i ,>L2'T rtS T« T Mr S„nRc E Mk F n S TwsTftS IM TmF GLnEWATIUN nr IU?/pARSFH. IF CALL " TM UPON rEturm* TuEm 'hE dAp«;Eh ri a s wEArnEn a tfr tiNALNnot- In Tuf pApSlNb STflncllHEi 1^ C^LL a rALSE HpON K t T 1 1 K N . UiEM ThF pApSE HAS FaILEj wIT^Ih I M E TRFF» ANr) ThE iNpUl S'RHr i(AS NUT BEEN cn-'PLFIELY EXAMINED, I cumifnt secuno unmatched hekjn i 0009 0009 ono9 0009 000 9 9 0009 0009 0009 00 9 0009 000° oooy PoO'i 300 3100 3 ? 'V 3 3 n 3/400 3510 3 son 3?nn 3 <(1'1 3 1 n ftnod 410 84 APPENDIX D FILE MAINTENANCE The files 0L2/SYNTAX, 0L2/TWST, 0L2/SKELET0N, 0L2/PARSER, and 0L2/INF0RMATI0N are stored on small tape number 210, named 0L2SYNTAX, which currently is kept in the B65OO machine room in Coordinated Science Laboratory. All of these files except 0L2/PARSER may be modified using the file editing features im- plemented on the B6500. The file editor and its use are des- cribed in Able (5)« Card versions of 0L2/SYNTAX, 0L2/TWST, 0L2/SKELET0N, and 0L2/INF0RMATI0N are available from Professor J. R. Phillips of the Department of Computer Science. The current version of 0L2/PARSER was generated by the TWST65 compiler-compiler on the B6500 from the files 0L2/TWST (Appendix B) and 0L2/SKELET0N (Appendix C), which are maintained as noted above. It is advisable to place the card files on disk before regenerating 0L2/PARSER; tape files must be placed on disk before they can be used. To establish a disk file from cards, run the following job. The . ' ? ' character indicates an illegal punch; an illegal punch in column one denotes a control card. 85 ?USER = ?EXECUTE CARD/DISK ?FILE DISK = 0L2/TWST (or other file name) ?DATA ?END To load the tape files to disk, first ask an operator to mount small tape number 210 without a ring. Then, from a terminal (see Appendix E for information about Hazeltines), enter the following commands. -SHIFT-N-LIBMAIN COPY QL2/TWST, 0L2/SKELET0N FROM 0L2SYNTAX (or other file names) END Once the files are on disk, they may be modified using the editor as described in Abel (5). 0L2/PARSER is generated in two passes, one through TWST65, the other through the ALGOL compiler. First, run TWST65. ?EXECUTE TWST65/COMPILE ?FILE SKELETON = 0L2/SKELET0N DISK SERIAL ?FILE CARD = 0L2/TWST DISK SERIAL ?END After the previous job has run to completion, run the ALGOL compiler. 7C0MPILE 0L2/PARSER WITH ALGOL LIBRARY ?ALGOL FILE CARD = 0L2/S0URCE DISK SERIAL ?END 86 It would be best at this point to have small tape number 210 mounted with a ring and to store the new versions of 0L2/TWST, OL 2/ SKELETON, and 0L2/PARSER on the tape. See Abel (5) for details on using the library maintenance routine. Previous versions may be kept for backup. 87 APPENDIX E 0L2/INF0RMATI0N 88 **** WHAT YOU NEED TO KNOW TO USE THE OL/2 INTERACTIVE PARSER **** THtS UOCUmEnT HAS THREE SECTIONS — SECTION 1 UEScRIHtS THE HAZELTINE TERMINALS AVAILABLE IN THE B6500 MArHI^E ROOM. ^EcTlON 2 DETAILS THE PROCEDURE NECESSARY TO LOAD "OL*/PARSER" INTO THr b°5oo system. HCTION 3 EXPLAINS HnW TO USE "ni-2/P ARSER" . ***** SECTION 1 ***** THrKE ARE USUALLY FlvE OH Sl< HAZEtTlNE CRT TERMINALS UPERATING IN THE p65°0 MACHINE ROOm. THE TERMINALS TRANSMIT AND RFCclyE OA I A IN THREE MOn L S» CONTROLLED HY A S^UCH UN ThE REAR OF THE pEylcE LAbELED - r ULU - HALF - HALF pUF F - . THE FEATURES OF THE -HALF RUFF" AND "HALF" MOnES WILL RE dESCwIpFU. IN THt. -HALF RUFF" Mont. CHARACTERS ENTERED AT THE TERMINAL ARE DISPLAYED At A HIGhEr INTENSITY THAN CHARACTERS WRITTEN p Y THE SYSTEM AN n A«E CALLED FORFRROUNIJ CHARACTERS. TRANSMISSION OF AN INPUT STRINr, IS ACCOMPLISHED BY DEPRESSING THE -SHIFT- AND -xMIT- KEYS SIMULTANEOUSLY. A SnLlD RECTANGLE IS DISPLAYED AT THE SCREEN POSITION FRoM WHICH TRANSMISSION vAS EFFECTED. AND A CARRIAGE RETURN AND LINE FEFU tOLLOw THE TRANSMISSION. IF THtRE IS A CHARACTER IN THE LAST f 7ft) POSITION OF THE HA7ELTINE LlNE> ANY SUBSEQUENT ENTrY WlLL OVERWRITE TmAT CHARACTER. YUu WILL BE UNrtBLt- TO GET A CARRIAGE RETljRN ANn LINE rEEQ UNTIL TRANSMISSION IS EEfEC'EQ' WHICH WILL OVERWRITE THE CHARACTER IN POSITION jTt, ALsU. IN THjS MODE THE BACKSPACE ( CHARACTER DELETE a -SHIFT-U- ) CAnSE^> A LEFT-PUINTlNr, ARROw TO RE DISPLAYED NEXT TO THE INCORRECT CHARACTER, AND THE CORRECT CHARAclFR IS DISPLAYED NEXT TO I HE ARROW, THF Nt-T RFSuLT IS THAT THREE CHARACTERS ARE REoUIrEl) TU OpIAlN ONE codREct Entry, in thk- -half" mode ( male duplex ), user entered characters are Dlc;PL A YED At the samf jntensity as those written my ThE system, the RArKSfAcE (-SHIET-T) CAUSES THE CURSOR ON THE SCREEN TO rA C « UP TO THE IN r URKE c T EnTrY sil TriAT I T ■ cAN BE nVERWplTTEN. TYPING ErrlIrs THEREFORE HO NUI IMdAiR SCREEN lE«I HIL I T Y • TRANSMISSION OF AN Iwpljl STRING IS ACHIEVED RY HITTING "CR"« HOWEVER. IN THIS MpDF* AFTER a CHARACTER IS ENTERED AT POSITION T 4 , THE TEoMl^AL FMITS A RFEp ANu AUwANcES ThE CURSOR TU THE FIRST POSITION OF THr Nt-xT LINE, "Ol_2/pARSER" "ILL NOT ACCFPT INPUT FROM ThL NEW LINE» HO w EvtR, TF YOU THEN HIT ~CR-» '*OL?/PARSER" WTLL REcElvt- A FULL 7 4 CHftNAl'TERS of INPUT. IF POSITION 7U 11CCURS In THF MIDULE jF A KpYW n RD OR ALPHABETIC OR NijMfrIC STRING, mil MEED NOT DELETE THE F'«TIRE LI N E f ArCOnPLlsHFD RY -CTRL"D-). INSTEAD. HIT THE HACkSPAcE FNUUGH TIMES TO RE"UVE ThE PARTIAL STKINi,, OOOOOIOO 00000200 00000300 00000/400 0000050't 00000*00 00000700 A 00000900 00001000 00001100 0000120T 00001100 0000140 () 00001500 oooouoo 00001700 1 s 00 0019 00 00002000 00002100 00002200 00002300 00002400 00002500 00002*00 00002700 0O002SO0 00002900' 00003000 000031 00 00003200 OOOO31OO 00003400 00003500 00003*00 00003700 00003300 00003900 0000400" oooomoo 00004200 00004300 00001400 00 00 4500 00004*00 00004700 00004*00 0004 900 00005000 00005100 00005200 ; 00005300 00005/iOOi 00005'jKn 00005420, 00005430 89 I rLCUMMEnO USING T Hr "HALF- Mo»E »HEN RUNNING "OL2/P aKSFR" Rrriner rur PArKS^AClNG FEATURE IMPROVES LEGIhRITY AnU All OW* THr MAD,cr2 E £f ctRL-e- •Cp FXCLAMatIpn M ARK IT IS EoUTVALENT TO THE EBCDIC CHARACTER »|' TO "0L2/PARSER" LINE DELETE USED TO DFLt-TE AN CHARACTER MUST BE ENTIRE LINE TRANSMITTED HHEN AN ERROR IS MAOE. IN -HALF RUFF" MOUE. THIS WRU ASKS THE OAlA COMMUNICATION SYSTEM TO IDENTIFY ITSELF IT A GOOD uAy TO FIND WHETHER OATa-COM IS UP. TRANSMIT rnR "HALF" MODE ( CARRIAGE RETURN ). •ShIFJ-xMiT- TRANSMIT FUR -HALF bUFF- MODE. FOR MURE INFORMATION ABOUT THE HA/FLTINES AND THE B6500 Q fl TA COMMUNICATION SYSTFM. CUNSULT "ThE LITTLE GULDEN hOOk UF THE B6500". available Through ili.iac iv documentation, or a listing of the file "EniTUR/oncuMENr". Available through the routing window in .the b*50o R0n M » ***** SErTlON 2 ***** since "ol?/parsEr« is not a system RESPONSIBILITY OF THF USER TO LOAD MAv Bt utiL T ze:d. PROGRAM ON THE R6500. I I is ThE THE PROGRAM INTO ThE SYSTEM SO IT "0| 2/KARSER« IS STQRFn ON SMALL TApE NO. ?10» TApE MUST RF MOUNTED AND "OL2/ pARSF R" MUST qF REruRt t h E PRnGRAH Cam tit' HU U . CALLED "UL2SYNTAX", THIS COPIED FHUM IApE TO DISK IF YOU ARE RUNNING In THE B6500 MACHINE ANrj AJ>k An OPERATOh TO MUllNT SMALL TAPE A mINL TRaCk TAPE. ROOM* GO TO ThL ROUTING WINDOW NO. ?10 WITHOUT A KING. IT IS 00005500 00005*00' 0000570O 00005800 00005900' 00006000 00006100 00006200 00006300 00006400 00006500 0000660O' 00006700 00006«OO 00006900 00007000 00007100 00007200 00007300 00007 u 00 00007500 00007*00 00007700 00007800 00007900 00008000' IS00008100 0000820 00008300 OOOO8/4OO 00008500 00008*00 00008700 00008800 00008900 00009000 000091 00 00009200 0000930 0' 00009400 00009500 00009*00 0000970O' 00009800' 0000990 0' 00010000' 00010100' 00010200' 00010300' 1 n 00010500' 00010600' 0C01 0700 00010800 00109 00' 1 1 00011100' 90 IF YQU ARF NOT RUNNING IN THE B6500 MACHINE ROOM. IT ^UUln BE BEST TO CAi L J33-71AB AND ASk AN OPERATUR TU MOUNT SMALL TAPE NO. 210 WITHOUT A plNli B^FUrE yUU nlAL YOUR TERMINAL INTO THE SYSTEM. YOU CAN ALSU RRnADl'AsT A MESSAGE OvLR nATACOM Tn ASK ThE OPERATOR TU MDUNT T HF TaPE» BUT THERE Is NO GUARANrEE THAT ANYONE WILL SEE THE MESSAGE' TN THt MACHINE ROOM. THE HAZELTlNES ARE USUALLY LEFT nN» sU ALL YOU NErU UO Is FIND A rRFF TERMINAL. IF IT IS NUT ON AND Y U II ARE NOT FAmIUAR hOw TO DIAL II INTO THE SYSTEM OR TURN IT ON. ASK SOMEONE FOR HE| P. OTHERWISE. YOll CAN CONNECT yUUR TERMINAL TO THE B6500 BY DIALING 33^-80Bx» WHERE X = n.l»...»8. BE SURE TO SET YOUR TERMINAL FOR A TRANSMISSION RATE of 300 HAUO. HIT -CTRL-E- TO DETERMINE WHETHER nATACOM IS UP. ,1 F H IS' IT WILL REs^O N D WITH A MESSAGE. IF YOU NUw CHOOSE TO S^NU A MESSAGE TO ASK THE OPERATOR TO MOUNT «0l2STNTAx", TRY somfthing similar TO -sh1fT"n- to all operator please mount small TAPF 210 NO RING THF INITIAL WORDS «Tn ALL" ARE ESSENTIAL SINCE THERE IS NO WAY AT THIS TI.«L 10 SENn A MESSAGE U'^LY TO ThE OPERATOR. THF SEQUENCE OF INSTRUCTIONS NECESSARY TO LOAD "UL2/PARSER" IS » -SuIFT-N" LiBMaIn USFR a CAcPHlLLlPS TApLDlR 0l2sYNTAX *this calls the library maintainance Routine^ w hic displays a colon when ready to accepi a command. XUSLR CODES ARE Nflw NECESSARY ON THE H6500. %1HIS ASKS FOR THE DIRECTORY OF »UL?S YNT AX" . IT IS A GUOD WAY TU FIND WHETHER THE TAPE HAS BEEN MOUNTED YET. COpY 0L2/PARSER FROM 0L2SYNTA* XDUN»T USE THIS COMMAND UNTIL THE TApL IS MOUNTED. IF YijU NEED a LISTInG rjF "nL2/SYNTAX" FuR REFERENCE PURPOSES wHILF RUMNING "OL^/'PARSER" USE COPY 0L2/PARSFR.0L2/SYNTAV FROM OL^SYNTAX INSTEAD. EN^ XTHIS WILL TERMINATE LiBRaRY M A I NT A I NA nC E . N0 W "0L2/pApSER« Is IN THE SYSTEM AND READY TO RUN. IF YOU DESIRE A LIFTING u r "0L2/SYMTAX" TYPE -SuIFT- N - Run DISk/PpinT> FILE DISK = 0L2/SYNTAXJ EnD PRtUR TO RUNNING "0L2/RAKSER". ***** S F C T I i N 3 ***** 00011200 oooinoo oooiiaoo o o o 1 1 «s o n 00011600 00011700 00011*00 ooohqoo' 000120 0- 00012100' 00012200' 00012300' 00012400 00012500 00012600' 00012700 00012800' 00012900 00013000' 00013100' 00013200' 00013300' 00013aOO' 0001350O 00013600 0001370O H00013800' 00013900 OOOHOOO oooiaioo 00014200 OOOHlOO o o o la a o o oooiasoo 00014600 oooia7oo oooia^oo 000H900 00015000 00015100 00015200 00015300 00015400 00015500 00015600 00015700 00015800 00015900 00016000 0001610O 00016200 00016300 016 4 00 0001650O 00016600 0001670O 0001680') 91 THr FULLUklNG COMMANDS HILL INITIATE M 0L2/PARSER" WITH YOU« TERMINAL AS INPUT ANn HUTPUT. -SmirT-N- CC USr« B CACPHILLIPS *ONCt REMOTE CONTROL DISPLAYS A COLON. RUM Of-^/PARsERI ENn "01.2/PaRSeR" will display 60 AHLAD i WHrN IT EyPECTS A NEW STATEMENT. TYPE YOUR STATEMENT. OR Up TO 7 4 CHARACTERS OF THE STATEMENT. FOLLOWED BY THE APPROPRIATE TKANSMlSSlON KEv < a F NECFSSARY — SEE SECTION 1). NUMERALS' IDENTIFIERS. AND KEvWUKQS fiAMNOT BE CONHnuEu FROM nNE LINE TO THE NE*T« if an Entire statement has reen entered and is parsed correctly. «0 L 2/ParSeR" WILL DISPLAY state"Ent parses as statement type>--any errors noted beluw PAbSE complete GO AHLAD » YOn should now enter yuur next statement. if thl statement is incomplete and parses correctly to the end of WHATEVER hAs BEEN ENTFKED. "0L2/PARSER" WILL DISPLAY statement Pa r ses as --any errors noted beluw continue t YOn SHOULD NOW ENTER THE REMAINDER OR Up TO 74 MORE CHARACTERS Of ThE statement, "0| 2/^ARSER- WILL DISPLAY THE MESSAGE CONTINUE « AS LUi«G As IT FINDS NO ERRORS IN INCOMPLETE STATEMENTS. Il MAY CDNSlDE A ^TAIEmEmT TO RE INCOMPLETE THAT YOU THINK IS COMPLETE. *HEN THIS OCrURi>» USUALLY THERF iS NU TERMINAL SE'llCOLnN OR THE SEMICOLON HAS RErN PARSED AS A NONTERMINAL SEMICOLON. AND "0L2/PARSER" EXPECTS MORE DA T A. TH T S frEATURE ALSo ALLn w S YoU TO ENTER BLANK LINES Fr,R THE PURP|)SE OF PDtTT^NG YOUR PRINTED UUTPtJf MlTHOllT CAUSING UNNECESSARY ERRORS. A STplNo OF BlANkS WILL N DI INITIATE ANY PARSE. BUT VlLL CAU&E THE PARSER TO WRiTE THE MESSAGE "CONTINUE t " . IF m l 2/PaRSER m DETECT 55 An ERROR Im THE TnPUT STRImGh IT WILL DISPLAY" STATEMENT PARSES As --ANY ERRORS NOTED BEL^W < « 00016900 00017000 00017200 00017300 00017400 00017500 oooi7» papSe incomplete GO AHtAtl t KUSUALLY* ALTHOUGH SOMtTlMES 1 E MESSAGE "PARSE COMPLETE" ^m APPEAR. WHrKE ThE «<» CHARACTER IS DI5PLAYF0 IJNOER THE FIRST CHARACTER TN UT STRTNp, NOT Sr*NN E D» ANT) ThE 'S ANn »S REfEK TO THE SYNTAX OF 01/? AS DEFINED IN "Oi 2/i>YNTAX«. of the HSijALl-Y ThE OCCURENCr UF AN ERROR .ILL CAUSE THE PARSE TO bREAK DOWN WITHOUT RrAcHING A TFRHINAL NnDE l, r THE PARSING TREE. IN I HIS CASE. THF Mt-SSAc,E "PARSE INCOMPLETE" IS DISPLAYED. ImOiCate t h e path taken d w n t hf paRSi t Hf LiS T n F ERRqR MESSAGES WILL TRrjE t-OR THE INPUT STRlNb. THE ERROR MESSAGES wlLL HE As SPECIFIC AS THr STNTAy riF OL/2 PFRMlTS. *HENE v ER SEVERAL ALTERNATIVES OCCUR wITHI A sYN.'.AcTtc UNIT. nN| v GENERAL rtESSAf.FS ARE POSSIBLE. KEptR TO THE Listing qf « n L2/SY NTA x". generally, t h e fips t m e ss a ge will be the m s USEFUL. THr EKROR CAN ALwAvS rtE FOUND IN T H E ELEMENT iMMEnlATFLY PKEDEDlNG THE FRpOR MAKkEr (•<•). UNLESS AH EARLTER ENTRY FORCED "0L2/PAKSFR" DOWN AN INtORRrCT rRANch n r THE PARSlN^ TREE. ( p-flR EXAMPLE' TYPING 'SFT' IN<;TE«D Op 'LET' FOR A STATEMENT.) IF THt MESSAGE STATEMENT PARSES As --ANy ERRORS NOTED BELUW RorS Nut APPEAR' n R A N()T"AR I T H '^E TjC STATEMENT C a"SES MESSAGES " RE r LRRlN(. Tn <0L2LF ?! hA NUS I DE > » THFN MOST PRORAflLv THE STAlEMFNT kE y wO» h ^bbbH BSKfi