1 /* $Id: mdoc.h,v 1.122 2011/03/22 14:05:45 kristaps Exp $ */
2 /*
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 *
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.
8 *
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.
16 */
17 #ifndef MDOC_H
18 #define MDOC_H
19
20 enum mdoct {
21 MDOC_Ap = 0,
294 enum mdoc_font {
295 FONT__NONE = 0,
296 FONT_Em, /* Em, -emphasis */
297 FONT_Li, /* Li, -literal */
298 FONT_Sy /* Sy, -symbolic */
299 };
300
301 struct mdoc_bd {
302 const char *offs; /* -offset */
303 enum mdoc_disp type; /* -ragged, etc. */
304 int comp; /* -compact */
305 };
306
307 struct mdoc_bl {
308 const char *width; /* -width */
309 const char *offs; /* -offset */
310 enum mdoc_list type; /* -tag, -enum, etc. */
311 int comp; /* -compact */
312 size_t ncols; /* -column arg count */
313 const char **cols; /* -column val ptr */
314 };
315
316 struct mdoc_bf {
317 enum mdoc_font font; /* font */
318 };
319
320 struct mdoc_an {
321 enum mdoc_auth auth; /* -split, etc. */
322 };
323
324 struct mdoc_rs {
325 int quote_T; /* whether to quote %T */
326 };
327
328 /*
329 * Consists of normalised node arguments. These should be used instead
330 * of iterating through the mdoc_arg pointers of a node: defaults are
331 * provided, etc.
332 */
333 union mdoc_data {
334 struct mdoc_an An;
335 struct mdoc_bd Bd;
336 struct mdoc_bf Bf;
337 struct mdoc_bl Bl;
338 struct mdoc_rs Rs;
339 };
340
341 /*
342 * Single node in tree-linked AST.
343 */
344 struct mdoc_node {
345 struct mdoc_node *parent; /* parent AST node */
346 struct mdoc_node *child; /* first child AST node */
347 struct mdoc_node *last; /* last child AST node */
348 struct mdoc_node *next; /* sibling AST node */
349 struct mdoc_node *prev; /* prior sibling AST node */
350 int nchild; /* number children */
351 int line; /* parse line */
352 int pos; /* parse column */
353 enum mdoct tok; /* tok or MDOC__MAX if none */
354 int flags;
355 #define MDOC_VALID (1 << 0) /* has been validated */
356 #define MDOC_EOS (1 << 2) /* at sentence boundary */
357 #define MDOC_LINE (1 << 3) /* first macro/text on line */
358 #define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting */
359 #define MDOC_ENDED (1 << 5) /* rendering has been ended */
360 #define MDOC_DELIMO (1 << 6)
361 #define MDOC_DELIMC (1 << 7)
362 enum mdoc_type type; /* AST node type */
363 enum mdoc_sec sec; /* current named section */
364 union mdoc_data *norm; /* normalised args */
365 /* FIXME: these can be union'd to shave a few bytes. */
366 struct mdoc_arg *args; /* BLOCK/ELEM */
367 struct mdoc_node *pending; /* BLOCK */
368 struct mdoc_node *head; /* BLOCK */
369 struct mdoc_node *body; /* BLOCK */
370 struct mdoc_node *tail; /* BLOCK */
371 char *string; /* TEXT */
372 const struct tbl_span *span; /* TBL */
373 const struct eqn *eqn; /* EQN */
374 enum mdoc_endbody end; /* BODY */
375 };
376
377 /* Names of macros. Index is enum mdoct. */
378 extern const char *const *mdoc_macronames;
379
380 /* Names of macro args. Index is enum mdocargt. */
381 extern const char *const *mdoc_argnames;
382
383 __BEGIN_DECLS
384
|
1 /* $Id: mdoc.h,v 1.125 2013/12/24 19:11:45 schwarze Exp $ */
2 /*
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 *
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.
8 *
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.
16 */
17 #ifndef MDOC_H
18 #define MDOC_H
19
20 enum mdoct {
21 MDOC_Ap = 0,
294 enum mdoc_font {
295 FONT__NONE = 0,
296 FONT_Em, /* Em, -emphasis */
297 FONT_Li, /* Li, -literal */
298 FONT_Sy /* Sy, -symbolic */
299 };
300
301 struct mdoc_bd {
302 const char *offs; /* -offset */
303 enum mdoc_disp type; /* -ragged, etc. */
304 int comp; /* -compact */
305 };
306
307 struct mdoc_bl {
308 const char *width; /* -width */
309 const char *offs; /* -offset */
310 enum mdoc_list type; /* -tag, -enum, etc. */
311 int comp; /* -compact */
312 size_t ncols; /* -column arg count */
313 const char **cols; /* -column val ptr */
314 int count; /* -enum counter */
315 };
316
317 struct mdoc_bf {
318 enum mdoc_font font; /* font */
319 };
320
321 struct mdoc_an {
322 enum mdoc_auth auth; /* -split, etc. */
323 };
324
325 struct mdoc_rs {
326 int quote_T; /* whether to quote %T */
327 };
328
329 /*
330 * Consists of normalised node arguments. These should be used instead
331 * of iterating through the mdoc_arg pointers of a node: defaults are
332 * provided, etc.
333 */
334 union mdoc_data {
335 struct mdoc_an An;
336 struct mdoc_bd Bd;
337 struct mdoc_bf Bf;
338 struct mdoc_bl Bl;
339 struct mdoc_rs Rs;
340 };
341
342 /*
343 * Single node in tree-linked AST.
344 */
345 struct mdoc_node {
346 struct mdoc_node *parent; /* parent AST node */
347 struct mdoc_node *child; /* first child AST node */
348 struct mdoc_node *last; /* last child AST node */
349 struct mdoc_node *next; /* sibling AST node */
350 struct mdoc_node *prev; /* prior sibling AST node */
351 int nchild; /* number children */
352 int line; /* parse line */
353 int pos; /* parse column */
354 int lastline; /* the node ends on this line */
355 enum mdoct tok; /* tok or MDOC__MAX if none */
356 int flags;
357 #define MDOC_VALID (1 << 0) /* has been validated */
358 #define MDOC_EOS (1 << 2) /* at sentence boundary */
359 #define MDOC_LINE (1 << 3) /* first macro/text on line */
360 #define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting */
361 #define MDOC_ENDED (1 << 5) /* rendering has been ended */
362 #define MDOC_DELIMO (1 << 6)
363 #define MDOC_DELIMC (1 << 7)
364 enum mdoc_type type; /* AST node type */
365 enum mdoc_sec sec; /* current named section */
366 union mdoc_data *norm; /* normalised args */
367 const void *prev_font; /* before entering this node */
368 /* FIXME: these can be union'd to shave a few bytes. */
369 struct mdoc_arg *args; /* BLOCK/ELEM */
370 struct mdoc_node *pending; /* BLOCK */
371 struct mdoc_node *head; /* BLOCK */
372 struct mdoc_node *body; /* BLOCK */
373 struct mdoc_node *tail; /* BLOCK */
374 char *string; /* TEXT */
375 const struct tbl_span *span; /* TBL */
376 const struct eqn *eqn; /* EQN */
377 enum mdoc_endbody end; /* BODY */
378 };
379
380 /* Names of macros. Index is enum mdoct. */
381 extern const char *const *mdoc_macronames;
382
383 /* Names of macro args. Index is enum mdocargt. */
384 extern const char *const *mdoc_argnames;
385
386 __BEGIN_DECLS
387
|