1 (* mcPretty.def provides an interface to the pretty printing of output code.
3 Copyright (C) 2016-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
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)
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.
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/>. *)
22 DEFINITION MODULE mcPretty
;
25 FROM DynamicStrings
IMPORT String
;
29 writeProc
= PROCEDURE (CHAR) ;
30 writeLnProc
= PROCEDURE ;
34 initPretty - initialise a pretty print data structure.
37 PROCEDURE initPretty (w
: writeProc
; l
: writeLnProc
) : pretty
;
41 dupPretty - duplicate a pretty print data structure.
44 PROCEDURE dupPretty (p
: pretty
) : pretty
;
48 killPretty - destroy a pretty print data structure.
49 Post condition: p is assigned to NIL.
52 PROCEDURE killPretty (VAR p
: pretty
) ;
56 pushPretty - duplicate, p. Push, p, and return the duplicate.
59 PROCEDURE pushPretty (p
: pretty
) : pretty
;
63 popPretty - pops the pretty object from the stack.
66 PROCEDURE popPretty (p
: pretty
) : pretty
;
70 getindent - returns the current indent value.
73 PROCEDURE getindent (p
: pretty
) : CARDINAL ;
77 setindent - sets the current indent to, n.
80 PROCEDURE setindent (p
: pretty
; n
: CARDINAL) ;
84 getcurpos - returns the current cursor position.
87 PROCEDURE getcurpos (s
: pretty
) : CARDINAL ;
91 getseekpos - returns the seek position.
94 PROCEDURE getseekpos (s
: pretty
) : CARDINAL ;
98 getcurline - returns the current line number.
101 PROCEDURE getcurline (s
: pretty
) : CARDINAL ;
105 setNeedSpace - sets needSpace flag to TRUE.
108 PROCEDURE setNeedSpace (s
: pretty
) ;
112 noSpace - unset needsSpace.
115 PROCEDURE noSpace (s
: pretty
) ;
119 print - print a string using, p.
122 PROCEDURE print (p
: pretty
; a
: ARRAY OF CHAR) ;
126 prints - print a string using, p.
129 PROCEDURE prints (p
: pretty
; s
: String
) ;
133 raw - print out string, s, without any translation of
137 PROCEDURE raw (p
: pretty
; s
: String
) ;