[BACK]Return to roff.h CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/roff.h, Revision 1.31

1.28      schwarze    1: /*     $OpenBSD$       */
1.1       kristaps    2: /*
1.28      schwarze    3:  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.31    ! schwarze    4:  * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
1.1       kristaps    5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
1.12      kristaps    7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
1.1       kristaps    9:  *
1.28      schwarze   10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.12      kristaps   11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.28      schwarze   12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.12      kristaps   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.
1.1       kristaps   17:  */
                     18:
1.29      schwarze   19: struct mdoc_arg;
                     20: union  mdoc_data;
                     21:
                     22: enum   roff_sec {
                     23:        SEC_NONE = 0,
                     24:        SEC_NAME,
                     25:        SEC_LIBRARY,
                     26:        SEC_SYNOPSIS,
                     27:        SEC_DESCRIPTION,
                     28:        SEC_CONTEXT,
                     29:        SEC_IMPLEMENTATION,     /* IMPLEMENTATION NOTES */
                     30:        SEC_RETURN_VALUES,
                     31:        SEC_ENVIRONMENT,
                     32:        SEC_FILES,
                     33:        SEC_EXIT_STATUS,
                     34:        SEC_EXAMPLES,
                     35:        SEC_DIAGNOSTICS,
                     36:        SEC_COMPATIBILITY,
                     37:        SEC_ERRORS,
                     38:        SEC_SEE_ALSO,
                     39:        SEC_STANDARDS,
                     40:        SEC_HISTORY,
                     41:        SEC_AUTHORS,
                     42:        SEC_CAVEATS,
                     43:        SEC_BUGS,
                     44:        SEC_SECURITY,
                     45:        SEC_CUSTOM,
                     46:        SEC__MAX
                     47: };
                     48:
1.28      schwarze   49: enum   roff_type {
                     50:        ROFFT_ROOT,
                     51:        ROFFT_BLOCK,
                     52:        ROFFT_HEAD,
                     53:        ROFFT_BODY,
                     54:        ROFFT_TAIL,
                     55:        ROFFT_ELEM,
                     56:        ROFFT_TEXT,
                     57:        ROFFT_TBL,
                     58:        ROFFT_EQN
1.29      schwarze   59: };
                     60:
1.31    ! schwarze   61: enum   roff_next {
        !            62:        ROFF_NEXT_SIBLING = 0,
        !            63:        ROFF_NEXT_CHILD
        !            64: };
        !            65:
