1 /* $Id: roff.h,v 1.52 2017/06/07 23:29:49 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
42 SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
162 /* MAN_fi; ignored in mdoc(7) */
192 /* MAN_in; ignored in mdoc(7) */
222 /* MAN_nf; ignored in mdoc(7) */
480 ROFF_NEXT_SIBLING = 0,
485 * Indicates that a BODY's formatting has ended, but
486 * the scope is still open. Used for badly nested blocks.
490 ENDBODY_SPACE /* Is broken: append a space. */
494 struct roff_node *parent; /* Parent AST node. */
495 struct roff_node *child; /* First child AST node. */
496 struct roff_node *last; /* Last child AST node. */
497 struct roff_node *next; /* Sibling AST node. */
498 struct roff_node *prev; /* Prior sibling AST node. */
499 struct roff_node *head; /* BLOCK */
500 struct roff_node *body; /* BLOCK/ENDBODY */
501 struct roff_node *tail; /* BLOCK */
502 struct mdoc_arg *args; /* BLOCK/ELEM */
503 union mdoc_data *norm; /* Normalized arguments. */
504 char *string; /* TEXT */
505 const struct tbl_span *span; /* TBL */
506 const struct eqn *eqn; /* EQN */
507 int line; /* Input file line number. */
508 int pos; /* Input file column number. */
510 #define NODE_VALID (1 << 0) /* Has been validated. */
511 #define NODE_ENDED (1 << 1) /* Gone past body end mark. */
512 #define NODE_EOS (1 << 2) /* At sentence boundary. */
513 #define NODE_LINE (1 << 3) /* First macro/text on line. */
514 #define NODE_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting. */
515 #define NODE_BROKEN (1 << 5) /* Must validate parent when ending. */
516 #define NODE_DELIMO (1 << 6)
517 #define NODE_DELIMC (1 << 7)
518 #define NODE_NOSRC (1 << 8) /* Generated node, not in input file. */
519 #define NODE_NOPRT (1 << 9) /* Shall not print anything. */
520 int prev_font; /* Before entering this node. */
521 int aux; /* Decoded node data, type-dependent. */
522 enum roff_tok tok; /* Request or macro ID. */
523 enum roff_type type; /* AST node type. */
524 enum roff_sec sec; /* Current named section. */
525 enum mdoc_endbody end; /* BODY */
529 char *msec; /* Manual section, usually a digit. */
530 char *vol; /* Manual volume title. */
531 char *os; /* Operating system. */
532 char *arch; /* Machine architecture. */
533 char *title; /* Manual title, usually CAPS. */
534 char *name; /* Leading manual name. */
535 char *date; /* Normalized date. */
536 int hasbody; /* Document is not empty. */
537 enum mdoc_os os_e; /* Operating system. */
541 struct roff_meta meta; /* Document meta-data. */
542 struct mparse *parse; /* Parse pointer. */
543 struct roff *roff; /* Roff parser state data. */
544 struct ohash *mdocmac; /* Mdoc macro lookup table. */
545 struct ohash *manmac; /* Man macro lookup table. */
546 const char *defos; /* Default operating system. */
547 struct roff_node *first; /* The first node parsed. */
548 struct roff_node *last; /* The last node parsed. */
549 struct roff_node *last_es; /* The most recent Es node. */
550 int quick; /* Abort parse early. */
551 int flags; /* Parse flags. */
552 #define MDOC_LITERAL (1 << 1) /* In a literal scope. */
553 #define MDOC_PBODY (1 << 2) /* In the document body. */
554 #define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
555 #define MDOC_PHRASE (1 << 4) /* In a Bl -column phrase. */
556 #define MDOC_PHRASELIT (1 << 5) /* Literal within a phrase. */
557 #define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
558 #define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
559 #define MDOC_KEEP (1 << 8) /* In a word keep. */
560 #define MDOC_SMOFF (1 << 9) /* Spacing is off. */
561 #define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
562 #define MAN_ELINE (1 << 11) /* Next-line element scope. */
563 #define MAN_BLINE (1 << 12) /* Next-line block scope. */
564 #define MDOC_PHRASEQF (1 << 13) /* Quote first word encountered. */
565 #define MDOC_PHRASEQL (1 << 14) /* Quote last word of this phrase. */
566 #define MDOC_PHRASEQN (1 << 15) /* Quote first word of the next phrase. */
567 #define MAN_LITERAL MDOC_LITERAL
568 #define MAN_NEWLINE MDOC_NEWLINE
569 enum roff_macroset macroset; /* Kind of high-level macros used. */
570 enum roff_sec lastsec; /* Last section seen. */
571 enum roff_sec lastnamed; /* Last standard section seen. */
572 enum roff_next next; /* Where to put the next node. */
575 extern const char *const *roff_name;
578 void deroff(char **, const struct roff_node *);
579 struct ohash *roffhash_alloc(enum roff_tok, enum roff_tok);
580 enum roff_tok roffhash_find(struct ohash *, const char *, size_t);
581 void roffhash_free(struct ohash *);
582 void roff_validate(struct roff_man *);