]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc.h
7c06697315442d8821d76cc090d77d929532ad46
1 /* $Id: mdoc.h,v 1.37 2009/03/06 14:13:47 kristaps Exp $ */
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
23 * This library implements a validating scanner/parser for ``mdoc'' roff
24 * macro documents, a.k.a. BSD manual page documents. The mdoc.c file
25 * drives the parser, while macro.c describes the macro ontologies.
26 * validate.c pre- and post-validates parsed macros, and action.c
27 * performs actions on parsed and validated macros.
30 /* What follows is a list of ALL possible macros. */
141 /* What follows is a list of ALL possible macro arguments. */
144 #define MDOC_Nosplit 1
145 #define MDOC_Ragged 2
146 #define MDOC_Unfilled 3
147 #define MDOC_Literal 4
149 #define MDOC_Offset 6
150 #define MDOC_Bullet 7
152 #define MDOC_Hyphen 9
158 #define MDOC_Ohang 15
159 #define MDOC_Inset 16
160 #define MDOC_Column 17
161 #define MDOC_Width 18
162 #define MDOC_Compact 19
164 #define MDOC_Filled 21
165 #define MDOC_Words 22
166 #define MDOC_Emphasis 23
167 #define MDOC_Symbolic 24
168 #define MDOC_ARG_MAX 25
170 /* Warnings are either syntax or groff-compatibility. */
176 /* An argument to a macro (multiple values = `It -column'). */
185 /* Type of a syntax node. */
196 /* Section (named/unnamed) of `Sh'. */
204 SEC_IMPLEMENTATION
= 6,
205 SEC_RETURN_VALUES
= 7,
209 SEC_DIAGNOSTICS
= 11,
210 SEC_COMPATIBILITY
= 12,
221 /* Information from prologue. */
232 /* Text-only node. */
237 /* Block (scoped) node. */
240 struct mdoc_arg
*argv
;
241 struct mdoc_node
*head
;
242 struct mdoc_node
*body
;
243 struct mdoc_node
*tail
;
246 /* In-line element node. */
249 struct mdoc_arg
*argv
;
252 /* Typed nodes of an AST node. */
254 struct mdoc_text text
;
255 struct mdoc_elem elem
;
256 struct mdoc_block block
;
261 struct mdoc_node
*parent
;
262 struct mdoc_node
*child
;
263 struct mdoc_node
*next
;
264 struct mdoc_node
*prev
;
269 #define MDOC_VALID (1 << 0)
270 #define MDOC_ACTED (1 << 1)
272 union mdoc_data data
;
276 /* Call-backs for parse messages. */
278 void (*mdoc_msg
)(void *, int, int, const char *);
279 int (*mdoc_err
)(void *, int, int, const char *);
280 int (*mdoc_warn
)(void *, int, int,
281 enum mdoc_warn
, const char *);
284 /* Global table of macro names (`Bd', `Ed', etc.). */
285 extern const char *const *mdoc_macronames
;
287 /* Global table of argument names (`column', `tag', etc.). */
288 extern const char *const *mdoc_argnames
;
294 /* Free memory allocated with mdoc_alloc. */
295 void mdoc_free(struct mdoc
*);
297 /* Allocate a new parser instance. */
298 struct mdoc
*mdoc_alloc(void *data
, const struct mdoc_cb
*);
300 /* Parse a single line in a stream (boolean retval). */
301 int mdoc_parseln(struct mdoc
*, int, char *buf
);
303 /* Get result first node (after mdoc_endparse!). */
304 const struct mdoc_node
*mdoc_node(const struct mdoc
*);
306 /* Get result meta-information (after mdoc_endparse!). */
307 const struct mdoc_meta
*mdoc_meta(const struct mdoc
*);
309 /* Signal end of parse sequence (boolean retval). */
310 int mdoc_endparse(struct mdoc
*);
312 /* The following are utility functions. */
314 const char *mdoc_a2att(const char *);
315 const char *mdoc_a2lib(const char *);
316 const char *mdoc_a2st(const char *);
318 int mdoc_isdelim(const char *);