<> <> <> <> <> <> <> <> DIRECTORY FS USING [Error, StreamOpen], IO USING [CR, EndOf, GetChar, GetIndex, int, PutF, PutFR, rope, SetIndex, SP, STREAM, TAB], RefText USING [AppendChar, Fetch, Length, New], Rope USING [Concat, Fetch, FromRefText, Length, ROPE, Substr], ThymeGlobals USING [branchPtr, EchoInput, GetLineAndCptr, Handle, MakeStringNB, MsgTextsWithLook, namePtr, Next, nodePtr, PutMsgLine, WorkingDirectory]; ThymeErrors: CEDAR PROGRAM IMPORTS FS, IO, RefText, Rope, ThymeGlobals EXPORTS ThymeGlobals = BEGIN Handle: TYPE = ThymeGlobals.Handle; ErrorSignal: PUBLIC SIGNAL[error: NAT, s: Rope.ROPE]= CODE; ErrWarnSummary: PUBLIC PROC[handle: Handle]= { IF handle.vars.errCount + handle.vars.warnCount > 0 THEN { handle.msgStream.PutF["\n\t"]; IF handle.vars.errCount > 0 THEN { ThymeGlobals.MsgTextsWithLook[handle, "Total errors: ", 'b]; handle.msgStream.PutF["%d", IO.int[handle.vars.errCount]]; IF handle.vars.warnCount > 0 THEN handle.msgStream.PutF["; "] ELSE ThymeGlobals.PutMsgLine[handle, ".\n"]; }; IF handle.vars.warnCount > 0 THEN { ThymeGlobals.MsgTextsWithLook[handle, IF handle.vars.errCount > 0 THEN "total warnings: " ELSE "Total Warnings: ", 'b]; handle.msgStream.PutF["%d.\n", IO.int[handle.vars.warnCount]]; }; }; }; -- ErrWarnSummary PrintError: PROC[handle: Handle, err: NAT, warning: BOOL_ FALSE]= { OPEN handle.vars; errMsg: REF TEXT_ RefText.New[256]; tChar: CHAR; number: NAT_ 0; nonBlank: BOOL; <> IF thymeDotErrors=NIL AND ~triedOnce THEN { OPEN ThymeGlobals; thymeDotErrors _ FS.StreamOpen[Rope.Concat[WorkingDirectory[handle], "Thyme.errors"] !FS.Error => { thymeDotErrors _ FS.StreamOpen["/DATools7.0/Thyme/Thyme.errors" !FS.Error => { handle.msgStream.PutF[ "-- Thyme can't find the file \"Thyme.errors\" on your working directory or the Thyme release directory. You need the file to find out what the Error is.\n"]; thymeDotErrors_ NIL; triedOnce_ TRUE; CONTINUE; }; ]; CONTINUE; }; ]; IF thymeDotErrors # NIL THEN topOfMsgStream_ thymeDotErrors.GetIndex[]; }; <> <<(Current Cedar PutF doesn't seem to support %l.)>> <> <> <> handle.msgStream.PutF["\t\t"]; ThymeGlobals.MsgTextsWithLook[handle, "g", 'm]; ThymeGlobals.MsgTextsWithLook[handle, IF warning THEN " Warning " ELSE " Error ", 'b]; IF warning THEN warnCount_ warnCount + 1 ELSE errCount _ errCount + 1; <> IF thymeDotErrors # NIL THEN { thymeDotErrors.SetIndex[topOfMsgStream]; UNTIL number=err OR thymeDotErrors.EndOf[] DO errMsg.length _ 0; tChar _ IO.SP; nonBlank _ FALSE; <> UNTIL thymeDotErrors.EndOf[] DO tChar _ thymeDotErrors.GetChar[]; IF ~nonBlank THEN { IF tChar=IO.SP OR tChar=IO.TAB THEN LOOP ELSE nonBlank _ TRUE; }; IF tChar=IO.CR THEN EXIT; errMsg _ RefText.AppendChar[errMsg, tChar]; ENDLOOP; <> number _ 0; FOR index: INT IN [0..RefText.Length[errMsg]) DO tChar _ RefText.Fetch[errMsg, index]; IF tChar IN ['0..'9] THEN number _ number*10 + (tChar - '0) ELSE EXIT; ENDLOOP; <> ENDLOOP; }; IF thymeDotErrors=NIL OR number # err THEN handle.msgStream.PutF["%d.\n", IO.int[err]] ELSE handle.msgStream.PutF["%g.\n", IO.rope[Rope.FromRefText[errMsg]]]; }; -- PrintError ErrorAtNB: PUBLIC PROC[handle: Handle, err: NAT, n: ThymeGlobals.nodePtr, b: ThymeGlobals.branchPtr]= { handle.msgStream.PutF["%g", IO.rope[ ThymeGlobals.MakeStringNB[handle, n, b, FALSE]]]; <> PrintError[handle, err]; }; -- ErrorAtNB ErrorStrings: PUBLIC PROC[handle: Handle, err: NAT, s1, s2: Rope.ROPE]= { errLine: Rope.ROPE_ IF s2= NIL THEN IO.PutFR["%g", IO.rope[s1]] ELSE IO.PutFR["%g at %g", IO.rope[s1], IO.rope[s2]]; handle.msgStream.PutF["%g", IO.rope[errLine]]; PrintError[handle, err]; }; -- ErrorStrings Error: PUBLIC PROC[handle: Handle, err: NAT, skip, warning: BOOL_ FALSE]= { cptr, lastPos: INT; line: Rope.ROPE; noEcho: BOOL _ NOT ThymeGlobals.EchoInput[handle]; [line, cptr]_ ThymeGlobals.GetLineAndCptr[handle]; cptr_ MAX[0, cptr - 1]; lastPos_ MAX[0, line.Length[]-1]; IF line.Fetch[lastPos]=IO.CR AND lastPos > 0 THEN lastPos_ lastPos-1; <> <> <> <> <> <<];>> <<(Cedar5.2 doesn't seem to support PutF to change looks.)>> handle.msgStream.PutF[IF noEcho THEN "\n%g" ELSE "%g", IO.rope[line.Substr[0, cptr]]]; ThymeGlobals.MsgTextsWithLook[handle, "8", 'm]; handle.msgStream.PutF["%g\n", IO.rope[line.Substr[cptr, lastPos-cptr+1]]]; PrintError[handle, err, warning]; IF NOT ThymeGlobals.EchoInput[handle] THEN handle.msgStream.PutF["\t\tat [%g] in %g.\n", IO.int[handle.vars.inStream.GetIndex[] - line.Length[] + cptr - 1], IO.rope[handle.vars.fileNameStack[handle.vars.fileStackTop]] ]; IF skip THEN DO SELECT handle.vars.item FROM semi, eof, rightC, leftC => EXIT; ENDCASE; ThymeGlobals.Next[handle]; ENDLOOP; }; -- Error Error2: PUBLIC PROC[handle: Handle, err: NAT, n: ThymeGlobals.namePtr]= { errLine: Rope.ROPE _ IO.PutFR["%g", IO.rope[n.name]]; handle.msgStream.PutF["%g", IO.rope[errLine]]; PrintError[handle, err]; }; -- Error2 END. CHANGE LOG Wilhelm, March 30, 1982 8:36 AM Barth, 7-May-82 10:50:38 PDT Chen, June 11, 1984 7:13:37 pm PDT, cedarized. Chen, July 22, 1985 8:03:18 pm PDT, => Cedar6.0.