!TITLE Elements of the language !KEY IMP80 is a high-level block-structured language. Relative to Algol 60, it adds program structuring, data structuring, event signalling and text handling facilities, but removes (or retains in a modified form) intrinsically inefficient features such as the Algol 60 %name-type parameter. ! | 94 ^ | 126 ~ | | 31 US | 63 ? | 95 _ | 127 DEL| |_______________|____________________|_________________|______________| The use of the character set is summarised in the sections below and described in detail in the rest of the manual. However, some general points about certain characters should be noted at the outset: !PAGE a) Quotes Several language constructions call for one or more characters to be enclosed in quotes. Within quotes all characters are significant and stand for themselves; thus, for example, space, newline, and percent characters may appear between quotes and stand for space, newline, and percent. Two quote characters are used: ' - character quote " - string quote Examples: 'A', ';', '"', '!' "String", "sealing wax", "!" If it is required to include the delimiting quote within the text it must be represented by two consecutive quotes. !PAGE Examples: '''' - the character quote "A ""big"" dog" - a string of eleven characters However, note '"' and "it's mine". b) Spaces Except when used to terminate keywords or when between quotes, space characters are ignored and may be used to improve the legibility of the program. c) Lower case letters Except when enclosed in quotes, lower case letters are equivalent to the corresponding upper case letters. !PAGE d) Non-graphic characters The ISO characters with no graphic representation have code values less than 32 or greater than 126. Any non-graphic characters can be included within quotes in an IMP80 program, but only one, the newline character (NL), is included in the syntactic definition of the language (see Appendix A). This has the ISO code value 10. {EMAS IMP80: all characters with code values less than 32 are treated as spaces, apart from NL (ISO code 10) EM (ISO code 25) - terminates program SUB(ISO code 26) - causes a syntax fault It ignores DEL (ISO code 127) and maps all codes greater than 127 according to the extended Regional Network Code (which is detailed in Regional Communications Memo JID/78/M20.4). } !PAGE {IMP77 Except for NL (see above) all characters not enclosed in quotes and with ISO codes outwith the range 32 to 126 inclusive are treated as spaces, but will be sent to the listing unaltered. The character FF (form feed) may be used to cause a new page to be taken in program listing files.} !> ! %on %event .... %start %finish %end %of %program !PAGE Only the delimiting keywords %begin and %end %of %program must be present. However, assuming that all the types of statement above are represented in an IMP80 program, the effect of running the program on a computer is as follows: First, storage space for the declarations is obtained. Conceptually, all the space is obtained at once - there is no defined order of execution of declaration statements. The procedure descriptions are skipped, as are the statements in the %on %event block, and the first of the executable statements is obeyed. Thereafter, the statements themselves define the sequence of execution ("flow of control"). Control passes to the %on %event block if one of the events defined in the %on %event statement occurs whilst executing a statement. The %on %event block is optional and often omitted. !PAGE Here is an IMP80 program: %begin %integer A, B, SUM, DIFFERENCE, MAX, MIN MAX = -1; MIN = 5000 %cycle READ(A) %exit %if A=-1; ! End of input. READ(B) PRINTSTRING("Input values:") WRITE(A,3); PRINTSYMBOL(',') WRITE(B,3) SUM = A+B; DIFFERENCE = A-B PRINTSTRING(" ... Sum is") WRITE(SUM,3) PRINTSTRING(", Difference is") WRITE(DIFFERENCE,3); NEWLINE %if SUM>MAX %start MAX = SUM %finish %else %if SUM ! ! !)| | | | ## (or \==) & ( ) * | | | | \ \\ + , - | | | | -> . / // : | | | | ; < <- << <= | | | | = == > >= >> | | | | @ \ (or ~) _ { } | | | | newline space | |_________________________________________________________________| !PAGE {IMP77: \ and \\ may be replaced by ^ and ^^ respectively.} {EMAS IMP80: \ and \\ may be replaced by ** and **** respectively.} The special symbols are used in IMP80 in various ways: * as operators (arithmetic, string, record, relational, logical) * as separators, e.g. (..) {..} : ; , newline space * in constants, e.g. 3_201, +27@4, -17.6, X'8F', "Constant" * in record subfield references, e.g. TAX(MONTH)_OVERTIME * ! as an alternative to the keyword %comment !> ! !> ! !<%include statement !KEY A file of IMP80 statements (terminated by the statement %end %of %file) may be included in a source program by giving a statement of the form %include where is a string constant representing a system-dependent file name. Refer to the relevant section of Appendix B for details of any implementation-dependent limitations on the use of %include. Example: %begin %include "WXYZ83.EXTSPECS" %integer TIME, DISPLACEMENT, ... : : Note that the %include statement appears in the program listing generated by the compiler, followed by the contents of the file referred to (including the %end %of %file). The %include statement should not be followed on the same line of the source program by other statements, since the complete source line will appear in the program listing before the statements included, while in the actual program the statements following the %include follow the statements included. !> !<%list and %end %of %list !KEY Normally the compiler generates a listing of a program as it compiles it. The precise layout of this listing is implementation-dependent. The production of the listing can normally by controlled by setting a system option prior to the compilation. In addition, however, the programmer can control the generation of the listing by use of the statement %end %of %list, which inhibits the listing until the end of the program or the statement %list is encountered. The default is for the listing to be generated. The statements %end %of %list and %list may appear anywhere within an IMP80 program. Note that when listing is inhibited, incorrect statements and the accompanying fault messages are still listed. {IMP77: %end %of %list and %list are nested, so that two %end %of %list statements require two matching %list statements to switch on the listing again. This means that it is possible within an included file (see above) to control the listing of the contents of the file, without changing the listing status of the rest of the program.} !> !>