version 1.37, 2009/03/06 14:13:47 |
version 1.43, 2009/03/09 13:04:01 |
|
|
|
|
/* What follows is a list of ALL possible macros. */ |
/* What follows is a list of ALL possible macros. */ |
|
|
|
/* TODO: Brq et al. */ |
|
|
#define MDOC___ 0 |
#define MDOC___ 0 |
#define MDOC_Dd 1 |
#define MDOC_Dd 1 |
#define MDOC_Dt 2 |
#define MDOC_Dt 2 |
|
|
#define MDOC_Fr 104 |
#define MDOC_Fr 104 |
#define MDOC_Ud 105 |
#define MDOC_Ud 105 |
#define MDOC_Lb 106 |
#define MDOC_Lb 106 |
#define MDOC_MAX 107 |
#define MDOC_Ap 107 |
|
#define MDOC_Lp 108 |
|
#define MDOC_MAX 109 |
|
|
/* What follows is a list of ALL possible macro arguments. */ |
/* What follows is a list of ALL possible macro arguments. */ |
|
|
Line 173 enum mdoc_warn { |
|
Line 177 enum mdoc_warn { |
|
WARN_COMPAT |
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. */ |
/* Type of a syntax node. */ |
enum mdoc_type { |
enum mdoc_type { |
MDOC_TEXT, |
MDOC_TEXT, |
Line 229 struct mdoc_meta { |
|
Line 224 struct mdoc_meta { |
|
char *name; |
char *name; |
}; |
}; |
|
|
/* Text-only node. */ |
/* An argument to a macro (multiple values = `It -column'). */ |
struct mdoc_text { |
struct mdoc_argv { |
char *string; |
int arg; |
|
int line; |
|
int pos; |
|
size_t sz; |
|
char **value; |
}; |
}; |
|
|
/* Block (scoped) node. */ |
struct mdoc_arg { |
struct mdoc_block { |
|
size_t argc; |
size_t argc; |
struct mdoc_arg *argv; |
struct mdoc_argv *argv; |
struct mdoc_node *head; |
unsigned int refcnt; |
struct mdoc_node *body; |
|
struct mdoc_node *tail; |
|
}; |
}; |
|
|
/* 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. */ |
/* Node in AST. */ |
struct mdoc_node { |
struct mdoc_node { |
struct mdoc_node *parent; |
struct mdoc_node *parent; |
Line 269 struct mdoc_node { |
|
Line 252 struct mdoc_node { |
|
#define MDOC_VALID (1 << 0) |
#define MDOC_VALID (1 << 0) |
#define MDOC_ACTED (1 << 1) |
#define MDOC_ACTED (1 << 1) |
enum mdoc_type type; |
enum mdoc_type type; |
union mdoc_data data; |
|
enum mdoc_sec sec; |
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. */ |
/* 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 *); |
|
|
void mdoc_free(struct mdoc *); |
void mdoc_free(struct mdoc *); |
|
|
/* Allocate a new parser instance. */ |
/* 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 *); |
|
|
|
/* Set parse options. */ |
|
void mdoc_setflags(struct mdoc *, int); |
|
|
/* Parse a single line in a stream (boolean retval). */ |
/* Parse a single line in a stream (boolean retval). */ |
int mdoc_parseln(struct mdoc *, int, char *buf); |
int mdoc_parseln(struct mdoc *, int, char *buf); |