-/* $Id: mdoc.h,v 1.1 2008/12/15 01:54:58 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.8 2008/12/29 18:08:44 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
#ifndef MDOC_H
#define MDOC_H
-#define MDOC_LINEARG_MAX 9
+#define MDOC_LINEARG_MAX 8
#define MDOC___ 0
#define MDOC_Dd 1
#define MDOC_ARG_MAX 60
enum mdoc_err {
- ERR_SYNTAX_QUOTE,
+ ERR_SYNTAX_QUOTE, /* NOTUSED */
+ ERR_SYNTAX_UNQUOTE,
+ ERR_SYNTAX_NOPUNCT,
ERR_SYNTAX_WS,
+ ERR_SYNTAX_ARG,
+ ERR_SYNTAX_ARGFORM,
+ ERR_SYNTAX_ARGVAL,
+ ERR_SYNTAX_ARGBAD,
+ ERR_SYNTAX_ARGMANY,
ERR_MACRO_NOTSUP,
ERR_MACRO_NOTCALL,
ERR_SCOPE_BREAK,
- ERR_ARGS_GE1
+ ERR_SCOPE_NOCTX,
+ ERR_SCOPE_NONEST,
+ ERR_SEC_PROLOGUE,
+ ERR_SEC_NPROLOGUE,
+ ERR_SEC_PROLOGUE_OO,
+ ERR_SEC_PROLOGUE_REP,
+ ERR_SEC_NAME,
+ ERR_ARGS_EQ0,
+ ERR_ARGS_GE1,
+ ERR_ARGS_LE2,
+ ERR_ARGS_MANY
+};
+
+enum mdoc_att {
+ ATT_DEFAULT = 0,
+ ATT_v1,
+ ATT_v2,
+ ATT_v3,
+ ATT_v4,
+ ATT_v5,
+ ATT_v6,
+ ATT_v7,
+ ATT_32v,
+ ATT_V1,
+ ATT_V2,
+ ATT_V3,
+ ATT_V4
};
enum mdoc_warn {
WARN_SYNTAX_WS_EOLN,
WARN_SYNTAX_MACLIKE,
- WARN_ARGS_GE1
+ WARN_SYNTAX_ARGLIKE,
+ WARN_SYNTAX_QUOTED,
+ WARN_IGN_AFTER_BLK,
+ WARN_IGN_BEFORE_BLK,
+ WARN_SEC_OO,
+ WARN_ARGS_GE1,
+ WARN_ARGS_EQ0,
+ WARN_COMPAT_TROFF
};
struct mdoc_arg {
MDOC_BLOCK
};
+enum mdoc_msec {
+ MSEC_DEFAULT = 0,
+ MSEC_1,
+ MSEC_2,
+ MSEC_3,
+ MSEC_3f,
+ MSEC_3p,
+ MSEC_4,
+ MSEC_5,
+ MSEC_6,
+ MSEC_7,
+ MSEC_8,
+ MSEC_9,
+ MSEC_X11,
+ MSEC_X11R6,
+ MSEC_local,
+ MSEC_n,
+ MSEC_unass,
+ MSEC_draft,
+ MSEC_paper
+};
+
+enum mdoc_sec {
+ SEC_PROLOGUE = 0,
+ SEC_BODY,
+ SEC_NAME,
+ SEC_SYNOPSIS,
+ SEC_DESCRIPTION,
+ SEC_RETURN_VALUES,
+ SEC_ENVIRONMENT,
+ SEC_FILES,
+ SEC_EXAMPLES,
+ SEC_DIAGNOSTICS,
+ SEC_ERRORS,
+ SEC_SEE_ALSO,
+ SEC_STANDARDS,
+ SEC_HISTORY,
+ SEC_AUTHORS,
+ SEC_CAVEATS,
+ SEC_BUGS,
+ SEC_CUSTOM
+};
+
+enum mdoc_vol {
+ VOL_DEFAULT = 0,
+ VOL_AMD,
+ VOL_IND,
+ VOL_KM,
+ VOL_LOCAL,
+ VOL_PRM,
+ VOL_PS1,
+ VOL_SMM,
+ VOL_URM,
+ VOL_USD
+};
+
+enum mdoc_arch {
+ ARCH_DEFAULT = 0,
+ ARCH_alpha,
+ ARCH_amd64,
+ ARCH_amiga,
+ ARCH_arc,
+ ARCH_armish,
+ ARCH_aviion,
+ ARCH_hp300,
+ ARCH_hppa,
+ ARCH_hppa64,
+ ARCH_i386,
+ ARCH_landisk,
+ ARCH_luna88k,
+ ARCH_mac68k,
+ ARCH_macppc,
+ ARCH_mvme68k,
+ ARCH_mvme88k,
+ ARCH_mvmeppc,
+ ARCH_pmax,
+ ARCH_sgi,
+ ARCH_socppc,
+ ARCH_sparc,
+ ARCH_sparc64,
+ ARCH_sun3,
+ ARCH_vax,
+ ARCH_zaurus
+};
+
+struct mdoc_meta {
+ enum mdoc_msec msec;
+ enum mdoc_vol vol;
+ enum mdoc_arch arch;
+ time_t date;
+#define META_TITLE_SZ (64)
+ char title[META_TITLE_SZ];
+#define META_OS_SZ (64)
+ char os[META_OS_SZ];
+};
+
struct mdoc_text {
char *string;
};
struct mdoc_node *parent;
struct mdoc_node *child;
struct mdoc_node *next;
+ struct mdoc_node *prev;
enum mdoc_type type;
union mdoc_data data;
};
void mdoc_free(struct mdoc *);
struct mdoc *mdoc_alloc(void *data, const struct mdoc_cb *);
int mdoc_parseln(struct mdoc *, char *buf);
-
const struct mdoc_node
*mdoc_result(struct mdoc *);