📄 prettier.mod
字号:
IMPLEMENTATION MODULE Prettier;
(* Pretty printing auxiliary functions for use with Modula-2 pretty printing
program generated by COCO from an attributed grammar
P.D. Terry, Rhodes University, 1995 *)
IMPORT SYSTEM, TextIO, IOChan, Mod2S;
IMPORT STextIO, SWholeIO;
CONST
BufMax = 12000;
VAR
AllBlanks : BOOLEAN;
Last, Indentation : CARDINAL;
Buffer : ARRAY [0 .. BufMax] OF CHAR;
PROCEDURE NewLine;
BEGIN
IF NOT AllBlanks THEN (* first strip trailing spaces *)
WHILE (Last > 0) & (Buffer[Last-1] = ' ') DO DEC(Last) END;
IOChan.RawWrite(results, SYSTEM.ADR(Buffer), Last);
TextIO.WriteLn(results);
END;
Last := 0;
WHILE Last < Indentation DO Buffer[Last] := ' '; INC(Last) END;
Buffer[Last] := 0C; AllBlanks := TRUE;
END NewLine;
PROCEDURE Append (Str : ARRAY OF CHAR);
VAR
l : CARDINAL;
BEGIN
l := 0;
WHILE (l <= HIGH(Str)) AND (Str[l] # 0C) DO
Buffer[Last] := Str[l];
IF Str[l] # ' ' THEN AllBlanks := FALSE END;
INC(l); INC(Last)
END;
Buffer[Last] := 0C;
IF Mod2S.seenComment THEN
NewLine; AllBlanks := FALSE;
Mod2S.GetComment(Buffer, Last, l); INC(Last, l);
Buffer[Last] := ' '; INC(Last); Buffer[Last] := CHR(0);
END
END Append;
PROCEDURE IndentNextLine;
BEGIN
INC(Indentation, 2); NewLine
END IndentNextLine;
PROCEDURE ExdentNextLine;
BEGIN
IF Indentation >= 2 THEN DEC(Indentation, 2) END; NewLine
END ExdentNextLine;
PROCEDURE Indent;
BEGIN
INC(Indentation, 2)
END Indent;
PROCEDURE Exdent;
BEGIN
IF Indentation >= 2 THEN DEC(Indentation, 2) END
END Exdent;
PROCEDURE BlankLine;
BEGIN
NewLine; TextIO.WriteLn(results);
END BlankLine;
BEGIN
Indentation := 0; AllBlanks := TRUE; Last := 0;
END Prettier.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -