@X @~
~L3 COUK1247
80
~V7 56 2 -5
~D10
~H                    MUSS
~
~
~D10
~H             BSC091
~D10
~MMANCHESTER UNIVERSITY  -  CONFIDENTIAL
~
~
                                                           ISSUE 9~
~V9 -1
~P
~V9 1
~YBSC091
~S~M~OBASIC COMPILER IMPLEMENTATION MANUAL
~S~M~OSection 9
~S~OSection 9. Fault and Reference Point Monitoring
~S~O1.1 General Description
~BThis module of the compiler is concerned with the output of
error indications and reference points for the begin and end
of each procedure.
~S~O2. Interfaces
~S~O2.1 Section Interfaces Used
~
   Section 1 :   (Compiler Description)~
   Section 3 :   (Lexical Analysis)~
~S~O2.2 Section Interface
~
Exported Scalars:~
   LAST.T~
   LAST.P~
   MAX.CH~
   MAX.N~
   MAX.MUTLN~
   LINE.NO~
   FAULTS~
~
Exported Procedure:~
   MONITOR.S~
   MONITOR.P~
   MONITOR.N~
   MONITOR.I~
   MONITOR~
   PRINT.STATS~
   INIT.S9~
~S11) MONITOR(MESSAGE)
~BThe type of message output is determined by MESSAGE as follows.~
~T# 16
~
~IThe seven least significant bits of MESSAGE determine the
error message printed out.  If bit 12 is set then control
is transferred to label RESTART in the main loop (Section 1),
this terminates compilation of the current statement.
If nit 13 is set then control is transferred to label C.EXIT in the
main loop (Section 1), this terminates compilation.
~BThe current value of I.PTR is used to place a marker in the
monitored source line to indicate the point at which the fault was
detected.
~S12) MONITOR.S(MESSAGE,CAPTION)
~BThis operates as MONITOR but in addition the CAPTION specified
by P2 is inserted in the monitoring message,
and no source line error marker is output.
~S13) MONITOR.P(MESSAGE,POSITION)
~BThis operates as MONITOR but in addition the error position
is given by P2.  If P2 is positive then it contains an
index into the itemised line, otherwise it is the negated index
into the source line.
~S14) MONITOR.N (MESSAGE, N.ID)
~BThis operates as MONITOR but in addition the name of the
entity whose namelist index is given by P2 is inserted in the
monitoring message, and no source line error marker is output.
~S~O5) MONITOR.I(MESSAGE,INTEGER)
~BThis procedure operates of MONITOR but in addition the value of
P2 is inserted in the monitoring message.
~S15) PRINT.STATS()
~BPrints some statistics indicating the maximum size reached in
the main lists of the compiler.
~S1~O3. Implementation
~S1~O3.1 Outline of Operation
~BOperation is straightforward.
~S~O3.2 Data Structures
~3
~T# 10
~
LINE.NO~Inumber of current line in compilation.~
LAST.T~Ilast used position in TLIST.~
MAX.CH~Ilast used position in CHLIST.~
MAX.N~Ilast used position in NLIST.~
MAX.MUTLN~Ilast MUTL name allocated.~
~0
~Y
~V9 -1
~P
~D15
~HFLOWCHARTS
~
~
~H                BSC091
~V9 -1
~F
@TITLE BSC09(1,11)
@COL 1S-3R-4R-5R-6F
@FLOW 1-3-4-5-6
@BOX 1.0
FAULT AND REFERENCE POINT MONITORING
@BOX 3
VARIABLE DECLS
@BOX 4.0
PROCEDURES IN MODULE
MONITOR.S.P.I[BSC09.1]
PRINT.STATS [BSC09.2]
MONITOR [BSC09.3]
MONITOR.S [BSC09.4]
MONITOR.P [BSC09.5]
MONITOR.N[BSC09.6]
MONITOR.I[BSC09.7]
@BOX 5
INITIALISATION PROC
@BOX 6.0
END
@BOX 1.1
#BSC09/1
MODULE (MONITOR,MONITOR.S,MONITOR.P,FAULTS,LINE.NO,INIT.S9,LASTT,LASTP,PRINT.STA
TS,
MAXCH,MAXN,MAXMUTLN,MONITOR.N,MONITOR.S.P.I,MONITOR.I);
@BOX 3.1
*GLOBAL 5;
$LI / ADDR [$LO8] NIL=;
$IN FAULTS,MAXMUTLN,MAXN,MAXCH,LASTT,LASTP;
$IN32 LINENO;
@BOX 4.1
*GLOBAL 0;
*CODE 8;
$PS MONITOR($IN);
$LS MONITOR.S.P.I($IN,ADDR[$LO8],$IN,$IN);
$PS MONITOR.S($IN,ADDR[$LO8]);
$PS MONITOR.P ($IN,$IN);
$LS MONITOR.N($IN,$IN);
$PS PRINT.STATS();
$PS MONITOR.I($IN, $IN16);
#BSC09.1
#BSC09.2
#BSC09.3
#BSC09.4
#BSC09.5
#BSC09.6
#BSC09.7
@BOX 5.1
$PS INIT.S9();
$PR INIT.S9;
0=>MAXN=>MAXCH=>MAXMUTLN=>FAULTS;
END
@BOX 6.1
*END
@END
///6
@TITLE BSC09/1(1,11)
@COL 1S
@BOX 1.0
EXTERNAL INTERFACE
TO MODULE BSC091
@BOX 1.1
$LA RESTART,C.EXIT;
$IN IPTR,SPTR;
$LO8[2000] SBUFF;
$IN MSTR;
PSPEC GENN($LO16)/ADDR[$LO8];
@END
///14
@TITLE BSC09.1(1,11)
@COL 1S-3R-7R-8R-9R-12T-16T-10F
@COL 13C-5C
@ROW 16-13
@ROW 10-5
@FLOW 1-3-7-8-9-12N-16N-10
@FLOW 16Y-5
@FLOW 12-13
@BOX 1.0
MONITOR.S.P.I(MESSAGE NO.,CAPTION,F.PTR,INTEGER)
@BOX 3.0
SELECT MONITORING STREAM
START A NEWLINE
AND PRINT THE LINE NUMBER
OUTPUT INDENTATION
@BOX 5.0
EXIT COMPILER
@BOX 7.0
MESSAGE TABLES [BSC09.1.1] MESSAGES 0 - 49
               [BSC09.1.2] MESSAGES 50 - 99
                [BSC09.1.3] MESSAGES 100 - 149
MESSAGE PSITION TABLE [BSC09.1.4]
OUTPUT >>>>* ERROR MESSAGE
AND NOTE <? POSITION
@BOX 8.0
OUTPUT SBUFF
INSERTING ??
AT THE POSITION OF IPTR
@BOX 9.0
NEWLINE
@BOX 16.0
ABORT COMPILATION
REQUESTED?
@BOX 10.0
EXIT
@BOX 12
ABORT CURRENT STATEMENT
BEING COMPILED?
@BOX 13
PROCESS NEXT
STATEMENT
@BOX 1.1
$PR MONITOR.S.P.I(MNO,CAP,F.PTR,INT);
$IN I,J,CH;
@BOX 3.1
SELECTOUTPUT(MSTR);
NEWLINES(0);
OUTLINENO(LINE.NO);
SPACES(4);
@BOX 5.1
-> C.EXIT;
@BOX 7.1
CAPTION(%">>>>* FAULT ");
#BSC09.1.1
#BSC09.1.2
#BSC09.1.3
#BSC09.1.4
OUTI(MNO & %FFF,5);
SPACES(4);
F.M.ST [MNO & %FFF => I] -1 => J;
F.M.ST [I+1] => I;
WHILE 1+>J < I DO
   IF F.M[J] => CH ='@ THEN
      OUT.CH (" " => CH);
      CAPTION (CAP);
   ELSE IF CH = '^ THEN
      OUT.CH(" " => CH);
      OUT.I(INT, 0);
   FI FI
