=================================================================== RCS file: /cvs/mandoc/mdoc.h,v retrieving revision 1.77 retrieving revision 1.82 diff -u -p -r1.77 -r1.82 --- mandoc/mdoc.h 2010/05/12 16:01:01 1.77 +++ mandoc/mdoc.h 2010/05/17 23:57:06 1.82 @@ -1,4 +1,4 @@ -/* $Id: mdoc.h,v 1.77 2010/05/12 16:01:01 kristaps Exp $ */ +/* $Id: mdoc.h,v 1.82 2010/05/17 23:57:06 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -223,7 +223,7 @@ enum mdoc_sec { /* Information from prologue. */ struct mdoc_meta { - int msec; + char *msec; char *vol; char *arch; time_t date; @@ -247,23 +247,38 @@ struct mdoc_arg { unsigned int refcnt; }; +enum mdoc_list { + LIST__NONE = 0, + LIST_bullet, + LIST_column, + LIST_dash, + LIST_diag, + LIST_enum, + LIST_hang, + LIST_hyphen, + LIST_inset, + LIST_item, + LIST_ohang, + LIST_tag +}; + /* Node in AST. */ struct mdoc_node { - struct mdoc_node *parent; - struct mdoc_node *child; - struct mdoc_node *next; - struct mdoc_node *prev; - int nchild; - int line; - int pos; - enum mdoct tok; + struct mdoc_node *parent; /* parent AST node */ + struct mdoc_node *child; /* first child AST node */ + struct mdoc_node *next; /* sibling AST node */ + struct mdoc_node *prev; /* prior sibling AST node */ + int nchild; /* number children */ + int line; /* parse line */ + int pos; /* parse column */ + enum mdoct tok; /* tok or MDOC__MAX if none */ int flags; -#define MDOC_VALID (1 << 0) -#define MDOC_ACTED (1 << 1) -#define MDOC_EOS (1 << 2) - enum mdoc_type type; - enum mdoc_sec sec; - +#define MDOC_VALID (1 << 0) /* has been validated */ +#define MDOC_ACTED (1 << 1) /* has been acted upon */ +#define MDOC_EOS (1 << 2) /* at sentence boundary */ +#define MDOC_LINE (1 << 3) /* first macro/text on line */ + enum mdoc_type type; /* AST node type */ + enum mdoc_sec sec; /* current named section */ struct mdoc_arg *args; /* BLOCK/ELEM */ #ifdef UGLY struct mdoc_node *pending; /* BLOCK */ @@ -272,19 +287,16 @@ struct mdoc_node { struct mdoc_node *body; /* BLOCK */ struct mdoc_node *tail; /* BLOCK */ char *string; /* TEXT */ + + union { + enum mdoc_list list; /* for `Bl' nodes */ + } data; }; #define MDOC_IGN_SCOPE (1 << 0) /* Ignore scope violations. */ #define MDOC_IGN_ESCAPE (1 << 1) /* Ignore bad escape sequences. */ #define MDOC_IGN_MACRO (1 << 2) /* Ignore unknown macros. */ -/* Call-backs for parse messages. */ - -struct mdoc_cb { - int (*mdoc_err)(void *, int, int, const char *); - int (*mdoc_warn)(void *, int, int, const char *); -}; - /* See mdoc.3 for documentation. */ extern const char *const *mdoc_macronames; @@ -297,9 +309,9 @@ struct mdoc; /* See mdoc.3 for documentation. */ void mdoc_free(struct mdoc *); -struct mdoc *mdoc_alloc(void *, int, const struct mdoc_cb *); +struct mdoc *mdoc_alloc(void *, int, mandocmsg); void mdoc_reset(struct mdoc *); -int mdoc_parseln(struct mdoc *, int, char *buf); +int mdoc_parseln(struct mdoc *, int, char *, int); const struct mdoc_node *mdoc_node(const struct mdoc *); const struct mdoc_meta *mdoc_meta(const struct mdoc *); int mdoc_endparse(struct mdoc *);