file: PasErrs.mesa
modified by Ramshaw, January 20, 1984 2:19 pm
written by McCreight, January 16, 1981 6:17 PM
DIRECTORY
IO USING [STREAM, int, PutChar, PutF, PutRope, rope],
PasPrivate,
PasPrivateVars,
Rope USING [Cat];
PasErrs: CEDAR PROGRAM IMPORTS IO, PasPrivateVars, Rope EXPORTS PasPrivate =
BEGIN
OPEN PasPrivate, PasPrivateVars;
Procedures
PasMesaError: PUBLIC ERROR [reason: ROPE] = CODE;
ErrorToString: PROCEDURE [e: Errors] RETURNS [ROPE]=
BEGIN
RETURN[SELECT e FROM
MalformedProgram => "MalformedProgram",
MalformedBlock => "MalformedBlock",
MalformedStatement => "MalformedStatement",
MalformedAssignment => "MalformedAssignment",
MalformedParameterList => "MalformedParameterList",
MalformedProcedureCall => "MalformedProcedureCall",
MultipleTypeDefinition => "MultipleTypeDefinition",
ShouldBeRecord => "ShouldBeRecord",
CantComputeConstant => "CantComputeConstant",
MalformedVariable => "MalformedVariable",
MalformedArrayAccess => "MalformedArrayAccess",
MalformedRecordAccess => "MalformedRecordAccess",
MalformedExpression => "MalformedExpression",
MalformedSimpleExpression => "MalformedSimpleExpression",
MalformedTerm => "MalformedTerm",
MalformedFactor => "MalformedFactor",
MalformedConstant => "MalformedConstant",
MalformedSetConstructor => "MalformedSetConstructor",
IllegalOperation => "IllegalOperation",
IncompatibleOperands => "IncompatibleOperands",
IllegalOperand => "IllegalOperand",
UnknownType => "UnknownType",
IllegalValue => "IllegalValue",
IncompatibleTypes => "IncompatibleTypes",
CantExpressString => "CantExpressString",
NotASet => "NotASet",
Undefined => "Undefined",
MultipleDefinition => "MultipleDefinition",
MalformedInstr => "MalformedInstr",
MalformedStandard => "MalformedStandard",
MalformedNewDispose => "MalformedNewDispose",
ImproperType => "ImproperType",
MalformedPack => "MalformedPack",
BadArgumentCount => "BadArgumentCount",
MalformedIdList => "MalformedIdList",
MalformedSimpleType => "MalformedSimpleType",
MalformedRangeType => "MalformedRangeType",
MalformedType => "MalformedType",
MalformedScalar => "MalformedScalar",
UnexpectedType => "UnexpectedType",
NotFiniteType => "NotFiniteType",
SetTooLarge => "SetTooLarge",
UndefinedType => "UndefinedType",
MultiplyDefinedLabel => "MultiplyDefinedLabel",
MalformedNonLocalGoTo => "MalformedNonLocalGoTo",
MalformedProcArrayDeclaration => "MalformedProcArrayDeclaration",
MalformedProcArrayAccess => "MalformedProcArrayAccess",
MalformedComputedSeqArrayDeclaration => "MalformedComputedSeqArrayDeclaration",
MalformedComputedSeqArrayAccess => "MalformedComputedSeqArrayAccess",
IdentifierMismatch => "IdentifierMismatch",
MalformedExternalProc => "MalformedExternalProc",
Confusion => "Confusion",
ENDCASE => "?Er"];
END; -- ErrorToString
SymbolToString: PROCEDURE [sy: Symbol] RETURNS [ROPE]=
BEGIN
RETURN[SELECT sy FROM
identSy => "identSy",
intConstSy => "intConstSy",
realConstSy => "realConstSy",
stringConstSy => "stringConstSy",
notSy => "notSy",
mulOpSy => "mulOpSy",
addOpSy => "addOpSy",
relOpSy => "relOpSy",
lParentSy => "lParentSy",
rParentSy => "rParentSy",
lBrackSy => "lBrackSy",
rBrackSy => "rBrackSy",
commaSy => "commaSy",
semiColonSy => "semiColonSy",
periodSy => "periodSy",
arrowSy => "arrowSy",
colonSy => "colonSy",
becomesSy => "becomesSy",
labelSy => "labelSy",
constSy => "constSy",
typeSy => "typeSy",
varSy => "varSy",
functionSy => "functionSy",
procedureSy => "procedureSy",
packedSy => "packedSy",
setSy => "setSy",
arraySy => "arraySy",
recordSy => "recordSy",
fileSy => "fileSy",
forwardSy => "forwardSy",
beginSy => "beginSy",
ifSy => "ifSy",
caseSy => "caseSy",
repeatSy => "repeatSy",
whileSy => "whileSy",
forSy => "forSy",
withSy => "withSy",
loopSy => "loopSy",
gotoSy => "gotoSy",
exitSy => "exitSy",
endSy => "endSy",
elseSy => "elseSy",
untilSy => "untilSy",
ofSy => "ofSy",
doSy => "doSy",
toSy => "toSy",
downToSy => "downToSy",
externSy => "externSy",
programSy => "programSy",
thenSy => "thenSy",
otherSy => "otherSy",
othersSy => "othersSy",
eofSy => "eofSy",
ENDCASE => "?Sy"];
END; -- of SymbolToString
OperatorToString: PROCEDURE [op: Operator] RETURNS [ROPE]=
BEGIN
RETURN[SELECT op FROM
noOp => "noOp",
mulOp => "mulOp",
rDivOp => "rDivOp",
andOp => "andOp",
iDivOp => "iDivOp",
modOp => "modOp",
plusOp => "plusOp",
minusOp => "minusOp",
orOp => "orOp",
ltOp => "ltOp",
leOp => "leOp",
gtOp => "gtOp",
geOp => "geOp",
neOp => "neOp",
eqOp => "eqOp",
inOp => "inOp",
ENDCASE => "?Op"];
END; -- of OperatorToString
ErrorPrinter: PROCEDURE [reason: Errors] RETURNS [r:ROPE]=
BEGIN
outStream: STREAM ← commandHandle.out;
r←Rope.Cat[ErrorToString[reason], "{", SymbolToString[sy]];
IF op # noOp THEN r←Rope.Cat[r, ".", OperatorToString[op]];
SELECT sy FROM
identSy, intConstSy, realConstSy, stringConstSy =>
r←Rope.Cat[r, ".""", ident, """"];
ENDCASE => NULL;
r←Rope.Cat[r, "}"];
outStream.PutF["\n!%g", IO.rope[r]];
outStream.PutF["\nat position %g in file: %g;\n", IO.int[positionInInputFile],
IO.rope[nameOfInputFile]];
outStream.PutRope["the context is: \n\n"];
FOR i: NAT IN [contextBufferIndex .. contextBufferLength) DO
outStream.PutChar[contextBuffer[i]] ENDLOOP;
FOR i: NAT IN [0 .. contextBufferIndex) DO
outStream.PutChar[contextBuffer[i]] ENDLOOP;
outStream.PutRope["\n\n"];
END; -- of ErrorPrinter
Error: PUBLIC PROCEDURE [reason: Errors] =
BEGIN
errString:ROPE𡤎rrorPrinter[reason];
ERROR PasMesaError[errString];
END; -- of Error
Warning: PUBLIC PROCEDURE [reason: Errors, extraInfo: ROPENIL] =
BEGIN
[]𡤎rrorPrinter[reason];
IF extraInfo # NIL THEN commandHandle.out.PutF["%g\n\n", IO.rope[extraInfo]];
END; -- of Warning
END.