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

Annotation of mandoc/roff_int.h, Revision 1.12

1.12    ! schwarze    1: /*     $Id: roff_int.h,v 1.11 2018/12/13 06:18:20 schwarze Exp $       */
1.1       schwarze    2: /*
                      3:  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.11      schwarze    4:  * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
1.1       schwarze    5:  *
                      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.
                      9:  *
                     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.
1.11      schwarze   17:  *
                     18:  * Parser internals shared by multiple parsers.
1.1       schwarze   19:  */
                     20:
1.12    ! schwarze   21: struct ohash;
        !            22: struct roff_node;
        !            23: struct roff_meta;
        !            24: struct roff;
        !            25: struct mdoc_arg;
        !            26:
        !            27: enum   roff_next {
        !            28:        ROFF_NEXT_SIBLING = 0,
        !            29:        ROFF_NEXT_CHILD
        !            30: };
        !            31:
        !            32: struct roff_man {
        !            33:        struct roff_meta  meta;    /* Public parse results. */
        !            34:        struct roff      *roff;    /* Roff parser state data. */
        !            35:        struct ohash     *mdocmac; /* Mdoc macro lookup table. */
        !            36:        struct ohash     *manmac;  /* Man macro lookup table. */
        !            37:        const char       *os_s;    /* Default operating system. */
        !            38:        struct roff_node *last;    /* The last node parsed. */
        !            39:        struct roff_node *last_es; /* The most recent Es node. */
        !            40:        int               quick;   /* Abort parse early. */
        !            41:        int               flags;   /* Parse flags. */
        !            42: #define        MDOC_LITERAL     (1 << 1)  /* In a literal scope. */
        !            43: #define        MDOC_PBODY       (1 << 2)  /* In the document body. */
        !            44: #define        MDOC_NEWLINE     (1 << 3)  /* First macro/text in a line. */
        !            45: #define        MDOC_PHRASE      (1 << 4)  /* In a Bl -column phrase. */
        !            46: #define        MDOC_PHRASELIT   (1 << 5)  /* Literal within a phrase. */
        !            47: #define        MDOC_FREECOL     (1 << 6)  /* `It' invocation should close. */
        !            48: #define        MDOC_SYNOPSIS    (1 << 7)  /* SYNOPSIS-style formatting. */
        !            49: #define        MDOC_KEEP        (1 << 8)  /* In a word keep. */
        !            50: #define        MDOC_SMOFF       (1 << 9)  /* Spacing is off. */
        !            51: #define        MDOC_NODELIMC    (1 << 10) /* Disable closing delimiter handling. */
        !            52: #define        MAN_ELINE        (1 << 11) /* Next-line element scope. */
        !            53: #define        MAN_BLINE        (1 << 12) /* Next-line block scope. */
        !            54: #define        MDOC_PHRASEQF    (1 << 13) /* Quote first word encountered. */
        !            55: #define        MDOC_PHRASEQL    (1 << 14) /* Quote last word of this phrase. */
        !            56: #define        MDOC_PHRASEQN    (1 << 15) /* Quote first word of the next phrase. */
        !            57: #define        MAN_LITERAL       MDOC_LITERAL
        !            58: #define        MAN_NEWLINE       MDOC_NEWLINE
        !            59:        enum roff_sec     lastsec; /* Last section seen. */
        !            60:        enum roff_sec     lastnamed; /* Last standard section seen. */
        !            61:        enum roff_next    next;    /* Where to put the next node. */
        !            62: };
        !            63:
        !            64:
1.1       schwarze   65: struct roff_node *roff_node_alloc(struct roff_man *, int, int,
                     66:                        enum roff_type, int);
                     67: void             roff_node_append(struct roff_man *, struct roff_node *);
1.2       schwarze   68: void             roff_word_alloc(struct roff_man *, int, int, const char *);
                     69: void             roff_word_append(struct roff_man *, const char *);
1.3       schwarze   70: void             roff_elem_alloc(struct roff_man *, int, int, int);
                     71: struct roff_node *roff_block_alloc(struct roff_man *, int, int, int);
1.1       schwarze   72: struct roff_node *roff_head_alloc(struct roff_man *, int, int, int);
                     73: struct roff_node *roff_body_alloc(struct roff_man *, int, int, int);
                     74: void             roff_node_unlink(struct roff_man *, struct roff_node *);
1.10      schwarze   75: void             roff_node_relink(struct roff_man *, struct roff_node *);
1.1       schwarze   76: void             roff_node_free(struct roff_node *);
                     77: void             roff_node_delete(struct roff_man *, struct roff_node *);
1.11      schwarze   78:
                     79: struct ohash    *roffhash_alloc(enum roff_tok, enum roff_tok);
                     80: enum roff_tok    roffhash_find(struct ohash *, const char *, size_t);
                     81: void             roffhash_free(struct ohash *);
1.12    ! schwarze   82:
        !            83: void             roff_validate(struct roff_man *);
1.2       schwarze   84:
                     85: /*
                     86:  * Functions called from roff.c need to be declared here,
                     87:  * not in libmdoc.h or libman.h, even if they are specific
                     88:  * to either the mdoc(7) or the man(7) parser.
                     89:  */
                     90:
                     91: void             man_breakscope(struct roff_man *, int);
                     92: void             mdoc_argv_free(struct mdoc_arg *);

CVSweb