xref: /titanic_51/usr/src/cmd/mandoc/mdoc.h (revision 260e9a87725c090ba5835b1f9f0b62fa2f96036f)
1*260e9a87SYuri Pankov /*	$Id: mdoc.h,v 1.136 2015/02/12 12:24:33 schwarze Exp $ */
295c635efSGarrett D'Amore /*
395c635efSGarrett D'Amore  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4*260e9a87SYuri Pankov  * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
595c635efSGarrett D'Amore  *
695c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
795c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
895c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
995c635efSGarrett D'Amore  *
1095c635efSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1195c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1295c635efSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1395c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1495c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1595c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1695c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1795c635efSGarrett D'Amore  */
1895c635efSGarrett D'Amore 
1995c635efSGarrett D'Amore enum	mdoct {
2095c635efSGarrett D'Amore 	MDOC_Ap = 0,
2195c635efSGarrett D'Amore 	MDOC_Dd,
2295c635efSGarrett D'Amore 	MDOC_Dt,
2395c635efSGarrett D'Amore 	MDOC_Os,
2495c635efSGarrett D'Amore 	MDOC_Sh,
2595c635efSGarrett D'Amore 	MDOC_Ss,
2695c635efSGarrett D'Amore 	MDOC_Pp,
2795c635efSGarrett D'Amore 	MDOC_D1,
2895c635efSGarrett D'Amore 	MDOC_Dl,
2995c635efSGarrett D'Amore 	MDOC_Bd,
3095c635efSGarrett D'Amore 	MDOC_Ed,
3195c635efSGarrett D'Amore 	MDOC_Bl,
3295c635efSGarrett D'Amore 	MDOC_El,
3395c635efSGarrett D'Amore 	MDOC_It,
3495c635efSGarrett D'Amore 	MDOC_Ad,
3595c635efSGarrett D'Amore 	MDOC_An,
3695c635efSGarrett D'Amore 	MDOC_Ar,
3795c635efSGarrett D'Amore 	MDOC_Cd,
3895c635efSGarrett D'Amore 	MDOC_Cm,
3995c635efSGarrett D'Amore 	MDOC_Dv,
4095c635efSGarrett D'Amore 	MDOC_Er,
4195c635efSGarrett D'Amore 	MDOC_Ev,
4295c635efSGarrett D'Amore 	MDOC_Ex,
4395c635efSGarrett D'Amore 	MDOC_Fa,
4495c635efSGarrett D'Amore 	MDOC_Fd,
4595c635efSGarrett D'Amore 	MDOC_Fl,
4695c635efSGarrett D'Amore 	MDOC_Fn,
4795c635efSGarrett D'Amore 	MDOC_Ft,
4895c635efSGarrett D'Amore 	MDOC_Ic,
4995c635efSGarrett D'Amore 	MDOC_In,
5095c635efSGarrett D'Amore 	MDOC_Li,
5195c635efSGarrett D'Amore 	MDOC_Nd,
5295c635efSGarrett D'Amore 	MDOC_Nm,
5395c635efSGarrett D'Amore 	MDOC_Op,
5495c635efSGarrett D'Amore 	MDOC_Ot,
5595c635efSGarrett D'Amore 	MDOC_Pa,
5695c635efSGarrett D'Amore 	MDOC_Rv,
5795c635efSGarrett D'Amore 	MDOC_St,
5895c635efSGarrett D'Amore 	MDOC_Va,
5995c635efSGarrett D'Amore 	MDOC_Vt,
6095c635efSGarrett D'Amore 	MDOC_Xr,
6195c635efSGarrett D'Amore 	MDOC__A,
6295c635efSGarrett D'Amore 	MDOC__B,
6395c635efSGarrett D'Amore 	MDOC__D,
6495c635efSGarrett D'Amore 	MDOC__I,
6595c635efSGarrett D'Amore 	MDOC__J,
6695c635efSGarrett D'Amore 	MDOC__N,
6795c635efSGarrett D'Amore 	MDOC__O,
6895c635efSGarrett D'Amore 	MDOC__P,
6995c635efSGarrett D'Amore 	MDOC__R,
7095c635efSGarrett D'Amore 	MDOC__T,
7195c635efSGarrett D'Amore 	MDOC__V,
7295c635efSGarrett D'Amore 	MDOC_Ac,
7395c635efSGarrett D'Amore 	MDOC_Ao,
7495c635efSGarrett D'Amore 	MDOC_Aq,
7595c635efSGarrett D'Amore 	MDOC_At,
7695c635efSGarrett D'Amore 	MDOC_Bc,
7795c635efSGarrett D'Amore 	MDOC_Bf,
7895c635efSGarrett D'Amore 	MDOC_Bo,
7995c635efSGarrett D'Amore 	MDOC_Bq,
8095c635efSGarrett D'Amore 	MDOC_Bsx,
8195c635efSGarrett D'Amore 	MDOC_Bx,
8295c635efSGarrett D'Amore 	MDOC_Db,
8395c635efSGarrett D'Amore 	MDOC_Dc,
8495c635efSGarrett D'Amore 	MDOC_Do,
8595c635efSGarrett D'Amore 	MDOC_Dq,
8695c635efSGarrett D'Amore 	MDOC_Ec,
8795c635efSGarrett D'Amore 	MDOC_Ef,
8895c635efSGarrett D'Amore 	MDOC_Em,
8995c635efSGarrett D'Amore 	MDOC_Eo,
9095c635efSGarrett D'Amore 	MDOC_Fx,
9195c635efSGarrett D'Amore 	MDOC_Ms,
9295c635efSGarrett D'Amore 	MDOC_No,
9395c635efSGarrett D'Amore 	MDOC_Ns,
9495c635efSGarrett D'Amore 	MDOC_Nx,
9595c635efSGarrett D'Amore 	MDOC_Ox,
9695c635efSGarrett D'Amore 	MDOC_Pc,
9795c635efSGarrett D'Amore 	MDOC_Pf,
9895c635efSGarrett D'Amore 	MDOC_Po,
9995c635efSGarrett D'Amore 	MDOC_Pq,
10095c635efSGarrett D'Amore 	MDOC_Qc,
10195c635efSGarrett D'Amore 	MDOC_Ql,
10295c635efSGarrett D'Amore 	MDOC_Qo,
10395c635efSGarrett D'Amore 	MDOC_Qq,
10495c635efSGarrett D'Amore 	MDOC_Re,
10595c635efSGarrett D'Amore 	MDOC_Rs,
10695c635efSGarrett D'Amore 	MDOC_Sc,
10795c635efSGarrett D'Amore 	MDOC_So,
10895c635efSGarrett D'Amore 	MDOC_Sq,
10995c635efSGarrett D'Amore 	MDOC_Sm,
11095c635efSGarrett D'Amore 	MDOC_Sx,
11195c635efSGarrett D'Amore 	MDOC_Sy,
11295c635efSGarrett D'Amore 	MDOC_Tn,
11395c635efSGarrett D'Amore 	MDOC_Ux,
11495c635efSGarrett D'Amore 	MDOC_Xc,
11595c635efSGarrett D'Amore 	MDOC_Xo,
11695c635efSGarrett D'Amore 	MDOC_Fo,
11795c635efSGarrett D'Amore 	MDOC_Fc,
11895c635efSGarrett D'Amore 	MDOC_Oo,
11995c635efSGarrett D'Amore 	MDOC_Oc,
12095c635efSGarrett D'Amore 	MDOC_Bk,
12195c635efSGarrett D'Amore 	MDOC_Ek,
12295c635efSGarrett D'Amore 	MDOC_Bt,
12395c635efSGarrett D'Amore 	MDOC_Hf,
12495c635efSGarrett D'Amore 	MDOC_Fr,
12595c635efSGarrett D'Amore 	MDOC_Ud,
12695c635efSGarrett D'Amore 	MDOC_Lb,
12795c635efSGarrett D'Amore 	MDOC_Lp,
12895c635efSGarrett D'Amore 	MDOC_Lk,
12995c635efSGarrett D'Amore 	MDOC_Mt,
13095c635efSGarrett D'Amore 	MDOC_Brq,
13195c635efSGarrett D'Amore 	MDOC_Bro,
13295c635efSGarrett D'Amore 	MDOC_Brc,
13395c635efSGarrett D'Amore 	MDOC__C,
13495c635efSGarrett D'Amore 	MDOC_Es,
13595c635efSGarrett D'Amore 	MDOC_En,
13695c635efSGarrett D'Amore 	MDOC_Dx,
13795c635efSGarrett D'Amore 	MDOC__Q,
13895c635efSGarrett D'Amore 	MDOC_br,
13995c635efSGarrett D'Amore 	MDOC_sp,
14095c635efSGarrett D'Amore 	MDOC__U,
14195c635efSGarrett D'Amore 	MDOC_Ta,
142*260e9a87SYuri Pankov 	MDOC_ll,
14395c635efSGarrett D'Amore 	MDOC_MAX
14495c635efSGarrett D'Amore };
14595c635efSGarrett D'Amore 
14695c635efSGarrett D'Amore enum	mdocargt {
14795c635efSGarrett D'Amore 	MDOC_Split, /* -split */
14895c635efSGarrett D'Amore 	MDOC_Nosplit, /* -nospli */
14995c635efSGarrett D'Amore 	MDOC_Ragged, /* -ragged */
15095c635efSGarrett D'Amore 	MDOC_Unfilled, /* -unfilled */
15195c635efSGarrett D'Amore 	MDOC_Literal, /* -literal */
15295c635efSGarrett D'Amore 	MDOC_File, /* -file */
15395c635efSGarrett D'Amore 	MDOC_Offset, /* -offset */
15495c635efSGarrett D'Amore 	MDOC_Bullet, /* -bullet */
15595c635efSGarrett D'Amore 	MDOC_Dash, /* -dash */
15695c635efSGarrett D'Amore 	MDOC_Hyphen, /* -hyphen */
15795c635efSGarrett D'Amore 	MDOC_Item, /* -item */
15895c635efSGarrett D'Amore 	MDOC_Enum, /* -enum */
15995c635efSGarrett D'Amore 	MDOC_Tag, /* -tag */
16095c635efSGarrett D'Amore 	MDOC_Diag, /* -diag */
16195c635efSGarrett D'Amore 	MDOC_Hang, /* -hang */
16295c635efSGarrett D'Amore 	MDOC_Ohang, /* -ohang */
16395c635efSGarrett D'Amore 	MDOC_Inset, /* -inset */
16495c635efSGarrett D'Amore 	MDOC_Column, /* -column */
16595c635efSGarrett D'Amore 	MDOC_Width, /* -width */
16695c635efSGarrett D'Amore 	MDOC_Compact, /* -compact */
16795c635efSGarrett D'Amore 	MDOC_Std, /* -std */
16895c635efSGarrett D'Amore 	MDOC_Filled, /* -filled */
16995c635efSGarrett D'Amore 	MDOC_Words, /* -words */
17095c635efSGarrett D'Amore 	MDOC_Emphasis, /* -emphasis */
17195c635efSGarrett D'Amore 	MDOC_Symbolic, /* -symbolic */
17295c635efSGarrett D'Amore 	MDOC_Nested, /* -nested */
17395c635efSGarrett D'Amore 	MDOC_Centred, /* -centered */
17495c635efSGarrett D'Amore 	MDOC_ARG_MAX
17595c635efSGarrett D'Amore };
17695c635efSGarrett D'Amore 
17795c635efSGarrett D'Amore enum	mdoc_type {
17895c635efSGarrett D'Amore 	MDOC_TEXT,
17995c635efSGarrett D'Amore 	MDOC_ELEM,
18095c635efSGarrett D'Amore 	MDOC_HEAD,
18195c635efSGarrett D'Amore 	MDOC_TAIL,
18295c635efSGarrett D'Amore 	MDOC_BODY,
18395c635efSGarrett D'Amore 	MDOC_BLOCK,
18495c635efSGarrett D'Amore 	MDOC_TBL,
18595c635efSGarrett D'Amore 	MDOC_EQN,
18695c635efSGarrett D'Amore 	MDOC_ROOT
18795c635efSGarrett D'Amore };
18895c635efSGarrett D'Amore 
18995c635efSGarrett D'Amore /*
19095c635efSGarrett D'Amore  * Section (named/unnamed) of `Sh'.   Note that these appear in the
19195c635efSGarrett D'Amore  * conventional order imposed by mdoc.7.  In the case of SEC_NONE, no
19295c635efSGarrett D'Amore  * section has been invoked (this shouldn't happen).  SEC_CUSTOM refers
19395c635efSGarrett D'Amore  * to other sections.
19495c635efSGarrett D'Amore  */
19595c635efSGarrett D'Amore enum	mdoc_sec {
19695c635efSGarrett D'Amore 	SEC_NONE = 0,
19795c635efSGarrett D'Amore 	SEC_NAME, /* NAME */
19895c635efSGarrett D'Amore 	SEC_LIBRARY, /* LIBRARY */
19995c635efSGarrett D'Amore 	SEC_SYNOPSIS, /* SYNOPSIS */
20095c635efSGarrett D'Amore 	SEC_DESCRIPTION, /* DESCRIPTION */
201*260e9a87SYuri Pankov 	SEC_CONTEXT, /* CONTEXT */
20295c635efSGarrett D'Amore 	SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
20395c635efSGarrett D'Amore 	SEC_RETURN_VALUES, /* RETURN VALUES */
20495c635efSGarrett D'Amore 	SEC_ENVIRONMENT,  /* ENVIRONMENT */
20595c635efSGarrett D'Amore 	SEC_FILES, /* FILES */
20695c635efSGarrett D'Amore 	SEC_EXIT_STATUS, /* EXIT STATUS */
20795c635efSGarrett D'Amore 	SEC_EXAMPLES, /* EXAMPLES */
20895c635efSGarrett D'Amore 	SEC_DIAGNOSTICS, /* DIAGNOSTICS */
20995c635efSGarrett D'Amore 	SEC_COMPATIBILITY, /* COMPATIBILITY */
21095c635efSGarrett D'Amore 	SEC_ERRORS, /* ERRORS */
21195c635efSGarrett D'Amore 	SEC_SEE_ALSO, /* SEE ALSO */
21295c635efSGarrett D'Amore 	SEC_STANDARDS, /* STANDARDS */
21395c635efSGarrett D'Amore 	SEC_HISTORY, /* HISTORY */
21495c635efSGarrett D'Amore 	SEC_AUTHORS, /* AUTHORS */
21595c635efSGarrett D'Amore 	SEC_CAVEATS, /* CAVEATS */
21695c635efSGarrett D'Amore 	SEC_BUGS, /* BUGS */
21795c635efSGarrett D'Amore 	SEC_SECURITY, /* SECURITY */
21895c635efSGarrett D'Amore 	SEC_CUSTOM,
21995c635efSGarrett D'Amore 	SEC__MAX
22095c635efSGarrett D'Amore };
22195c635efSGarrett D'Amore 
22295c635efSGarrett D'Amore struct	mdoc_meta {
22395c635efSGarrett D'Amore 	char		 *msec; /* `Dt' section (1, 3p, etc.) */
22495c635efSGarrett D'Amore 	char		 *vol; /* `Dt' volume (implied) */
22595c635efSGarrett D'Amore 	char		 *arch; /* `Dt' arch (i386, etc.) */
22695c635efSGarrett D'Amore 	char		 *date; /* `Dd' normalised date */
22795c635efSGarrett D'Amore 	char		 *title; /* `Dt' title (FOO, etc.) */
22895c635efSGarrett D'Amore 	char		 *os; /* `Os' system (OpenBSD, etc.) */
22995c635efSGarrett D'Amore 	char		 *name; /* leading `Nm' name */
23095c635efSGarrett D'Amore };
23195c635efSGarrett D'Amore 
23295c635efSGarrett D'Amore /*
23395c635efSGarrett D'Amore  * An argument to a macro (multiple values = `-column xxx yyy').
23495c635efSGarrett D'Amore  */
23595c635efSGarrett D'Amore struct	mdoc_argv {
23695c635efSGarrett D'Amore 	enum mdocargt	  arg; /* type of argument */
23795c635efSGarrett D'Amore 	int		  line;
23895c635efSGarrett D'Amore 	int		  pos;
23995c635efSGarrett D'Amore 	size_t		  sz; /* elements in "value" */
24095c635efSGarrett D'Amore 	char		**value; /* argument strings */
24195c635efSGarrett D'Amore };
24295c635efSGarrett D'Amore 
24395c635efSGarrett D'Amore /*
24495c635efSGarrett D'Amore  * Reference-counted macro arguments.  These are refcounted because
24595c635efSGarrett D'Amore  * blocks have multiple instances of the same arguments spread across
24695c635efSGarrett D'Amore  * the HEAD, BODY, TAIL, and BLOCK node types.
24795c635efSGarrett D'Amore  */
24895c635efSGarrett D'Amore struct	mdoc_arg {
24995c635efSGarrett D'Amore 	size_t		  argc;
25095c635efSGarrett D'Amore 	struct mdoc_argv *argv;
25195c635efSGarrett D'Amore 	unsigned int	  refcnt;
25295c635efSGarrett D'Amore };
25395c635efSGarrett D'Amore 
25495c635efSGarrett D'Amore /*
25595c635efSGarrett D'Amore  * Indicates that a BODY's formatting has ended, but the scope is still
25695c635efSGarrett D'Amore  * open.  Used for syntax-broken blocks.
25795c635efSGarrett D'Amore  */
25895c635efSGarrett D'Amore enum	mdoc_endbody {
25995c635efSGarrett D'Amore 	ENDBODY_NOT = 0,
26095c635efSGarrett D'Amore 	ENDBODY_SPACE, /* is broken: append a space */
26195c635efSGarrett D'Amore 	ENDBODY_NOSPACE /* is broken: don't append a space */
26295c635efSGarrett D'Amore };
26395c635efSGarrett D'Amore 
26495c635efSGarrett D'Amore enum	mdoc_list {
26595c635efSGarrett D'Amore 	LIST__NONE = 0,
26695c635efSGarrett D'Amore 	LIST_bullet, /* -bullet */
26795c635efSGarrett D'Amore 	LIST_column, /* -column */
26895c635efSGarrett D'Amore 	LIST_dash, /* -dash */
26995c635efSGarrett D'Amore 	LIST_diag, /* -diag */
27095c635efSGarrett D'Amore 	LIST_enum, /* -enum */
27195c635efSGarrett D'Amore 	LIST_hang, /* -hang */
27295c635efSGarrett D'Amore 	LIST_hyphen, /* -hyphen */
27395c635efSGarrett D'Amore 	LIST_inset, /* -inset */
27495c635efSGarrett D'Amore 	LIST_item, /* -item */
27595c635efSGarrett D'Amore 	LIST_ohang, /* -ohang */
27695c635efSGarrett D'Amore 	LIST_tag, /* -tag */
27795c635efSGarrett D'Amore 	LIST_MAX
27895c635efSGarrett D'Amore };
27995c635efSGarrett D'Amore 
28095c635efSGarrett D'Amore enum	mdoc_disp {
28195c635efSGarrett D'Amore 	DISP__NONE = 0,
282*260e9a87SYuri Pankov 	DISP_centered, /* -centered */
28395c635efSGarrett D'Amore 	DISP_ragged, /* -ragged */
28495c635efSGarrett D'Amore 	DISP_unfilled, /* -unfilled */
28595c635efSGarrett D'Amore 	DISP_filled, /* -filled */
28695c635efSGarrett D'Amore 	DISP_literal /* -literal */
28795c635efSGarrett D'Amore };
28895c635efSGarrett D'Amore 
28995c635efSGarrett D'Amore enum	mdoc_auth {
29095c635efSGarrett D'Amore 	AUTH__NONE = 0,
29195c635efSGarrett D'Amore 	AUTH_split, /* -split */
29295c635efSGarrett D'Amore 	AUTH_nosplit /* -nosplit */
29395c635efSGarrett D'Amore };
29495c635efSGarrett D'Amore 
29595c635efSGarrett D'Amore enum	mdoc_font {
29695c635efSGarrett D'Amore 	FONT__NONE = 0,
29795c635efSGarrett D'Amore 	FONT_Em, /* Em, -emphasis */
29895c635efSGarrett D'Amore 	FONT_Li, /* Li, -literal */
29995c635efSGarrett D'Amore 	FONT_Sy /* Sy, -symbolic */
30095c635efSGarrett D'Amore };
30195c635efSGarrett D'Amore 
30295c635efSGarrett D'Amore struct	mdoc_bd {
30395c635efSGarrett D'Amore 	const char	 *offs; /* -offset */
30495c635efSGarrett D'Amore 	enum mdoc_disp	  type; /* -ragged, etc. */
30595c635efSGarrett D'Amore 	int		  comp; /* -compact */
30695c635efSGarrett D'Amore };
30795c635efSGarrett D'Amore 
30895c635efSGarrett D'Amore struct	mdoc_bl {
30995c635efSGarrett D'Amore 	const char	 *width; /* -width */
31095c635efSGarrett D'Amore 	const char	 *offs; /* -offset */
31195c635efSGarrett D'Amore 	enum mdoc_list	  type; /* -tag, -enum, etc. */
31295c635efSGarrett D'Amore 	int		  comp; /* -compact */
31395c635efSGarrett D'Amore 	size_t		  ncols; /* -column arg count */
31495c635efSGarrett D'Amore 	const char	**cols; /* -column val ptr */
315698f87a4SGarrett D'Amore 	int		  count; /* -enum counter */
31695c635efSGarrett D'Amore };
31795c635efSGarrett D'Amore 
31895c635efSGarrett D'Amore struct	mdoc_bf {
31995c635efSGarrett D'Amore 	enum mdoc_font	  font; /* font */
32095c635efSGarrett D'Amore };
32195c635efSGarrett D'Amore 
32295c635efSGarrett D'Amore struct	mdoc_an {
32395c635efSGarrett D'Amore 	enum mdoc_auth	  auth; /* -split, etc. */
32495c635efSGarrett D'Amore };
32595c635efSGarrett D'Amore 
32695c635efSGarrett D'Amore struct	mdoc_rs {
32795c635efSGarrett D'Amore 	int		  quote_T; /* whether to quote %T */
32895c635efSGarrett D'Amore };
32995c635efSGarrett D'Amore 
33095c635efSGarrett D'Amore /*
33195c635efSGarrett D'Amore  * Consists of normalised node arguments.  These should be used instead
33295c635efSGarrett D'Amore  * of iterating through the mdoc_arg pointers of a node: defaults are
33395c635efSGarrett D'Amore  * provided, etc.
33495c635efSGarrett D'Amore  */
33595c635efSGarrett D'Amore union	mdoc_data {
33695c635efSGarrett D'Amore 	struct mdoc_an	  An;
33795c635efSGarrett D'Amore 	struct mdoc_bd	  Bd;
33895c635efSGarrett D'Amore 	struct mdoc_bf	  Bf;
33995c635efSGarrett D'Amore 	struct mdoc_bl	  Bl;
340*260e9a87SYuri Pankov 	struct mdoc_node *Es;
34195c635efSGarrett D'Amore 	struct mdoc_rs	  Rs;
34295c635efSGarrett D'Amore };
34395c635efSGarrett D'Amore 
34495c635efSGarrett D'Amore /*
34595c635efSGarrett D'Amore  * Single node in tree-linked AST.
34695c635efSGarrett D'Amore  */
34795c635efSGarrett D'Amore struct	mdoc_node {
34895c635efSGarrett D'Amore 	struct mdoc_node *parent; /* parent AST node */
34995c635efSGarrett D'Amore 	struct mdoc_node *child; /* first child AST node */
35095c635efSGarrett D'Amore 	struct mdoc_node *last; /* last child AST node */
35195c635efSGarrett D'Amore 	struct mdoc_node *next; /* sibling AST node */
35295c635efSGarrett D'Amore 	struct mdoc_node *prev; /* prior sibling AST node */
35395c635efSGarrett D'Amore 	int		  nchild; /* number children */
35495c635efSGarrett D'Amore 	int		  line; /* parse line */
35595c635efSGarrett D'Amore 	int		  pos; /* parse column */
35695c635efSGarrett D'Amore 	enum mdoct	  tok; /* tok or MDOC__MAX if none */
35795c635efSGarrett D'Amore 	int		  flags;
35895c635efSGarrett D'Amore #define	MDOC_VALID	 (1 << 0) /* has been validated */
359*260e9a87SYuri Pankov #define	MDOC_ENDED	 (1 << 1) /* gone past body end mark */
36095c635efSGarrett D'Amore #define	MDOC_EOS	 (1 << 2) /* at sentence boundary */
36195c635efSGarrett D'Amore #define	MDOC_LINE	 (1 << 3) /* first macro/text on line */
36295c635efSGarrett D'Amore #define	MDOC_SYNPRETTY	 (1 << 4) /* SYNOPSIS-style formatting */
363*260e9a87SYuri Pankov #define	MDOC_BROKEN	 (1 << 5) /* must validate parent when ending */
36495c635efSGarrett D'Amore #define	MDOC_DELIMO	 (1 << 6)
36595c635efSGarrett D'Amore #define	MDOC_DELIMC	 (1 << 7)
36695c635efSGarrett D'Amore 	enum mdoc_type	  type; /* AST node type */
36795c635efSGarrett D'Amore 	enum mdoc_sec	  sec; /* current named section */
36895c635efSGarrett D'Amore 	union mdoc_data	 *norm; /* normalised args */
369*260e9a87SYuri Pankov 	int		  prev_font; /* before entering this node */
37095c635efSGarrett D'Amore 	/* FIXME: these can be union'd to shave a few bytes. */
37195c635efSGarrett D'Amore 	struct mdoc_arg	 *args; /* BLOCK/ELEM */
37295c635efSGarrett D'Amore 	struct mdoc_node *head; /* BLOCK */
373*260e9a87SYuri Pankov 	struct mdoc_node *body; /* BLOCK/ENDBODY */
37495c635efSGarrett D'Amore 	struct mdoc_node *tail; /* BLOCK */
37595c635efSGarrett D'Amore 	char		 *string; /* TEXT */
37695c635efSGarrett D'Amore 	const struct tbl_span *span; /* TBL */
37795c635efSGarrett D'Amore 	const struct eqn *eqn; /* EQN */
37895c635efSGarrett D'Amore 	enum mdoc_endbody end; /* BODY */
37995c635efSGarrett D'Amore };
38095c635efSGarrett D'Amore 
38195c635efSGarrett D'Amore /* Names of macros.  Index is enum mdoct. */
38295c635efSGarrett D'Amore extern	const char *const *mdoc_macronames;
38395c635efSGarrett D'Amore 
38495c635efSGarrett D'Amore /* Names of macro args.  Index is enum mdocargt. */
38595c635efSGarrett D'Amore extern	const char *const *mdoc_argnames;
38695c635efSGarrett D'Amore 
38795c635efSGarrett D'Amore __BEGIN_DECLS
38895c635efSGarrett D'Amore 
38995c635efSGarrett D'Amore struct	mdoc;
39095c635efSGarrett D'Amore 
39195c635efSGarrett D'Amore const struct mdoc_node *mdoc_node(const struct mdoc *);
39295c635efSGarrett D'Amore const struct mdoc_meta *mdoc_meta(const struct mdoc *);
393*260e9a87SYuri Pankov void mdoc_deroff(char **, const struct mdoc_node *);
39495c635efSGarrett D'Amore 
39595c635efSGarrett D'Amore __END_DECLS
396