xref: /titanic_52/usr/src/cmd/mandoc/mdoc.h (revision 95c635efb7c3b86efc493e0447eaec7aecca3f0f)
1*95c635efSGarrett D'Amore /*	$Id: mdoc.h,v 1.122 2011/03/22 14:05:45 kristaps Exp $ */
2*95c635efSGarrett D'Amore /*
3*95c635efSGarrett D'Amore  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4*95c635efSGarrett D'Amore  *
5*95c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
6*95c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
7*95c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
8*95c635efSGarrett D'Amore  *
9*95c635efSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*95c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*95c635efSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*95c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*95c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*95c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*95c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*95c635efSGarrett D'Amore  */
17*95c635efSGarrett D'Amore #ifndef MDOC_H
18*95c635efSGarrett D'Amore #define MDOC_H
19*95c635efSGarrett D'Amore 
20*95c635efSGarrett D'Amore enum	mdoct {
21*95c635efSGarrett D'Amore 	MDOC_Ap = 0,
22*95c635efSGarrett D'Amore 	MDOC_Dd,
23*95c635efSGarrett D'Amore 	MDOC_Dt,
24*95c635efSGarrett D'Amore 	MDOC_Os,
25*95c635efSGarrett D'Amore 	MDOC_Sh,
26*95c635efSGarrett D'Amore 	MDOC_Ss,
27*95c635efSGarrett D'Amore 	MDOC_Pp,
28*95c635efSGarrett D'Amore 	MDOC_D1,
29*95c635efSGarrett D'Amore 	MDOC_Dl,
30*95c635efSGarrett D'Amore 	MDOC_Bd,
31*95c635efSGarrett D'Amore 	MDOC_Ed,
32*95c635efSGarrett D'Amore 	MDOC_Bl,
33*95c635efSGarrett D'Amore 	MDOC_El,
34*95c635efSGarrett D'Amore 	MDOC_It,
35*95c635efSGarrett D'Amore 	MDOC_Ad,
36*95c635efSGarrett D'Amore 	MDOC_An,
37*95c635efSGarrett D'Amore 	MDOC_Ar,
38*95c635efSGarrett D'Amore 	MDOC_Cd,
39*95c635efSGarrett D'Amore 	MDOC_Cm,
40*95c635efSGarrett D'Amore 	MDOC_Dv,
41*95c635efSGarrett D'Amore 	MDOC_Er,
42*95c635efSGarrett D'Amore 	MDOC_Ev,
43*95c635efSGarrett D'Amore 	MDOC_Ex,
44*95c635efSGarrett D'Amore 	MDOC_Fa,
45*95c635efSGarrett D'Amore 	MDOC_Fd,
46*95c635efSGarrett D'Amore 	MDOC_Fl,
47*95c635efSGarrett D'Amore 	MDOC_Fn,
48*95c635efSGarrett D'Amore 	MDOC_Ft,
49*95c635efSGarrett D'Amore 	MDOC_Ic,
50*95c635efSGarrett D'Amore 	MDOC_In,
51*95c635efSGarrett D'Amore 	MDOC_Li,
52*95c635efSGarrett D'Amore 	MDOC_Nd,
53*95c635efSGarrett D'Amore 	MDOC_Nm,
54*95c635efSGarrett D'Amore 	MDOC_Op,
55*95c635efSGarrett D'Amore 	MDOC_Ot,
56*95c635efSGarrett D'Amore 	MDOC_Pa,
57*95c635efSGarrett D'Amore 	MDOC_Rv,
58*95c635efSGarrett D'Amore 	MDOC_St,
59*95c635efSGarrett D'Amore 	MDOC_Va,
60*95c635efSGarrett D'Amore 	MDOC_Vt,
61*95c635efSGarrett D'Amore 	MDOC_Xr,
62*95c635efSGarrett D'Amore 	MDOC__A,
63*95c635efSGarrett D'Amore 	MDOC__B,
64*95c635efSGarrett D'Amore 	MDOC__D,
65*95c635efSGarrett D'Amore 	MDOC__I,
66*95c635efSGarrett D'Amore 	MDOC__J,
67*95c635efSGarrett D'Amore 	MDOC__N,
68*95c635efSGarrett D'Amore 	MDOC__O,
69*95c635efSGarrett D'Amore 	MDOC__P,
70*95c635efSGarrett D'Amore 	MDOC__R,
71*95c635efSGarrett D'Amore 	MDOC__T,
72*95c635efSGarrett D'Amore 	MDOC__V,
73*95c635efSGarrett D'Amore 	MDOC_Ac,
74*95c635efSGarrett D'Amore 	MDOC_Ao,
75*95c635efSGarrett D'Amore 	MDOC_Aq,
76*95c635efSGarrett D'Amore 	MDOC_At,
77*95c635efSGarrett D'Amore 	MDOC_Bc,
78*95c635efSGarrett D'Amore 	MDOC_Bf,
79*95c635efSGarrett D'Amore 	MDOC_Bo,
80*95c635efSGarrett D'Amore 	MDOC_Bq,
81*95c635efSGarrett D'Amore 	MDOC_Bsx,
82*95c635efSGarrett D'Amore 	MDOC_Bx,
83*95c635efSGarrett D'Amore 	MDOC_Db,
84*95c635efSGarrett D'Amore 	MDOC_Dc,
85*95c635efSGarrett D'Amore 	MDOC_Do,
86*95c635efSGarrett D'Amore 	MDOC_Dq,
87*95c635efSGarrett D'Amore 	MDOC_Ec,
88*95c635efSGarrett D'Amore 	MDOC_Ef,
89*95c635efSGarrett D'Amore 	MDOC_Em,
90*95c635efSGarrett D'Amore 	MDOC_Eo,
91*95c635efSGarrett D'Amore 	MDOC_Fx,
92*95c635efSGarrett D'Amore 	MDOC_Ms,
93*95c635efSGarrett D'Amore 	MDOC_No,
94*95c635efSGarrett D'Amore 	MDOC_Ns,
95*95c635efSGarrett D'Amore 	MDOC_Nx,
96*95c635efSGarrett D'Amore 	MDOC_Ox,
97*95c635efSGarrett D'Amore 	MDOC_Pc,
98*95c635efSGarrett D'Amore 	MDOC_Pf,
99*95c635efSGarrett D'Amore 	MDOC_Po,
100*95c635efSGarrett D'Amore 	MDOC_Pq,
101*95c635efSGarrett D'Amore 	MDOC_Qc,
102*95c635efSGarrett D'Amore 	MDOC_Ql,
103*95c635efSGarrett D'Amore 	MDOC_Qo,
104*95c635efSGarrett D'Amore 	MDOC_Qq,
105*95c635efSGarrett D'Amore 	MDOC_Re,
106*95c635efSGarrett D'Amore 	MDOC_Rs,
107*95c635efSGarrett D'Amore 	MDOC_Sc,
108*95c635efSGarrett D'Amore 	MDOC_So,
109*95c635efSGarrett D'Amore 	MDOC_Sq,
110*95c635efSGarrett D'Amore 	MDOC_Sm,
111*95c635efSGarrett D'Amore 	MDOC_Sx,
112*95c635efSGarrett D'Amore 	MDOC_Sy,
113*95c635efSGarrett D'Amore 	MDOC_Tn,
114*95c635efSGarrett D'Amore 	MDOC_Ux,
115*95c635efSGarrett D'Amore 	MDOC_Xc,
116*95c635efSGarrett D'Amore 	MDOC_Xo,
117*95c635efSGarrett D'Amore 	MDOC_Fo,
118*95c635efSGarrett D'Amore 	MDOC_Fc,
119*95c635efSGarrett D'Amore 	MDOC_Oo,
120*95c635efSGarrett D'Amore 	MDOC_Oc,
121*95c635efSGarrett D'Amore 	MDOC_Bk,
122*95c635efSGarrett D'Amore 	MDOC_Ek,
123*95c635efSGarrett D'Amore 	MDOC_Bt,
124*95c635efSGarrett D'Amore 	MDOC_Hf,
125*95c635efSGarrett D'Amore 	MDOC_Fr,
126*95c635efSGarrett D'Amore 	MDOC_Ud,
127*95c635efSGarrett D'Amore 	MDOC_Lb,
128*95c635efSGarrett D'Amore 	MDOC_Lp,
129*95c635efSGarrett D'Amore 	MDOC_Lk,
130*95c635efSGarrett D'Amore 	MDOC_Mt,
131*95c635efSGarrett D'Amore 	MDOC_Brq,
132*95c635efSGarrett D'Amore 	MDOC_Bro,
133*95c635efSGarrett D'Amore 	MDOC_Brc,
134*95c635efSGarrett D'Amore 	MDOC__C,
135*95c635efSGarrett D'Amore 	MDOC_Es,
136*95c635efSGarrett D'Amore 	MDOC_En,
137*95c635efSGarrett D'Amore 	MDOC_Dx,
138*95c635efSGarrett D'Amore 	MDOC__Q,
139*95c635efSGarrett D'Amore 	MDOC_br,
140*95c635efSGarrett D'Amore 	MDOC_sp,
141*95c635efSGarrett D'Amore 	MDOC__U,
142*95c635efSGarrett D'Amore 	MDOC_Ta,
143*95c635efSGarrett D'Amore 	MDOC_MAX
144*95c635efSGarrett D'Amore };
145*95c635efSGarrett D'Amore 
146*95c635efSGarrett D'Amore enum	mdocargt {
147*95c635efSGarrett D'Amore 	MDOC_Split, /* -split */
148*95c635efSGarrett D'Amore 	MDOC_Nosplit, /* -nospli */
149*95c635efSGarrett D'Amore 	MDOC_Ragged, /* -ragged */
150*95c635efSGarrett D'Amore 	MDOC_Unfilled, /* -unfilled */
151*95c635efSGarrett D'Amore 	MDOC_Literal, /* -literal */
152*95c635efSGarrett D'Amore 	MDOC_File, /* -file */
153*95c635efSGarrett D'Amore 	MDOC_Offset, /* -offset */
154*95c635efSGarrett D'Amore 	MDOC_Bullet, /* -bullet */
155*95c635efSGarrett D'Amore 	MDOC_Dash, /* -dash */
156*95c635efSGarrett D'Amore 	MDOC_Hyphen, /* -hyphen */
157*95c635efSGarrett D'Amore 	MDOC_Item, /* -item */
158*95c635efSGarrett D'Amore 	MDOC_Enum, /* -enum */
159*95c635efSGarrett D'Amore 	MDOC_Tag, /* -tag */
160*95c635efSGarrett D'Amore 	MDOC_Diag, /* -diag */
161*95c635efSGarrett D'Amore 	MDOC_Hang, /* -hang */
162*95c635efSGarrett D'Amore 	MDOC_Ohang, /* -ohang */
163*95c635efSGarrett D'Amore 	MDOC_Inset, /* -inset */
164*95c635efSGarrett D'Amore 	MDOC_Column, /* -column */
165*95c635efSGarrett D'Amore 	MDOC_Width, /* -width */
166*95c635efSGarrett D'Amore 	MDOC_Compact, /* -compact */
167*95c635efSGarrett D'Amore 	MDOC_Std, /* -std */
168*95c635efSGarrett D'Amore 	MDOC_Filled, /* -filled */
169*95c635efSGarrett D'Amore 	MDOC_Words, /* -words */
170*95c635efSGarrett D'Amore 	MDOC_Emphasis, /* -emphasis */
171*95c635efSGarrett D'Amore 	MDOC_Symbolic, /* -symbolic */
172*95c635efSGarrett D'Amore 	MDOC_Nested, /* -nested */
173*95c635efSGarrett D'Amore 	MDOC_Centred, /* -centered */
174*95c635efSGarrett D'Amore 	MDOC_ARG_MAX
175*95c635efSGarrett D'Amore };
176*95c635efSGarrett D'Amore 
177*95c635efSGarrett D'Amore enum	mdoc_type {
178*95c635efSGarrett D'Amore 	MDOC_TEXT,
179*95c635efSGarrett D'Amore 	MDOC_ELEM,
180*95c635efSGarrett D'Amore 	MDOC_HEAD,
181*95c635efSGarrett D'Amore 	MDOC_TAIL,
182*95c635efSGarrett D'Amore 	MDOC_BODY,
183*95c635efSGarrett D'Amore 	MDOC_BLOCK,
184*95c635efSGarrett D'Amore 	MDOC_TBL,
185*95c635efSGarrett D'Amore 	MDOC_EQN,
186*95c635efSGarrett D'Amore 	MDOC_ROOT
187*95c635efSGarrett D'Amore };
188*95c635efSGarrett D'Amore 
189*95c635efSGarrett D'Amore /*
190*95c635efSGarrett D'Amore  * Section (named/unnamed) of `Sh'.   Note that these appear in the
191*95c635efSGarrett D'Amore  * conventional order imposed by mdoc.7.  In the case of SEC_NONE, no
192*95c635efSGarrett D'Amore  * section has been invoked (this shouldn't happen).  SEC_CUSTOM refers
193*95c635efSGarrett D'Amore  * to other sections.
194*95c635efSGarrett D'Amore  */
195*95c635efSGarrett D'Amore enum	mdoc_sec {
196*95c635efSGarrett D'Amore 	SEC_NONE = 0,
197*95c635efSGarrett D'Amore 	SEC_NAME, /* NAME */
198*95c635efSGarrett D'Amore 	SEC_LIBRARY, /* LIBRARY */
199*95c635efSGarrett D'Amore 	SEC_SYNOPSIS, /* SYNOPSIS */
200*95c635efSGarrett D'Amore 	SEC_DESCRIPTION, /* DESCRIPTION */
201*95c635efSGarrett D'Amore 	SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
202*95c635efSGarrett D'Amore 	SEC_RETURN_VALUES, /* RETURN VALUES */
203*95c635efSGarrett D'Amore 	SEC_ENVIRONMENT,  /* ENVIRONMENT */
204*95c635efSGarrett D'Amore 	SEC_FILES, /* FILES */
205*95c635efSGarrett D'Amore 	SEC_EXIT_STATUS, /* EXIT STATUS */
206*95c635efSGarrett D'Amore 	SEC_EXAMPLES, /* EXAMPLES */
207*95c635efSGarrett D'Amore 	SEC_DIAGNOSTICS, /* DIAGNOSTICS */
208*95c635efSGarrett D'Amore 	SEC_COMPATIBILITY, /* COMPATIBILITY */
209*95c635efSGarrett D'Amore 	SEC_ERRORS, /* ERRORS */
210*95c635efSGarrett D'Amore 	SEC_SEE_ALSO, /* SEE ALSO */
211*95c635efSGarrett D'Amore 	SEC_STANDARDS, /* STANDARDS */
212*95c635efSGarrett D'Amore 	SEC_HISTORY, /* HISTORY */
213*95c635efSGarrett D'Amore 	SEC_AUTHORS, /* AUTHORS */
214*95c635efSGarrett D'Amore 	SEC_CAVEATS, /* CAVEATS */
215*95c635efSGarrett D'Amore 	SEC_BUGS, /* BUGS */
216*95c635efSGarrett D'Amore 	SEC_SECURITY, /* SECURITY */
217*95c635efSGarrett D'Amore 	SEC_CUSTOM,
218*95c635efSGarrett D'Amore 	SEC__MAX
219*95c635efSGarrett D'Amore };
220*95c635efSGarrett D'Amore 
221*95c635efSGarrett D'Amore struct	mdoc_meta {
222*95c635efSGarrett D'Amore 	char		 *msec; /* `Dt' section (1, 3p, etc.) */
223*95c635efSGarrett D'Amore 	char		 *vol; /* `Dt' volume (implied) */
224*95c635efSGarrett D'Amore 	char		 *arch; /* `Dt' arch (i386, etc.) */
225*95c635efSGarrett D'Amore 	char		 *date; /* `Dd' normalised date */
226*95c635efSGarrett D'Amore 	char		 *title; /* `Dt' title (FOO, etc.) */
227*95c635efSGarrett D'Amore 	char		 *os; /* `Os' system (OpenBSD, etc.) */
228*95c635efSGarrett D'Amore 	char		 *name; /* leading `Nm' name */
229*95c635efSGarrett D'Amore };
230*95c635efSGarrett D'Amore 
231*95c635efSGarrett D'Amore /*
232*95c635efSGarrett D'Amore  * An argument to a macro (multiple values = `-column xxx yyy').
233*95c635efSGarrett D'Amore  */
234*95c635efSGarrett D'Amore struct	mdoc_argv {
235*95c635efSGarrett D'Amore 	enum mdocargt  	  arg; /* type of argument */
236*95c635efSGarrett D'Amore 	int		  line;
237*95c635efSGarrett D'Amore 	int		  pos;
238*95c635efSGarrett D'Amore 	size_t		  sz; /* elements in "value" */
239*95c635efSGarrett D'Amore 	char		**value; /* argument strings */
240*95c635efSGarrett D'Amore };
241*95c635efSGarrett D'Amore 
242*95c635efSGarrett D'Amore /*
243*95c635efSGarrett D'Amore  * Reference-counted macro arguments.  These are refcounted because
244*95c635efSGarrett D'Amore  * blocks have multiple instances of the same arguments spread across
245*95c635efSGarrett D'Amore  * the HEAD, BODY, TAIL, and BLOCK node types.
246*95c635efSGarrett D'Amore  */
247*95c635efSGarrett D'Amore struct 	mdoc_arg {
248*95c635efSGarrett D'Amore 	size_t		  argc;
249*95c635efSGarrett D'Amore 	struct mdoc_argv *argv;
250*95c635efSGarrett D'Amore 	unsigned int	  refcnt;
251*95c635efSGarrett D'Amore };
252*95c635efSGarrett D'Amore 
253*95c635efSGarrett D'Amore /*
254*95c635efSGarrett D'Amore  * Indicates that a BODY's formatting has ended, but the scope is still
255*95c635efSGarrett D'Amore  * open.  Used for syntax-broken blocks.
256*95c635efSGarrett D'Amore  */
257*95c635efSGarrett D'Amore enum	mdoc_endbody {
258*95c635efSGarrett D'Amore 	ENDBODY_NOT = 0,
259*95c635efSGarrett D'Amore 	ENDBODY_SPACE, /* is broken: append a space */
260*95c635efSGarrett D'Amore 	ENDBODY_NOSPACE /* is broken: don't append a space */
261*95c635efSGarrett D'Amore };
262*95c635efSGarrett D'Amore 
263*95c635efSGarrett D'Amore enum	mdoc_list {
264*95c635efSGarrett D'Amore 	LIST__NONE = 0,
265*95c635efSGarrett D'Amore 	LIST_bullet, /* -bullet */
266*95c635efSGarrett D'Amore 	LIST_column, /* -column */
267*95c635efSGarrett D'Amore 	LIST_dash, /* -dash */
268*95c635efSGarrett D'Amore 	LIST_diag, /* -diag */
269*95c635efSGarrett D'Amore 	LIST_enum, /* -enum */
270*95c635efSGarrett D'Amore 	LIST_hang, /* -hang */
271*95c635efSGarrett D'Amore 	LIST_hyphen, /* -hyphen */
272*95c635efSGarrett D'Amore 	LIST_inset, /* -inset */
273*95c635efSGarrett D'Amore 	LIST_item, /* -item */
274*95c635efSGarrett D'Amore 	LIST_ohang, /* -ohang */
275*95c635efSGarrett D'Amore 	LIST_tag, /* -tag */
276*95c635efSGarrett D'Amore 	LIST_MAX
277*95c635efSGarrett D'Amore };
278*95c635efSGarrett D'Amore 
279*95c635efSGarrett D'Amore enum	mdoc_disp {
280*95c635efSGarrett D'Amore 	DISP__NONE = 0,
281*95c635efSGarrett D'Amore 	DISP_centred, /* -centered */
282*95c635efSGarrett D'Amore 	DISP_ragged, /* -ragged */
283*95c635efSGarrett D'Amore 	DISP_unfilled, /* -unfilled */
284*95c635efSGarrett D'Amore 	DISP_filled, /* -filled */
285*95c635efSGarrett D'Amore 	DISP_literal /* -literal */
286*95c635efSGarrett D'Amore };
287*95c635efSGarrett D'Amore 
288*95c635efSGarrett D'Amore enum	mdoc_auth {
289*95c635efSGarrett D'Amore 	AUTH__NONE = 0,
290*95c635efSGarrett D'Amore 	AUTH_split, /* -split */
291*95c635efSGarrett D'Amore 	AUTH_nosplit /* -nosplit */
292*95c635efSGarrett D'Amore };
293*95c635efSGarrett D'Amore 
294*95c635efSGarrett D'Amore enum	mdoc_font {
295*95c635efSGarrett D'Amore 	FONT__NONE = 0,
296*95c635efSGarrett D'Amore 	FONT_Em, /* Em, -emphasis */
297*95c635efSGarrett D'Amore 	FONT_Li, /* Li, -literal */
298*95c635efSGarrett D'Amore 	FONT_Sy /* Sy, -symbolic */
299*95c635efSGarrett D'Amore };
300*95c635efSGarrett D'Amore 
301*95c635efSGarrett D'Amore struct	mdoc_bd {
302*95c635efSGarrett D'Amore 	const char	 *offs; /* -offset */
303*95c635efSGarrett D'Amore 	enum mdoc_disp	  type; /* -ragged, etc. */
304*95c635efSGarrett D'Amore 	int		  comp; /* -compact */
305*95c635efSGarrett D'Amore };
306*95c635efSGarrett D'Amore 
307*95c635efSGarrett D'Amore struct	mdoc_bl {
308*95c635efSGarrett D'Amore 	const char	 *width; /* -width */
309*95c635efSGarrett D'Amore 	const char	 *offs; /* -offset */
310*95c635efSGarrett D'Amore 	enum mdoc_list	  type; /* -tag, -enum, etc. */
311*95c635efSGarrett D'Amore 	int		  comp; /* -compact */
312*95c635efSGarrett D'Amore 	size_t		  ncols; /* -column arg count */
313*95c635efSGarrett D'Amore 	const char	**cols; /* -column val ptr */
314*95c635efSGarrett D'Amore };
315*95c635efSGarrett D'Amore 
316*95c635efSGarrett D'Amore struct	mdoc_bf {
317*95c635efSGarrett D'Amore 	enum mdoc_font	  font; /* font */
318*95c635efSGarrett D'Amore };
319*95c635efSGarrett D'Amore 
320*95c635efSGarrett D'Amore struct	mdoc_an {
321*95c635efSGarrett D'Amore 	enum mdoc_auth	  auth; /* -split, etc. */
322*95c635efSGarrett D'Amore };
323*95c635efSGarrett D'Amore 
324*95c635efSGarrett D'Amore struct	mdoc_rs {
325*95c635efSGarrett D'Amore 	int		  quote_T; /* whether to quote %T */
326*95c635efSGarrett D'Amore };
327*95c635efSGarrett D'Amore 
328*95c635efSGarrett D'Amore /*
329*95c635efSGarrett D'Amore  * Consists of normalised node arguments.  These should be used instead
330*95c635efSGarrett D'Amore  * of iterating through the mdoc_arg pointers of a node: defaults are
331*95c635efSGarrett D'Amore  * provided, etc.
332*95c635efSGarrett D'Amore  */
333*95c635efSGarrett D'Amore union	mdoc_data {
334*95c635efSGarrett D'Amore 	struct mdoc_an 	  An;
335*95c635efSGarrett D'Amore 	struct mdoc_bd	  Bd;
336*95c635efSGarrett D'Amore 	struct mdoc_bf	  Bf;
337*95c635efSGarrett D'Amore 	struct mdoc_bl	  Bl;
338*95c635efSGarrett D'Amore 	struct mdoc_rs	  Rs;
339*95c635efSGarrett D'Amore };
340*95c635efSGarrett D'Amore 
341*95c635efSGarrett D'Amore /*
342*95c635efSGarrett D'Amore  * Single node in tree-linked AST.
343*95c635efSGarrett D'Amore  */
344*95c635efSGarrett D'Amore struct	mdoc_node {
345*95c635efSGarrett D'Amore 	struct mdoc_node *parent; /* parent AST node */
346*95c635efSGarrett D'Amore 	struct mdoc_node *child; /* first child AST node */
347*95c635efSGarrett D'Amore 	struct mdoc_node *last; /* last child AST node */
348*95c635efSGarrett D'Amore 	struct mdoc_node *next; /* sibling AST node */
349*95c635efSGarrett D'Amore 	struct mdoc_node *prev; /* prior sibling AST node */
350*95c635efSGarrett D'Amore 	int		  nchild; /* number children */
351*95c635efSGarrett D'Amore 	int		  line; /* parse line */
352*95c635efSGarrett D'Amore 	int		  pos; /* parse column */
353*95c635efSGarrett D'Amore 	enum mdoct	  tok; /* tok or MDOC__MAX if none */
354*95c635efSGarrett D'Amore 	int		  flags;
355*95c635efSGarrett D'Amore #define	MDOC_VALID	 (1 << 0) /* has been validated */
356*95c635efSGarrett D'Amore #define	MDOC_EOS	 (1 << 2) /* at sentence boundary */
357*95c635efSGarrett D'Amore #define	MDOC_LINE	 (1 << 3) /* first macro/text on line */
358*95c635efSGarrett D'Amore #define	MDOC_SYNPRETTY	 (1 << 4) /* SYNOPSIS-style formatting */
359*95c635efSGarrett D'Amore #define	MDOC_ENDED	 (1 << 5) /* rendering has been ended */
360*95c635efSGarrett D'Amore #define	MDOC_DELIMO	 (1 << 6)
361*95c635efSGarrett D'Amore #define	MDOC_DELIMC	 (1 << 7)
362*95c635efSGarrett D'Amore 	enum mdoc_type	  type; /* AST node type */
363*95c635efSGarrett D'Amore 	enum mdoc_sec	  sec; /* current named section */
364*95c635efSGarrett D'Amore 	union mdoc_data	 *norm; /* normalised args */
365*95c635efSGarrett D'Amore 	/* FIXME: these can be union'd to shave a few bytes. */
366*95c635efSGarrett D'Amore 	struct mdoc_arg	 *args; /* BLOCK/ELEM */
367*95c635efSGarrett D'Amore 	struct mdoc_node *pending; /* BLOCK */
368*95c635efSGarrett D'Amore 	struct mdoc_node *head; /* BLOCK */
369*95c635efSGarrett D'Amore 	struct mdoc_node *body; /* BLOCK */
370*95c635efSGarrett D'Amore 	struct mdoc_node *tail; /* BLOCK */
371*95c635efSGarrett D'Amore 	char		 *string; /* TEXT */
372*95c635efSGarrett D'Amore 	const struct tbl_span *span; /* TBL */
373*95c635efSGarrett D'Amore 	const struct eqn *eqn; /* EQN */
374*95c635efSGarrett D'Amore 	enum mdoc_endbody end; /* BODY */
375*95c635efSGarrett D'Amore };
376*95c635efSGarrett D'Amore 
377*95c635efSGarrett D'Amore /* Names of macros.  Index is enum mdoct. */
378*95c635efSGarrett D'Amore extern	const char *const *mdoc_macronames;
379*95c635efSGarrett D'Amore 
380*95c635efSGarrett D'Amore /* Names of macro args.  Index is enum mdocargt. */
381*95c635efSGarrett D'Amore extern	const char *const *mdoc_argnames;
382*95c635efSGarrett D'Amore 
383*95c635efSGarrett D'Amore __BEGIN_DECLS
384*95c635efSGarrett D'Amore 
385*95c635efSGarrett D'Amore struct	mdoc;
386*95c635efSGarrett D'Amore 
387*95c635efSGarrett D'Amore const struct mdoc_node *mdoc_node(const struct mdoc *);
388*95c635efSGarrett D'Amore const struct mdoc_meta *mdoc_meta(const struct mdoc *);
389*95c635efSGarrett D'Amore 
390*95c635efSGarrett D'Amore __END_DECLS
391*95c635efSGarrett D'Amore 
392*95c635efSGarrett D'Amore #endif /*!MDOC_H*/
393