prettier.mod

来自「一个Modula-2语言分析器」· MOD 代码 · 共 47 行

MOD
47
字号
IMPLEMENTATION MODULE Prettier;
(* Pretty printing auxiliary functions for use with Taste pretty printing
   program generated by COCO from an attributed grammar
   P.D. Terry, Rhodes University, 17 May 1991 *)

  IMPORT TextIO;

  VAR
    Indentation : CARDINAL;

  PROCEDURE Append (String : ARRAY OF CHAR);
    BEGIN
      TextIO.WriteString(results, String);
    END Append;

  PROCEDURE NewLine;
    VAR
      I : CARDINAL;
    BEGIN
      TextIO.WriteLn(results);
      FOR I := 1 TO Indentation DO TextIO.WriteChar(results, ' ') END;
    END NewLine;

  PROCEDURE IndentNextLine;
    BEGIN
      INC(Indentation, 2); NewLine
    END IndentNextLine;

  PROCEDURE ExdentNextLine;
    BEGIN
      DEC(Indentation, 2); NewLine
    END ExdentNextLine;

  PROCEDURE Indent;
    BEGIN
      INC(Indentation, 2)
    END Indent;

  PROCEDURE Exdent;
    BEGIN
      DEC(Indentation, 2)
    END Exdent;

  BEGIN
    Indentation := 0
  END Prettier.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?