OUT.CH (CH);
OD
NEWLINES(1);
CAPTION(%"  IPTR: "); OUTHEX(IPTR, 4); NEWLINES(1);
@BOX 8.1
0 => I
$WH 1 +> I =< SPTR $DO
$IF SBUFF[I] => CH & %80 = 0 $TH
OUTCH(CH)
IF 0 - FPTR = I THEN
   OUT.CH('<);
   OUT.CH('?);
FI
$EL $IF CH & 127 <<- 8 ! SBUFF[1 +> I] >= FPTR - 1 $TH
OUTCH('<);
OUTCH('?);
%7FFF => FPTR;
$FI $FI $OD
@BOX 9.1
NEWLINES(1);
@BOX 16.1
IF MNO & %2000 /= 0
@BOX 10.1
$EN
@BOX 12.1
$IF MNO & %1000 /= 0
@BOX 13.1
-1 => FAULTS;
-> RESTART;
@END
//15
@TITLE BSC09.1.1(1,11)
@COL 1S
@BOX 1.0
MESSAGE DATAVEC
MESSAGES 0 - 49
@BOX 1.1
DATAVEC F.M($LO8)
"Illegal syntax!"
"Statement contains too many characters!"
"Illegal character in statement!"
"Missing closing quote in character constant!"
"Character constant too long! - truncated to 255 characters"
"Too many characters in identifier! - truncated to 31 characters"
"Illegal syntax! - identifier expected"
"Use of this keyword as an identifer is illegal!"
"Statement label missing"
"Label not at start of source line"
"Statement@not implemented"  ::10


"Only imperative statements allowed here"
"Statement not allowed at this textual level"
"Label expected"
"Label must be less than 100000"
"Compiler table -@- full"
"Label^defined twice"
"Iconsistent data type on variable@"
"Invalid string length - default assumed"
"String length too long - length of 132 assumed"


"Identifier@not allowed as a simple variable"    ::20
"Array declarator expected"
"Identifier@already declared"
"Invalid range on bounds of array@"
"Invalid format string"
"Procedure@not available"
"Incorrect type on expression"
"Call operand is not a subroutine"
"Incorrect use of array name"
"Simple variable expected"

"Illegal expression, operand or identifier"  ::30
"Incompatible coercion of data types"
"Invalid channel expression"
"Invalid string array expression"
"Illegal use of array operands"
"Invalid use of parameter/subscript list"
"Invalid use of substring specifier"
"Wrong number of subscript expressions for array"
"Subscript expression of incorrect type"
"Invalid numeric array expression"

"Invalid string array expression"  ::40
"Invalid data type on operands for this operator"
"Invalid data type in string expression"
"Unexpected compiler fault at@"
"Too many items in assignment list"
"Invalid item in assignment list"
"Incompatible data types of items in assignment list"
"Data type of expression incompatible with assignment list"
"Output specifier given more than once"
"Illegal use of output specifier"


@END
//14
@TITLE BSC09.1.2(1,11)
@COL 1S
@BOX 1.0
MESSAGE DATAVEC
MESSAGES 50-99
@BOX 1.1
"Identifier not an array"
"Input specifier given more than once"  ::51
"Illegal use of input specifier"
"Array of strings expected"
"Illegal use of variable length vectors"
"Wrong number of dimensions specified for array@"  ::55
"Matrices can not be of variable length - only vectors"
"Statement processed but garbage follows statement"
"Incorrect@control construct - line ignored"   ::58
"EXIT DO not in a do-body"  ::59

"EXIT FOR not in a for-body"  ::60
"@not allowed after else-line in if-block"  ::61
"@is not the control variable of this for-loop"  ::62
"@is already a control variable of a for-loop"   ::63
"Channel-number not a positive integer"  ::64
"Channel-number only allowed in a subprogram"  ::65
"Inconsistent use of name@"  ::66
"Procedure@defined more than once"  ::67
"Previous call of@inconsistent with procedure definition"  ::68
"Too many procedure references in program unit - maximum is 128" ::69

"Parameter@not unique"  ::70
"Channel@not unique"  ::71
"Missing END@assumed"    ::72
"Wrong END statement - END@assumed"    ::73
"Incomplete@construct"   ::74
"Procedure@not defined"     ::75
"This kind of EXIT statement not allowed in main program"  ::76
"Wrong EXIT statement - EXIT@assumed"    ::77
"No def-let-statement in the function@"  ::78
"Line number@not defined"  ::79

"Wrong number of parameters"  ::80
"Parameter of incorrect type" ::81
"Incorrect parameter list"  ::82
"Use of name inconsistent with use prior to this program unit"  ::83
"Name already defined"  ::84
"Option already specified in this program unit"  ::85
"Statement only permitted in an exception handler"  ::86
"Protection block not allowed in an exception handler"  ::87
"Use-line only allowed in a when-use-name-block"  ::88
"Handler@defined more than once"  ::89

"Invalid use of end-when-line in protection block"  ::90
"End-handler-line only allowed at end of detached-handlers"   ::91
"@- a handler may only be referenced from a program unit or a single internal fu
nction"  ::92
"Numeric identifier expected"  ::93
"Internal functions are not allowed in in an exception handler" ::94
"Exception handler@not defined"  ::95
"File-attribute specified more than once"   ::96
"Ask-attribute specified more than once"  ::97
"Record.control.item specified more than once"   ::98
"Case-else-line occurs more than once in a select-block" ::99
@END
///14
@TITLE BSC09.1.3(1,11)
@COL 1S
@BOX 1.0
MESSAGE DATAVEC
MESSAGES 100 - 149
@BOX 1.1
"This case-item overlaps with a previous case-item in select-block" ::100
"Case-item of incorrect type" ::101
"Select-block without any case-blocks" ::102
"Second constant of case-item range must be greater than first constant" ::103
"Case-block not allowed after case-else in select-block"  ::104
"Case-line must follow select-line" ::105
"Numeric or string array name expected"   ::106
"RHS not a valid array expression"   ::107
"Array type incompatible with array being assigned to"  ::108
"No. of array dimensions incompatible with array being assigned to" ::109
END
@END
///17  9-AUG-83
@TITLE BSC09.1.4(1,11)
@COL 1S
@BOX 1.0
POSITION OF MESSAGES IN DATAVEC [BSC09.1.1]
@BOX 1.1
$LI/$LO16 P0=0,P1=P0+15,P2=P1+39,P3=P2+31,
          P4=P3+44,P5=P4+58,P6=P5+63,
          P7=P6+37,P8=P7+47,P9=P8+23,
          P10=P9+33,P11=P10+25,P12=P11+39,
          P13=P12+43,P14=P13+14,P15=P14+30,
          P16=P15+23,P17=P16+19,P18=P17+34,
          P19=P18+39,P20=P19+46,P21=P20+43,
          P22=P21+25,P23=P22+27,P24=P23+33,P25=P24+21,
          P26=P25+23,P27=P26+28,P28=P27+32,P29=P28+27,
          P30=P29+24,P31=P30+41,P32=P31+35,P33=P32+26,
          P34=P33+31,P35=P34+29,P36=P35+39,P37=P36+34,
          P38=P37+47,P39=P38+38,P40=P39+32,P41=P40+31,
          P42=P41+47,P43=P42+38,P44=P43+29,P45=P44+33,
          P46=P45+31,P47=P46+51,P48=P47+57,P49=P48+37,
          P50=P49+31,P51=P50+23,P52=P51+36,P53=P52+30,
          P54=P53+25,P55=P54+38,P56=P55+47,P57=P56+53,
          P58=P57+49,P59=P58+42,P60=P59+24,P61=P60+26,
          P62=P61+40,P63=P62+45,P64=P63+44,P65=P64+37,
          P66=P65+43,P67=P66+25,P68=P67+32,P69=P68+55,
          P70=P69+62,P71=P70+20,P72=P71+18,P73=P72+19,
          P74=P73+33,P75=P74+20,P76=P75+21,P77=P76+55,
          P78=P77+35,P79=P78+37,P80=P79+23,P81=P80+26,
          P82=P81+27,P83=P82+24,P84=P83+60,P85=P84+20,
          P86=P85+45,P87=P86+48,P88=P87+52,P89=P88+46,
          P90=P89+30,P91=P90+48,P92=P91+57,P93=P92+85,
          P94=P93+27,P95=P94+61,P96=P95+29,P97=P96+39,
          P98=P97+38,P99=P98+44,P100=P99+54,P101=P100+65,
          P102=P101+27,P103=P102+36,P104=P103+70,
          P105=P104+54,P106=P105+33,P107=P106+37,P108=P107+32,
          P109=P108+52,P110=P109+65;

DATAVEC F.M.ST ($LO16)
P0  P1  P2  P3  P4
P5  P6  P7  P8  P9
P10 P11 P12 P13 P14
P15 P16 P17 P18 P19
P20 P21 P22 P23 P24
P25 P26 P27 P28 P29
P30 P31 P32 P33 P34
P35 P36 P37 P38 P39
P40 P41 P42 P43 P44
P45 P46 P47 P48 P49
P50 P51 P52 P53 P54
P55 P56 P57 P58 P59
P60 P61 P62 P63 P64
P65 P66 P67 P68 P69
P70 P71 P72 P73 P74
P75 P76 P77 P78 P79
P80 P81 P82 P83 P84
P85 P86 P87 P88 P89
P90 P91 P92 P93 P94
P95 P96 P97 P98 P99
P100 P101 P102 P103
P104 P105 P106 P107
P108 P109 P110
END
@END
@TITLE BSC09.2(1,11)
@COL 1S-3R-4R-5F
@FLOW 1-3-4-5
@BOX1.0
PRINT STATS
@BOX 3.0
NEWLINE
@BOX 4.0
PRINT SIZE OF
   NLIST
   CHLIST
   PLIST
   TLIST
   PARAMS
@BOX 5.0
END
@BOX 1.1
$PR PRINT.STATS;
@BOX 3.1
SELECTOUTPUT(MSTR);
NEWLINES(0);
@BOX 4.1
OUTI(MAXN,5);
OUTI(MAXCH,5);
OUTI(MAXMUTLN,5);
OUTI(LASTT,5);
NEWLINES(1);
@BOX 5.1
END
@END
@TITLE BSC09.3(1,11)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
MONITOR(MESSAGE.NO)
@BOX 2.0
PRODUCE FAULT MESSAGE
[BSC09.1]
@BOX 3.0
END
@BOX 1.1
PROC MONITOR (MESSAGE);
@BOX 2.1
MONITOR.S.P.I(MESSAGE,NIL,IPTR,0);
@BOX 3.1
END
@END
@TITLE BSC09.4(1,11)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
MONITOR.S (MESSAGE,CAPTION)
@BOX 2.0
PRODUCE FAULT MESSAGE
[BSC09.1]
@BOX 3.0
END
@BOX 1.1
PROC MONITOR.S (MESSAGE,CAP);
@BOX 2.1
MONITOR.S.P.I (MESSAGE,CAP,%7FFF,0);
@BOX 3.1
END
@END
@TITLE BSC09.5(1,11)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
MONITOR.P (MESSAGE,POSITION)
@BOX 2.0
PRODUCE FAULT MESSAGE
[BSC09.1]
@BOX 3.0
END
@BOX 1.1
PROC MONITOR.P (MESS,POS);
@BOX 2.1
MONITOR.S.P.I (MESS,NIL,POS,0);
@BOX 3.1
END
@END
@TITLE BSC09.6(1,11)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
MONITOR.N(MESSAGE,NAME.ID)
@BOX 2.0
PRODUCE FAULT MESSAGE
[BSC09.1]
@BOX 3.0
END
@BOX 1.1
PROC MONITOR.N (MESS,ID);
@BOX 2.1
MONITOR.S.P.I(MESS,GENN(ID),%7FFF,0);
@BOX 3.1
END
@END
///6
@TITLE BSC09.7(1,11)
@COL 1S-2R-3F
@FLOW 1-2-3
@BOX 1.0
MONITOR.I(MESSAGE,INTEGER)
@BOX 2.0
PRODUCE FAULT MESSAGE
[BSC09.1]
@BOX 3.0
END
@BOX 1.1
PROC MONITOR.I (MESS,I);
@BOX 2.1
MONITOR.S.P.I(MESS,NIL,%7FFF,I);
@BOX 3.1
END
@END

