| 1 |
(* mcPretty.def provides an interface to the pretty printing of output code. |
| 2 |
|
| 3 |
Copyright (C) 2016-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. *) |
| 21 |
|
| 22 |
DEFINITION MODULE mcPretty ; |
| 23 |
|
| 24 |
|
| 25 |
FROM DynamicStrings IMPORT String ; |
| 26 |
|
| 27 |
TYPE |
| 28 |
pretty ; |
| 29 |
writeProc = PROCEDURE (CHAR) ; |
| 30 |
writeLnProc = PROCEDURE ; |
| 31 |
|
| 32 |
|
| 33 |
(* |
| 34 |
initPretty - initialise a pretty print data structure. |
| 35 |
*) |
| 36 |
|
| 37 |
PROCEDURE initPretty (w: writeProc; l: writeLnProc) : pretty ; |
| 38 |
|
| 39 |
|
| 40 |
(* |
| 41 |
dupPretty - duplicate a pretty print data structure. |
| 42 |
*) |
| 43 |
|
| 44 |
PROCEDURE dupPretty (p: pretty) : pretty ; |
| 45 |
|
| 46 |
|
| 47 |
(* |
| 48 |
killPretty - destroy a pretty print data structure. |
| 49 |
Post condition: p is assigned to NIL. |
| 50 |
*) |
| 51 |
|
| 52 |
PROCEDURE killPretty (VAR p: pretty) ; |
| 53 |
|
| 54 |
|
| 55 |
(* |
| 56 |
pushPretty - duplicate, p. Push, p, and return the duplicate. |
| 57 |
*) |
| 58 |
|
| 59 |
PROCEDURE pushPretty (p: pretty) : pretty ; |
| 60 |
|
| 61 |
|
| 62 |
(* |
| 63 |
popPretty - pops the pretty object from the stack. |
| 64 |
*) |
| 65 |
|
| 66 |
PROCEDURE popPretty (p: pretty) : pretty ; |
| 67 |
|
| 68 |
|
| 69 |
(* |
| 70 |
getindent - returns the current indent value. |
| 71 |
*) |
| 72 |
|
| 73 |
PROCEDURE getindent (p: pretty) : CARDINAL ; |
| 74 |
|
| 75 |
|
| 76 |
(* |
| 77 |
setindent - sets the current indent to, n. |
| 78 |
*) |
| 79 |
|
| 80 |
PROCEDURE setindent (p: pretty; n: CARDINAL) ; |
| 81 |
|
| 82 |
|
| 83 |
(* |
| 84 |
getcurpos - returns the current cursor position. |
| 85 |
*) |
| 86 |
|
| 87 |
PROCEDURE getcurpos (s: pretty) : CARDINAL ; |
| 88 |
|
| 89 |
|
| 90 |
(* |
| 91 |
getseekpos - returns the seek position. |
| 92 |
*) |
| 93 |
|
| 94 |
PROCEDURE getseekpos (s: pretty) : CARDINAL ; |
| 95 |
|
| 96 |
|
| 97 |
(* |
| 98 |
getcurline - returns the current line number. |
| 99 |
*) |
| 100 |
|
| 101 |
PROCEDURE getcurline (s: pretty) : CARDINAL ; |
| 102 |
|
| 103 |
|
| 104 |
(* |
| 105 |
setNeedSpace - sets needSpace flag to TRUE. |
| 106 |
*) |
| 107 |
|
| 108 |
PROCEDURE setNeedSpace (s: pretty) ; |
| 109 |
|
| 110 |
|
| 111 |
(* |
| 112 |
noSpace - unset needsSpace. |
| 113 |
*) |
| 114 |
|
| 115 |
PROCEDURE noSpace (s: pretty) ; |
| 116 |
|
| 117 |
|
| 118 |
(* |
| 119 |
print - print a string using, p. |
| 120 |
*) |
| 121 |
|
| 122 |
PROCEDURE print (p: pretty; a: ARRAY OF CHAR) ; |
| 123 |
|
| 124 |
|
| 125 |
(* |
| 126 |
prints - print a string using, p. |
| 127 |
*) |
| 128 |
|
| 129 |
PROCEDURE prints (p: pretty; s: String) ; |
| 130 |
|
| 131 |
|
| 132 |
(* |
| 133 |
raw - print out string, s, without any translation of |
| 134 |
escape sequences. |
| 135 |
*) |
| 136 |
|
| 137 |
PROCEDURE raw (p: pretty; s: String) ; |
| 138 |
|
| 139 |
|
| 140 |
END mcPretty. |