APPENDIX A: IMP80 Syntax

KEY ::= A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ::= {newline character} ::= {| character} ::= ! | " | # | $ | % | & | ' | ( | ) | * | + | , | - | . | / | : | < | = | > | ? | @ | [ | ] | \ | ^ | _ | ` | ~ | ; | <letter> | <digit> | <bar> ::= []... ::= %comment | ! ::= []...
::= | ::= []... ::= [, ]... ::= [] ::= . [] ::= [] [] [@ ] ::= _ ... | ' ... ' ::= | ::= ' ' | M' ... ' ::= " []... "
::= | | | <char const> | <str const> ::= + | - | \ | ~ ::= = | == | <- | -> ::= + | - ::= | -> | == | \== | ## ::= = | # | \= | <> | > | >= | < | <= ::= * | / | // | + | - | ** | **** | \ | \\ | >> | << | ! | !! | & | . ::= ( [, ]... ) ::= _ []
::= [] []... | | ( ) ::= [] [ ]... ::= ( ) | (*) ::= [] ::= = [, ]... ::= [[%array] %name] | %array [%format] <adecln> ::= [, ]... ::= [[%array] %name] | %array ::= ( [%or ]... ) ::= [, ]...
::= | ::= ( ) | ::= %integer | %real | %long %real ::= %integer | %real | %long | %byte [%integer] | %short [%integer] | %half [%integer] | %string<count> ::= | %record ::= [%alias " "] ::= [, ]... ::= [= ] ::= [[%array] %name] [%spec] [, ]... | %array [%format] [%spec] <oname> <bpair>[<constlist>]
::= %fn | %function | %map ::= %routine | ::= [[%array] %name] | <rt> [%name] <namelist> [<fpp>] | %name <namelist> ::= ( [, ]... ) ::= : ::= ( [, ]... ) ::= %own | %external | %constant | %const <%sed> ::= %system | %external | %dynamic ::= %of %program | %of %file | %of %list
::= [%and ]... | [%or ]... ::= [ ] | ( <sc> <restofcond> ) | %not <sc> ::= [%and ]... | [%or ]... <%wf> ::= %while | %for <name> = <expr> , <expr> , <expr> <%iu> ::= %if | %unless
::= [] []... [<assop> <expr>] [%and <ui>] | -> <name> [<app>] | %return | %result <assop> <expr> | %monitor [%and <ui>] | %stop | %signal [%event] <const> [, <expr>] | %exit | %continue ::= <%iu> ::= [%then] %start | %then [] ::= %else %start | %else <ci> | %else <ui>
::= <%iu> | %until <sc> <restofcond> | <%wf> ::= ; | ::= ...
::= %begin | <xtype> <decln> <s> | %record %format <name> <rfdeclistor> <s> | [<%sed>] <rt> [%spec] <name> [<fpp>] <s> | <xown> <xtype> <owndec> <s> | %include " <text> " | %switch <namelist> <bpair> [, <namelist> <spair>]... <s> | %on [%event] [, <integer>]... %start <s> | <ui> [<restofss>] <s> | <ci> <s> | %finish [<else>] <s> | [<%wf>] %cycle <s> | %repeat [%until <sc> <restofcond>] <s> | <name> [<app>] : | <name> (*) : | %list <s> | %end [<endlist>] <s> | <comment> | <s>

Notes

KEY * In the above syntax, items in italics are non-terminals, '|' separates alternatives, '::=' means 'is defined as', items enclosed in [..] brackets are optional, and items followed by '...' can be repeated one or more times. All other characters stand for themselves, except that {...} indicates a "descriptive" definition, involving a newline character or a character used in the statement of the syntax itself. * The case of letters is ignored in IMP80 programs except within character constants. * Space characters are only significant within character constants or following a keyword (%real, %if, %unless, %end, %not, etc.). * <type> definition: not all the types may be available in some implementations. * {EMAS IMP80: <type> definition: <count> replaced by [<count>]} * {IMP77: <op> definition: ** | **** replaced by ^ | ^^ . }
* Text preceded by '{', terminated by '}' and appearing between syntactic elements of a program is treated as a comment. Such a comment is also terminated by a newline character. * IMP80 statements can be continued on the next line with %c. The %c is not required if the break comes immediately after a comma. {IMP77: comment statements cannot be continued.}