1.29      schwarze   66: /*
                     67:  * Indicates that a BODY's formatting has ended, but
                     68:  * the scope is still open.  Used for badly nested blocks.
                     69:  */
                     70: enum   mdoc_endbody {
                     71:        ENDBODY_NOT = 0,
                     72:        ENDBODY_SPACE,  /* Is broken: append a space. */
                     73:        ENDBODY_NOSPACE /* Is broken: don't append a space. */
                     74: };
                     75:
                     76: struct roff_node {
                     77:        struct roff_node *parent;  /* Parent AST node. */
                     78:        struct roff_node *child;   /* First child AST node. */
                     79:        struct roff_node *last;    /* Last child AST node. */
                     80:        struct roff_node *next;    /* Sibling AST node. */
                     81:        struct roff_node *prev;    /* Prior sibling AST node. */
                     82:        struct roff_node *head;    /* BLOCK */
                     83:        struct roff_node *body;    /* BLOCK/ENDBODY */
                     84:        struct roff_node *tail;    /* BLOCK */
                     85:        struct mdoc_arg  *args;    /* BLOCK/ELEM */
                     86:        union mdoc_data  *norm;    /* Normalized arguments. */
                     87:        char             *string;  /* TEXT */
                     88:        const struct tbl_span *span; /* TBL */
                     89:        const struct eqn *eqn;     /* EQN */
                     90:        int               nchild;  /* Number of child nodes. */
                     91:        int               line;    /* Input file line number. */
                     92:        int               pos;     /* Input file column number. */
                     93:        int               tok;     /* Request or macro ID. */
                     94:        int               flags;
                     95: #define        MDOC_VALID       (1 << 0)  /* Has been validated. */
                     96: #define        MDOC_ENDED       (1 << 1)  /* Gone past body end mark. */
                     97: #define MDOC_EOS        (1 << 2)  /* At sentence boundary. */
                     98: #define        MDOC_LINE        (1 << 3)  /* First macro/text on line. */
                     99: #define MDOC_SYNPRETTY  (1 << 4)  /* SYNOPSIS-style formatting. */
                    100: #define MDOC_BROKEN     (1 << 5)  /* Must validate parent when ending. */
                    101: #define        MDOC_DELIMO      (1 << 6)
                    102: #define        MDOC_DELIMC      (1 << 7)
                    103: #define        MAN_VALID         MDOC_VALID
                    104: #define        MAN_EOS           MDOC_EOS
                    105: #define        MAN_LINE          MDOC_LINE
                    106:        int               prev_font; /* Before entering this node. */
                    107:        int               aux;     /* Decoded node data, type-dependent. */
                    108:        enum roff_type    type;    /* AST node type. */
                    109:        enum roff_sec     sec;     /* Current named section. */
                    110:        enum mdoc_endbody end;     /* BODY */
1.28      schwarze  111: };
1.30      schwarze  112:
                    113: struct roff_meta {
                    114:        char             *msec;    /* Manual section, usually a digit. */
                    115:        char             *vol;     /* Manual volume title. */
                    116:        char             *os;      /* Operating system. */
                    117:        char             *arch;    /* Machine architecture. */
                    118:        char             *title;   /* Manual title, usually CAPS. */
                    119:        char             *name;    /* Leading manual name. */
                    120:        char             *date;    /* Normalized date. */
                    121:        int               hasbody; /* Document is not empty. */
1.31    ! schwarze  122: };
        !           123:
        !           124: struct roff_man {
        !           125:        struct roff_meta  meta;    /* Document meta-data. */
        !           126:        struct mparse    *parse;   /* Parse pointer. */
        !           127:        struct roff      *roff;    /* Roff parser state data. */
        !           128:        const char       *defos;   /* Default operating system. */
        !           129:        struct roff_node *first;   /* The first node parsed. */
        !           130:        struct roff_node *last;    /* The last node parsed. */
        !           131:        struct roff_node *last_es; /* The most recent Es node. */
        !           132:        int               quick;   /* Abort parse early. */
        !           133:        int               flags;   /* Parse flags. */
        !           134: #define        MDOC_LITERAL     (1 << 1)  /* In a literal scope. */
        !           135: #define        MDOC_PBODY       (1 << 2)  /* In the document body. */
        !           136: #define        MDOC_NEWLINE     (1 << 3)  /* First macro/text in a line. */
        !           137: #define        MDOC_PHRASELIT   (1 << 4)  /* Literal within a partial phrase. */
        !           138: #define        MDOC_PPHRASE     (1 << 5)  /* Within a partial phrase. */
        !           139: #define        MDOC_FREECOL     (1 << 6)  /* `It' invocation should close. */
        !           140: #define        MDOC_SYNOPSIS    (1 << 7)  /* SYNOPSIS-style formatting. */
        !           141: #define        MDOC_KEEP        (1 << 8)  /* In a word keep. */
        !           142: #define        MDOC_SMOFF       (1 << 9)  /* Spacing is off. */
        !           143: #define        MDOC_NODELIMC    (1 << 10) /* Disable closing delimiter handling. */
        !           144: #define        MAN_ELINE        (1 << 11) /* Next-line element scope. */
        !           145: #define        MAN_BLINE        (1 << 12) /* Next-line block scope. */
        !           146: #define        MAN_LITERAL       MDOC_LITERAL
        !           147: #define        MAN_NEWLINE       MDOC_NEWLINE
        !           148:        enum roff_sec     lastsec; /* Last section seen. */
        !           149:        enum roff_sec     lastnamed; /* Last standard section seen. */
        !           150:        enum roff_next    next;    /* Where to put the next node. */
1.30      schwarze  151: };

CVSweb