]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc.h
1 /* $Id: mdoc.h,v 1.96 2010/07/01 22:56:17 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * This library implements a validating scanner/parser for ``mdoc'' roff
22 * macro documents, a.k.a. BSD manual page documents. The mdoc.c file
23 * drives the parser, while macro.c describes the macro ontologies.
24 * validate.c pre- and post-validates parsed macros, and action.c
25 * performs actions on parsed and validated macros.
28 /* What follows is a list of ALL possible macros. */
156 /* What follows is a list of ALL possible macro arguments. */
158 /* FIXME: make this into an enum. */
160 #define MDOC_Nosplit 1
161 #define MDOC_Ragged 2
162 #define MDOC_Unfilled 3
163 #define MDOC_Literal 4
165 #define MDOC_Offset 6
166 #define MDOC_Bullet 7
168 #define MDOC_Hyphen 9
174 #define MDOC_Ohang 15
175 #define MDOC_Inset 16
176 #define MDOC_Column 17
177 #define MDOC_Width 18
178 #define MDOC_Compact 19
180 #define MDOC_Filled 21
181 #define MDOC_Words 22
182 #define MDOC_Emphasis 23
183 #define MDOC_Symbolic 24
184 #define MDOC_Nested 25
185 #define MDOC_Centred 26
186 #define MDOC_ARG_MAX 27
188 /* Type of a syntax node. */
199 /* Section (named/unnamed) of `Sh'. */
201 SEC_NONE
, /* No section, yet. */
222 SEC_CUSTOM
, /* User-defined. */
226 /* Information from prologue. */
237 /* An argument to a macro (multiple values = `It -column'). */
248 struct mdoc_argv
*argv
;
283 const char *offs
; /* -offset */
284 enum mdoc_disp type
; /* -ragged, etc. */
285 int comp
; /* -compact */
289 const char *width
; /* -width */
290 const char *offs
; /* -offset */
291 enum mdoc_list type
; /* -tag, -enum, etc. */
292 int comp
; /* -compact */
297 struct mdoc_node
*parent
; /* parent AST node */
298 struct mdoc_node
*child
; /* first child AST node */
299 struct mdoc_node
*next
; /* sibling AST node */
300 struct mdoc_node
*prev
; /* prior sibling AST node */
301 int nchild
; /* number children */
302 int line
; /* parse line */
303 int pos
; /* parse column */
304 enum mdoct tok
; /* tok or MDOC__MAX if none */
306 #define MDOC_VALID (1 << 0) /* has been validated */
307 #define MDOC_ACTED (1 << 1) /* has been acted upon */
308 #define MDOC_EOS (1 << 2) /* at sentence boundary */
309 #define MDOC_LINE (1 << 3) /* first macro/text on line */
310 #define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting */
311 #define MDOC_ENDED (1 << 5) /* rendering has been ended */
312 enum mdoc_type type
; /* AST node type */
313 enum mdoc_sec sec
; /* current named section */
314 /* FIXME: these can be union'd to shave a few bytes. */
315 struct mdoc_arg
*args
; /* BLOCK/ELEM */
316 struct mdoc_node
*pending
; /* BLOCK */
317 struct mdoc_node
*head
; /* BLOCK */
318 struct mdoc_node
*body
; /* BLOCK */
319 struct mdoc_node
*tail
; /* BLOCK */
320 char *string
; /* TEXT */
321 enum mdoc_endbody end
; /* BODY */
329 #define MDOC_IGN_SCOPE (1 << 0) /* Ignore scope violations. */
330 #define MDOC_IGN_ESCAPE (1 << 1) /* Ignore bad escape sequences. */
331 #define MDOC_IGN_MACRO (1 << 2) /* Ignore unknown macros. */
333 /* See mdoc.3 for documentation. */
335 extern const char *const *mdoc_macronames
;
336 extern const char *const *mdoc_argnames
;
342 /* See mdoc.3 for documentation. */
344 void mdoc_free(struct mdoc
*);
345 struct mdoc
*mdoc_alloc(struct regset
*, void *, int, mandocmsg
);
346 void mdoc_reset(struct mdoc
*);
347 int mdoc_parseln(struct mdoc
*, int, char *, int);
348 const struct mdoc_node
*mdoc_node(const struct mdoc
*);
349 const struct mdoc_meta
*mdoc_meta(const struct mdoc
*);
350 int mdoc_endparse(struct mdoc
*);