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

Annotation of mandoc/libmdoc.h, Revision 1.99

1.99    ! schwarze    1: /*     $Id: libmdoc.h,v 1.98 2015/04/02 22:48:17 schwarze Exp $ */
1.1       kristaps    2: /*
1.77      schwarze    3:  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.98      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.6       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.98      schwarze   10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.6       kristaps   11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.98      schwarze   12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.6       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:
                     19: enum   mdoc_next {
                     20:        MDOC_NEXT_SIBLING = 0,
                     21:        MDOC_NEXT_CHILD
                     22: };
                     23:
                     24: struct mdoc {
1.69      kristaps   25:        struct mparse    *parse; /* parse pointer */
1.86      schwarze   26:        const char       *defos; /* default argument for .Os */
1.83      schwarze   27:        int               quick; /* abort parse early */
1.69      kristaps   28:        int               flags; /* parse flags */
1.42      kristaps   29: #define        MDOC_LITERAL     (1 << 1) /* in a literal scope */
                     30: #define        MDOC_PBODY       (1 << 2) /* in the document body */
                     31: #define        MDOC_NEWLINE     (1 << 3) /* first macro/text in a line */
1.45      kristaps   32: #define        MDOC_PHRASELIT   (1 << 4) /* literal within a partila phrase */
                     33: #define        MDOC_PPHRASE     (1 << 5) /* within a partial phrase */
1.51      kristaps   34: #define        MDOC_FREECOL     (1 << 6) /* `It' invocation should close */
1.59      schwarze   35: #define        MDOC_SYNOPSIS    (1 << 7) /* SYNOPSIS-style formatting */
1.82      schwarze   36: #define        MDOC_KEEP        (1 << 8) /* in a word keep */
                     37: #define        MDOC_SMOFF       (1 << 9) /* spacing is off */
1.89      schwarze   38: #define        MDOC_NODELIMC    (1 << 10) /* disable closing delimiter handling */
1.56      kristaps   39:        enum mdoc_next    next; /* where to put the next node */
1.98      schwarze   40:        struct roff_node *last; /* the last node parsed */
                     41:        struct roff_node *first; /* the first node parsed */
                     42:        struct roff_node *last_es; /* the most recent Es node */
1.99    ! schwarze   43:        struct roff_meta  meta; /* document meta-data */
1.98      schwarze   44:        enum roff_sec     lastnamed;
                     45:        enum roff_sec     lastsec;
1.75      kristaps   46:        struct roff      *roff;
1.13      kristaps   47: };
1.1       kristaps   48:
1.81      schwarze   49: #define        MACRO_PROT_ARGS struct mdoc *mdoc, \
1.98      schwarze   50:                        int tok, \
1.55      kristaps   51:                        int line, \
                     52:                        int ppos, \
                     53:                        int *pos, \
                     54:                        char *buf
1.1       kristaps   55:
                     56: struct mdoc_macro {
1.92      schwarze   57:        void            (*fp)(MACRO_PROT_ARGS);
1.1       kristaps   58:        int               flags;
                     59: #define        MDOC_CALLABLE    (1 << 0)
                     60: #define        MDOC_PARSED      (1 << 1)
                     61: #define        MDOC_EXPLICIT    (1 << 2)
                     62: #define        MDOC_PROLOGUE    (1 << 3)
1.82      schwarze   63: #define        MDOC_IGNDELIM    (1 << 4)
                     64: #define        MDOC_JOIN        (1 << 5)
1.1       kristaps   65: };
                     66:
1.36      kristaps   67: enum   margserr {
1.35      kristaps   68:        ARGS_ERROR,
1.73      kristaps   69:        ARGS_EOLN, /* end-of-line */
                     70:        ARGS_WORD, /* normal word */
                     71:        ARGS_PUNCT, /* series of punctuation */
                     72:        ARGS_QWORD, /* quoted word */
                     73:        ARGS_PHRASE, /* Ta'd phrase (-column) */
                     74:        ARGS_PPHRASE, /* tabbed phrase (-column) */
                     75:        ARGS_PEND /* last phrase (-column) */
1.35      kristaps   76: };
                     77:
1.70      kristaps   78: /*
                     79:  * A punctuation delimiter is opening, closing, or "middle mark"
                     80:  * punctuation.  These govern spacing.
                     81:  * Opening punctuation (e.g., the opening parenthesis) suppresses the
                     82:  * following space; closing punctuation (e.g., the closing parenthesis)
                     83:  * suppresses the leading space; middle punctuation (e.g., the vertical
                     84:  * bar) can do either.  The middle punctuation delimiter bends the rules
                     85:  * depending on usage.
                     86:  */
                     87: enum   mdelim {
                     88:        DELIM_NONE = 0,
                     89:        DELIM_OPEN,
                     90:        DELIM_MIDDLE,
                     91:        DELIM_CLOSE,
                     92:        DELIM_MAX
                     93: };
                     94:
1.1       kristaps   95: extern const struct mdoc_macro *const mdoc_macros;
                     96:
                     97: __BEGIN_DECLS
                     98:
1.92      schwarze   99: void             mdoc_macro(MACRO_PROT_ARGS);
1.91      schwarze  100: void             mdoc_word_alloc(struct mdoc *, int, int, const char *);
1.82      schwarze  101: void             mdoc_word_append(struct mdoc *, const char *);
1.91      schwarze  102: void             mdoc_elem_alloc(struct mdoc *, int, int,
1.98      schwarze  103:                        int, struct mdoc_arg *);
                    104: struct roff_node *mdoc_block_alloc(struct mdoc *, int, int,
                    105:                        int, struct mdoc_arg *);
                    106: struct roff_node *mdoc_head_alloc(struct mdoc *, int, int, int);
                    107: void             mdoc_tail_alloc(struct mdoc *, int, int, int);
                    108: struct roff_node *mdoc_body_alloc(struct mdoc *, int, int, int);
                    109: struct roff_node *mdoc_endbody_alloc(struct mdoc *, int, int, int,
                    110:                        struct roff_node *, enum mdoc_endbody);
                    111: void             mdoc_node_delete(struct mdoc *, struct roff_node *);
                    112: void             mdoc_node_relink(struct mdoc *, struct roff_node *);
1.27      kristaps  113: void             mdoc_hash_init(void);
1.98      schwarze  114: int              mdoc_hash_find(const char *);
1.16      kristaps  115: const char      *mdoc_a2att(const char *);
1.18      kristaps  116: const char      *mdoc_a2lib(const char *);
1.17      kristaps  117: const char      *mdoc_a2st(const char *);
1.1       kristaps  118: const char      *mdoc_a2arch(const char *);
1.98      schwarze  119: void             mdoc_valid_pre(struct mdoc *, struct roff_node *);
1.90      schwarze  120: void             mdoc_valid_post(struct mdoc *);
1.98      schwarze  121: void             mdoc_argv(struct mdoc *, int, int,
1.1       kristaps  122:                        struct mdoc_arg **, int *, char *);
                    123: void             mdoc_argv_free(struct mdoc_arg *);
1.36      kristaps  124: enum margserr    mdoc_args(struct mdoc *, int,
1.98      schwarze  125:                        int *, char *, int, char **);
1.92      schwarze  126: void             mdoc_macroend(struct mdoc *);
1.70      kristaps  127: enum mdelim      mdoc_isdelim(const char *);
1.1       kristaps  128:
                    129: __END_DECLS

CVSweb