File ParserTypes.mesa
March 5, 1980 5:04 PM
Converte to Mesa 6 October 20, 1980 4:20 PM
October 20, 1980 4:20 PM by MN
Last Edited by: McCreight, January 28, 1985 4:06:15 pm PST
DIRECTORY
ParserTypeDefs;
ParserTypes: CEDAR PROGRAM EXPORTS ParserTypeDefs =
BEGIN OPEN ParserTypeDefs;
InitTypes:
PUBLIC
PROCEDURE
RETURNS [
BOOLEAN] =
BEGIN
RETURN[TRUE];
END;
FinishTypes:
PUBLIC
PROCEDURE
RETURNS [
BOOLEAN] =
BEGIN
RETURN[TRUE];
END;
PathLength:
PUBLIC
PROCEDURE [a: Path]
RETURNS [
CARDINAL] =
BEGIN
RETURN[a.length];
END;
AllocatePath:
PUBLIC
PROCEDURE
RETURNS [Path] =
{RETURN[NEW[PathRecord ← [first: NIL, last: NIL, length: 0]]]};
FreePath:
PUBLIC
PROCEDURE [a: Path] = {
NULL};
AppendPoint:
PUBLIC
PROCEDURE [a: Path, p: Point] =
BEGIN
IF a.first =
NIL
THEN
{a.first ← a.last ← CONS[p, NIL]; a.length ← 1}
ELSE
{a.last.rest ← CONS[p, NIL]; a.last ← a.last.rest; a.length ← a.length+1};
END;
CopyPath:
PUBLIC
PROCEDURE [from, to: Path] =
BEGIN
IF from = to THEN RETURN;
FOR temp: PointList ← from.first, temp.rest
UNTIL temp =
NIL
DO
AppendPoint[to, temp.first];
ENDLOOP;
END;
RemovePoint:
PUBLIC
PROCEDURE [a: Path]
RETURNS [
BOOLEAN, Point] =
BEGIN
ans: Point;
IF a.first =
NIL
THEN
RETURN [
FALSE, ans]
ELSE
BEGIN
ans ← a.first.first;
a.first ← a.first.rest;
IF a.first = NIL THEN a.last ← NIL;
a.length ← a.length - 1;
RETURN [TRUE, ans];
END;
END;
AllocateTList:
PUBLIC
PROCEDURE
RETURNS [TList] =
{RETURN[NEW[TRecord ← [first: NIL, last: NIL, length: 0]]]};
FreeTList:
PUBLIC
PROCEDURE [a: TList] = {
NULL};
AppendTList:
PUBLIC
PROCEDURE [a: TList, p: TEntry] =
BEGIN
IF a.first =
NIL
THEN
{a.first ← a.last ← CONS[p, NIL]; a.length ← 1}
ELSE
{a.last.rest ← CONS[p, NIL]; a.last ← a.last.rest; a.length ← a.length+1};
END;
RemoveTList:
PUBLIC
PROCEDURE [a: TList]
RETURNS [
BOOLEAN, TEntry] =
BEGIN
ans: TEntry;
IF a.first =
NIL
THEN
RETURN [
FALSE, ans]
ELSE
BEGIN
ans ← a.first.first;
a.first ← a.first.rest;
IF a.first = NIL THEN a.last ← NIL;
a.length ← a.length - 1;
RETURN [TRUE, ans];
END;
END;
TListLength:
PUBLIC
PROCEDURE [a: TList]
RETURNS [
CARDINAL] =
BEGIN
RETURN[a.length];
END;
END.