forked from asyncvlsi/act
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpp.h
More file actions
175 lines (143 loc) · 4.23 KB
/
Copy pathpp.h
File metadata and controls
175 lines (143 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*************************************************************************
*
* Pretty printer library.
*
* Copyright (c) 1996-2000, 2019 Rajit Manohar
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
**************************************************************************
*/
#ifndef __PP_H__
#define __PP_H__
#include <stdio.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
struct __pp_brstack {
int indent;
int broken; /* true if broken */
struct __pp_brstack *n;
};
typedef struct {
FILE *fp; /* output stream */
char *inpbuf; /* input buffer */
int inpbufsz; /* input buffer size */
int inpbufst; /* start position */
int inpbufend; /* end position */
/* inpbuf: a circular buffer.
0 . . . inpbufsz
One position is not used.
Includes inpbufst, not inpbufend.
Empty: inpbufst == inpbufend
Full: inpbufst = k, inpbufend = k-1 mod inpbufsz.
*/
char *linebuf; /* output buffer */
int margin; /* margin */
int indent; /* current indentation */
int correction; /* correction */
struct __pp_brstack *stk; /* stack of setb/endbs */
} pp_t;
enum {
PP_FORCED = '\n',
PP_UNITED = '\001',
PP_LAZY = '\002',
PP_SETB = '\003',
PP_ENDB = '\004'
};
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FUNCTIONS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
extern pp_t *pp_init (FILE *, int margin);
/*
Return a new pretty-printer filter with "margin" set to be the margin.
*/
extern void pp_puts_generic (pp_t *, const char *, int flag);
/*
If "flag" != 0, prints out raw string without interpreting anything
except '\n' as a newline.
If "flag" == 0, understands normal pp formatting conventions.
*/
#define pp_puts(pp,s) pp_puts_generic(pp,s,0)
/*
Pretty-print string
*/
#define pp_puts_raw(pp,s) pp_puts_generic(pp,s,1)
/*
Dump raw string "s" on pretty-printer
*/
extern void pp_printf (pp_t *, const char *, ...);
/*
Pretty-printf a string. The resulting string should be < 4096
characters.
*/
extern void pp_vprintf (pp_t *, const char *, va_list);
/*
Pretty-printf a string. The resulting string should be < 4096
characters.
*/
extern void pp_printf_raw (pp_t *, const char *, ...);
/*
Dump raw string to pp. Same 4096 character restriction.
*/
extern void pp_vprintf_raw (pp_t *, const char *, va_list);
/*
Pretty-printf a string. The resulting string should be < 4096
characters.
*/
extern void pp_printf_text (pp_t *, const char *, ...);
/*
Pretty-printf a text string. This means that word/tab spacing is
ignored, and there is an implicit lazy breakpoint after each
word. Words are space/tab delimited. Newlines are respected.
*/
extern void pp_lazy (pp_t *, int);
/*
Put a lazy breakpoint into the output
*/
extern void pp_united (pp_t *, int);
/*
Put a united breakpoint into the output
*/
extern void pp_forced (pp_t *, int);
/*
Put a forced breakpoint into the output
*/
#define pp_setb(x) pp_puts(x,"\003")
/*
Put a "setb" into the output
*/
#define pp_endb(x) pp_puts(x,"\004")
/*
Put an "endb" into the output
*/
extern void pp_flush (pp_t *);
/*
Flush output
*/
extern void pp_close (pp_t *);
/*
Close a pretty-printer
*/
extern void pp_stop (pp_t *);
/*
Flush and free a pretty-printer without closing the output file
*/
#ifdef __cplusplus
}
#endif
#endif /* __PP_H__ */