=================================================================== RCS file: /cvs/mandoc/mdoc.h,v retrieving revision 1.37 retrieving revision 1.53 diff -u -p -r1.37 -r1.53 --- mandoc/mdoc.h 2009/03/06 14:13:47 1.37 +++ mandoc/mdoc.h 2009/03/23 14:22:11 1.53 @@ -1,6 +1,6 @@ -/* $Id: mdoc.h,v 1.37 2009/03/06 14:13:47 kristaps Exp $ */ +/* $Id: mdoc.h,v 1.53 2009/03/23 14:22:11 kristaps Exp $ */ /* - * Copyright (c) 2008 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the @@ -19,6 +19,8 @@ #ifndef MDOC_H #define MDOC_H +#include + /* * This library implements a validating scanner/parser for ``mdoc'' roff * macro documents, a.k.a. BSD manual page documents. The mdoc.c file @@ -136,7 +138,19 @@ #define MDOC_Fr 104 #define MDOC_Ud 105 #define MDOC_Lb 106 -#define MDOC_MAX 107 +#define MDOC_Ap 107 +#define MDOC_Lp 108 +#define MDOC_Lk 109 +#define MDOC_Mt 110 +#define MDOC_Brq 111 +#define MDOC_Bro 112 +#define MDOC_Brc 113 +#define MDOC__C 114 +#define MDOC_Es 115 +#define MDOC_En 116 +#define MDOC_Dx 117 +#define MDOC__Q 118 +#define MDOC_MAX 119 /* What follows is a list of ALL possible macro arguments. */ @@ -165,7 +179,8 @@ #define MDOC_Words 22 #define MDOC_Emphasis 23 #define MDOC_Symbolic 24 -#define MDOC_ARG_MAX 25 +#define MDOC_Nested 25 +#define MDOC_ARG_MAX 26 /* Warnings are either syntax or groff-compatibility. */ enum mdoc_warn { @@ -173,15 +188,6 @@ enum mdoc_warn { WARN_COMPAT }; -/* An argument to a macro (multiple values = `It -column'). */ -struct mdoc_arg { - int arg; - int line; - int pos; - size_t sz; - char **value; -}; - /* Type of a syntax node. */ enum mdoc_type { MDOC_TEXT, @@ -229,33 +235,21 @@ struct mdoc_meta { char *name; }; -/* Text-only node. */ -struct mdoc_text { - char *string; +/* An argument to a macro (multiple values = `It -column'). */ +struct mdoc_argv { + int arg; + int line; + int pos; + size_t sz; + char **value; }; -/* Block (scoped) node. */ -struct mdoc_block { +struct mdoc_arg { size_t argc; - struct mdoc_arg *argv; - struct mdoc_node *head; - struct mdoc_node *body; - struct mdoc_node *tail; + struct mdoc_argv *argv; + unsigned int refcnt; }; -/* In-line element node. */ -struct mdoc_elem { - size_t argc; - struct mdoc_arg *argv; -}; - -/* Typed nodes of an AST node. */ -union mdoc_data { - struct mdoc_text text; - struct mdoc_elem elem; - struct mdoc_block block; -}; - /* Node in AST. */ struct mdoc_node { struct mdoc_node *parent; @@ -269,10 +263,20 @@ struct mdoc_node { #define MDOC_VALID (1 << 0) #define MDOC_ACTED (1 << 1) enum mdoc_type type; - union mdoc_data data; enum mdoc_sec sec; + + /* FIXME: union/struct this with #defines. */ + struct mdoc_arg *args; /* BLOCK/ELEM */ + struct mdoc_node *head; /* BLOCK */ + struct mdoc_node *body; /* BLOCK */ + struct mdoc_node *tail; /* BLOCK */ + char *string; /* TEXT */ }; +#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 { void (*mdoc_msg)(void *, int, int, const char *); @@ -295,8 +299,11 @@ struct mdoc; void mdoc_free(struct mdoc *); /* Allocate a new parser instance. */ -struct mdoc *mdoc_alloc(void *data, const struct mdoc_cb *); +struct mdoc *mdoc_alloc(void *, int, const struct mdoc_cb *); +/* Gets system ready for another parse. */ +void mdoc_reset(struct mdoc *); + /* Parse a single line in a stream (boolean retval). */ int mdoc_parseln(struct mdoc *, int, char *buf); @@ -314,8 +321,6 @@ int mdoc_endparse(struct mdoc *); const char *mdoc_a2att(const char *); const char *mdoc_a2lib(const char *); const char *mdoc_a2st(const char *); - -int mdoc_isdelim(const char *); __END_DECLS