version 1.22, 2009/01/15 17:38:57 |
version 1.26, 2009/01/19 17:02:58 |
|
|
#ifndef MDOC_H |
#ifndef MDOC_H |
#define MDOC_H |
#define MDOC_H |
|
|
/* FIXME: move this elsewhere (it's 9, too). */ |
|
|
|
#define MDOC_LINEARG_MAX 12 |
|
|
|
/* What follows is a list of ALL possible macros. */ |
/* What follows is a list of ALL possible macros. */ |
|
|
#define MDOC___ 0 |
#define MDOC___ 0 |
Line 204 enum mdoc_warn { |
|
Line 200 enum mdoc_warn { |
|
WARN_COMPAT /* Groff compat warn (at line/col). */ |
WARN_COMPAT /* Groff compat warn (at line/col). */ |
}; |
}; |
|
|
|
/* Possible values for the `At' macro. */ |
enum mdoc_att { |
enum mdoc_att { |
ATT_DEFAULT = 0, |
ATT_DEFAULT = 0, |
ATT_v1, |
ATT_v1, |
|
|
ATT_V4 |
ATT_V4 |
}; |
}; |
|
|
|
/* An argument to a macro (multiple values = `It -column'). */ |
struct mdoc_arg { |
struct mdoc_arg { |
int arg; |
int arg; |
int line; |
int line; |
Line 228 struct mdoc_arg { |
|
Line 226 struct mdoc_arg { |
|
char **value; |
char **value; |
}; |
}; |
|
|
|
/* |
|
* Simplified grammar of syntax tree: |
|
* |
|
* MDOC_ROOT: root of tree |
|
* MDOC_TEXT: free-form text |
|
* MDOC_ELEM: elem [args] MDOC_TEXT... |
|
* MDOC_BLOCK, MDOC_HEAD, MDOC_BODY, MDOC_TAIL: |
|
* MDOC_BLOCK: |
|
* MDOC_HEAD [args] (MDOC_TEXT|MDOC_ELEM|MDOC_BLOCK)... |
|
* MDOC_BODY (MDOC_TEXT|MDOC_ELEM|MDOC_BLOCK)... |
|
* MDOC_TAIL (optional) (MDOC_TEXT|MDOC_ELEM|MDOC_BLOCK)... |
|
*/ |
|
|
|
/* Type of a syntax node. */ |
enum mdoc_type { |
enum mdoc_type { |
MDOC_TEXT, |
MDOC_TEXT, |
MDOC_ELEM, |
MDOC_ELEM, |
Line 238 enum mdoc_type { |
|
Line 250 enum mdoc_type { |
|
MDOC_ROOT |
MDOC_ROOT |
}; |
}; |
|
|
|
/* Manual section. */ |
enum mdoc_msec { |
enum mdoc_msec { |
MSEC_DEFAULT = 0, |
MSEC_DEFAULT = 0, |
MSEC_1, |
MSEC_1, |
Line 260 enum mdoc_msec { |
|
Line 273 enum mdoc_msec { |
|
MSEC_paper |
MSEC_paper |
}; |
}; |
|
|
|
/* Section (named/unnamed) of `Ss'. */ |
enum mdoc_sec { |
enum mdoc_sec { |
SEC_PROLOGUE = 0, |
SEC_PROLOGUE = 0, |
SEC_BODY, |
SEC_BODY, |
|
|
SEC_CUSTOM |
SEC_CUSTOM |
}; |
}; |
|
|
|
/* Volume of `Dt'. */ |
enum mdoc_vol { |
enum mdoc_vol { |
VOL_DEFAULT = 0, |
VOL_DEFAULT = 0, |
VOL_AMD, |
VOL_AMD, |
|
|
VOL_USD |
VOL_USD |
}; |
}; |
|
|
|
/* Architecture of `Dt'. */ |
enum mdoc_arch { |
enum mdoc_arch { |
ARCH_DEFAULT = 0, |
ARCH_DEFAULT = 0, |
ARCH_alpha, |
ARCH_alpha, |
ARCH_amd64, |
ARCH_amd64, |
ARCH_amiga, |
ARCH_amiga, |
ARCH_arc, |
ARCH_arc, |
|
ARCH_arm, |
ARCH_armish, |
ARCH_armish, |
ARCH_aviion, |
ARCH_aviion, |
ARCH_hp300, |
ARCH_hp300, |
Line 323 enum mdoc_arch { |
|
Line 340 enum mdoc_arch { |
|
ARCH_zaurus |
ARCH_zaurus |
}; |
}; |
|
|
|
/* Meta-information from prologue. */ |
struct mdoc_meta { |
struct mdoc_meta { |
enum mdoc_msec msec; |
enum mdoc_msec msec; |
enum mdoc_vol vol; |
enum mdoc_vol vol; |
enum mdoc_arch arch; |
enum mdoc_arch arch; |
time_t date; |
time_t date; |
#define META_TITLE_SZ (64) |
char *title; |
char title[META_TITLE_SZ]; |
char *os; |
#define META_OS_SZ (64) |
char *name; |
char os[META_OS_SZ]; |
|
}; |
}; |
|
|
struct mdoc_text { |
struct mdoc_text { |
Line 359 union mdoc_data { |
|
Line 376 union mdoc_data { |
|
struct mdoc_block block; |
struct mdoc_block block; |
}; |
}; |
|
|
|
/* Syntax node in parse tree. */ |
struct mdoc_node { |
struct mdoc_node { |
struct mdoc_node *parent; |
struct mdoc_node *parent; |
struct mdoc_node *child; |
struct mdoc_node *child; |
Line 367 struct mdoc_node { |
|
Line 385 struct mdoc_node { |
|
int line; |
int line; |
int pos; |
int pos; |
int tok; |
int tok; |
|
int flags; |
|
#define MDOC_VALID (1 << 0) |
|
#define MDOC_ACTED (1 << 1) |
enum mdoc_type type; |
enum mdoc_type type; |
union mdoc_data data; |
union mdoc_data data; |
}; |
}; |
|
|
|
/* Call-backs for parse messages. */ |
struct mdoc_cb { |
struct mdoc_cb { |
void (*mdoc_msg)(void *, int, int, const char *); |
void (*mdoc_msg)(void *, int, int, const char *); |
int (*mdoc_err)(void *, int, int, const char *); |
int (*mdoc_err)(void *, int, int, const char *); |
|
|
|
|
struct mdoc; |
struct mdoc; |
|
|
|
/* Free memory allocated with mdoc_alloc. */ |
void mdoc_free(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 *data, const struct mdoc_cb *); |
|
|
|
/* Parse a single line (boolean retval). */ |
int mdoc_parseln(struct mdoc *, int, char *buf); |
int mdoc_parseln(struct mdoc *, int, char *buf); |
const struct mdoc_node |
|
*mdoc_result(struct mdoc *); |
|
int mdoc_endparse(struct mdoc *); |
|
|
|
char *mdoc_type2a(enum mdoc_type); |
/* Get parse result or NULL. */ |
|
const struct mdoc_node *mdoc_result(struct mdoc *); |
|
|
|
/* Signal end of parse sequence (boolean retval). */ |
|
int mdoc_endparse(struct mdoc *); |
|
|
__END_DECLS |
__END_DECLS |
|
|