! File: DRIVER.BLI ! ! This work was supported by the Advanced Research ! Projects Agency of the Office of the Secretary of ! Defense (F44620-73-C-0074) and is monitored by the ! Air Force Office of Scientific Research. ! Module DRIVER(main=main) = Begin ! ! DRIVER MODULE ! ------------- ! ! ! THIS IS THE MAIN PROGRAM FOR THE BLISS-11 COMPILER. IT ALSO ! CONTAINS SOME COMMON UTILITY ROUTINES. THIS MODULE RESIDES IN ! THE LOW SEGMENT IN THE OVERLAID VERSION OF THE COMPILER. ! ! Require 'Bliss'; Require 'errmsg.req'; External Routine ParseCcl : Novalue, OpenFiles : Novalue, CloseFiles : Novalue, SYS$EXIT : Novalue; ! ! OUTPUT ERROR OR WARNING MESSAGE, WITH POINTERS, ETC. ! Routine ERROUT(TYPE : Ref Vector[,Byte],LASTOPEN,NUM,POSN) : Novalue = Begin Local save_device : Integer, N : Integer, C : Integer, TEMP : Vector[128,Byte]; save_device = .DEVICE; DEVICE = LSTDEV; If .swit_errors Then DEVICE = ERRDEV; If .flg_tty Then DEVICE<0,1> = 0; FORCELINE(); C = (If .TYPE[0] Eql 'E' Then '?' Else '%'); If .DEVICE<0,1> Then Print(AZ('%b%1m%c%e'),.c); Print(AZ('%b%2m;%e')); Print(AZ('%s#%3d'),.TYPE,.NUM); If .POSN Neq 0 Then Begin N = .POSN<0,8>; If .N Lss .LASTOPEN<0,8> Then N = .LASTOPEN<0,8>; If .LASTOPEN Neq 0 Then If .N Lss .pos_good<0,8> Then N = .pos_good<0,8>; Incr I From 1 To .N Do Begin C = '.'; Selectone .I Of Set [.POSN<0,8>]: C = '1'; [.LASTOPEN<0,8>]: C = '2'; [.pos_good<0,8>]: If .LASTOPEN Neq 0 Then C = '3' Tes; TEMP[.I-1] = .C End; TEMP[.N] = 0; Print(AZ('\t%s L1:%4d'),TEMP,.POSN<16,16>); If .LASTOPEN Neq 0 Then Print(AZ(' L2:%4d L3:%4d'),.LASTOPEN<16,16>,.pos_good<16,16>) End; Print(AZ('\n;%s'),.ERMSGPLIT[.NUM]); If .NUM Eql REGTOOCROWD Then Print(AZ('%d'),.ERRINFO[0]); Print(AZ('\n')); If .NUM Eql IDERR Or .NUM Eql ERUPLVL Then Print(AZ('; %p\n'),.SYM) Else If .NUM Eql ERMRD Or .NUM Eql BADSYMERR Or .NUM Eql ERMPL Or .NUM Eql WASMPREV Then Print(AZ('; %p\n'),.ERRINFO[0]) Else If .NUM Eql WABLKMTCH Then Begin If .ERRINFO[0] Eql 0 Then Print(AZ('; (NONE) ')) Else Print(AZ('; %p '),.ERRINFO[0]); If .ERRINFO[1] Eql 0 Then Print(AZ('; (NONE)\n')) Else Print(AZ('; %p\n'),.ERRINFO[1]) End; DEVICE = .save_device End; Global Routine ERRPRNT(LASTOPEN,POSN,NUM) : Novalue = Begin If Not .ERRLEVEL Then Begin ERROUT(AZ('ERR '),.LASTOPEN,.NUM,.POSN); num_error = .num_error+1 End; Return 0 End; Global Routine WARNEM(POSN,NUM) : Novalue = Begin ERROUT(AZ('WARN'),0,.NUM,.POSN); num_warning = .num_warning+1; Return 0 End; Routine WRITEFINAL : Novalue = Begin ! THIS ROUTINE WRITES THE FINAL GOOD-BYE TO THE USER swit_errors = TRUE; Print(AZ('%b\n%3m')); If (.num_error+.num_warning) Neq 0 Then Print(AZ('\n; # Warnings =%d\n; # Errors =%d\n'),.num_warning,.num_error); Print(AZ('%e')) End; ! INITIALIZATION ROUTINES !------------------------ Routine REINIT : Novalue = Begin ! THIS ROUTINE IS THE PRIMARY INITIALIZATION OF THE COMPILER. ! IT IS CALLED TO RE-INIT THE SYSTEM FOR EACH COMPILATION. TNCHAIN[itm_llink] = TNCHAIN; TNCHAIN[itm_rlink] = TNCHAIN; MODMAIN = AZ(''); DEVICE = LSTDEV; MODNAME = AZ('$MODULE'); CSNAME = .MODNAME; CSFLAG = TRUE; PAGE(); End; Routine MODINIT : Novalue = Begin PURGED = .LASTPUR; BLOCKLEVEL = 1; STRUCLEVEL = %x'7fffffff' End; Global Routine GENIT : Novalue = Begin External Routine PrintTree : Novalue; If .swit_dump_flowan Then Begin Print(AZ('\n\n==== after flowan ===\n\n')); PrintTree(.sym,0) End; DELAYDRIVER(.SYM); If .swit_dump_delay Then Begin Print(AZ('\n\n==== after delay ===\n\n')); PrintTree(.sym,1) End; TNBIND(.SYM); ! Note: dump done in tnbind before needed table are destroyed CODEDRIVER(.SYM); FINALDRIV(0); RSTRTHREAD(.PURGED); PURGED = .LASTPUR End; Global Routine MAIN : Novalue = Begin ParseCcl(); OpenFiles(); ONCEONLY(); REINIT(); ! initialize the scanner SKAN1(); ! the first call fills FUTWINDOW, the second call fills SYM and DEL RUND(QL_LEXEME); RUND(QL_LEXEME); If .DEL Neq TK_MODULE Then Begin ERRPRNT(.pos_del,.pos_del,ERMISSBRC); STOP(1) End; MODINIT(); DOMODULE(); LASTPUR = 0; MODDONE = TRUE; If Not .NOTREE And .num_error Eql 0 Then GENIT(); WRITEFINAL(); RUND(QL_LEXEME); If Not .flg_eof Then ERRPRNT(.pos_del,.pos_del,ERMISSBRC); Print(AZ('%3m\n; Size: %d+%d'),.CODESIZE,.DATASIZE); Print(AZ('\n; Compilation Complete\n%2m\n\t.END %s\n'),.MODMAIN); CloseFiles(); SYS$EXIT(1) End; End Eludom