X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/2bcccf0dba8f2c504e9c3597a11177aaca90023c..c75a70fe96c444404797d0ca3abc9edf5076a713:/mdoc.h

diff --git a/mdoc.h b/mdoc.h
index dc4be587..80390dd0 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,6 +1,6 @@
-/*	$Id: mdoc.h,v 1.92 2010/06/26 15:36:37 kristaps Exp $ */
+/*	$Id: mdoc.h,v 1.102 2010/07/21 09:08:26 kristaps Exp $ */
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -155,35 +155,36 @@ enum	mdoct {
 
 /* What follows is a list of ALL possible macro arguments. */
 
-/* FIXME: make this into an enum. */
-#define	MDOC_Split	 0
-#define	MDOC_Nosplit	 1
-#define	MDOC_Ragged	 2
-#define	MDOC_Unfilled	 3
-#define	MDOC_Literal	 4
-#define	MDOC_File	 5
-#define	MDOC_Offset	 6
-#define	MDOC_Bullet	 7
-#define	MDOC_Dash	 8
-#define	MDOC_Hyphen	 9
-#define	MDOC_Item	 10
-#define	MDOC_Enum	 11
-#define	MDOC_Tag	 12
-#define	MDOC_Diag	 13
-#define	MDOC_Hang	 14
-#define	MDOC_Ohang	 15
-#define	MDOC_Inset	 16
-#define	MDOC_Column	 17
-#define	MDOC_Width	 18
-#define	MDOC_Compact	 19
-#define	MDOC_Std	 20
-#define	MDOC_Filled	 21
-#define	MDOC_Words	 22
-#define	MDOC_Emphasis	 23
-#define	MDOC_Symbolic	 24
-#define	MDOC_Nested	 25
-#define	MDOC_Centred	 26
-#define	MDOC_ARG_MAX	 27
+enum	mdocargt {
+	MDOC_Split,
+	MDOC_Nosplit,
+	MDOC_Ragged,
+	MDOC_Unfilled,
+	MDOC_Literal,
+	MDOC_File,
+	MDOC_Offset,
+	MDOC_Bullet,
+	MDOC_Dash,
+	MDOC_Hyphen,
+	MDOC_Item,
+	MDOC_Enum,
+	MDOC_Tag,
+	MDOC_Diag,
+	MDOC_Hang,
+	MDOC_Ohang,
+	MDOC_Inset,
+	MDOC_Column,
+	MDOC_Width,
+	MDOC_Compact,
+	MDOC_Std,
+	MDOC_Filled,
+	MDOC_Words,
+	MDOC_Emphasis,
+	MDOC_Symbolic,
+	MDOC_Nested,
+	MDOC_Centred,
+	MDOC_ARG_MAX
+};
 
 /* Type of a syntax node. */
 enum	mdoc_type {
@@ -236,7 +237,7 @@ struct	mdoc_meta {
 
 /* An argument to a macro (multiple values = `It -column'). */
 struct	mdoc_argv {
-	int	  	  arg;
+	enum mdocargt  	  arg;
 	int		  line;
 	int		  pos;
 	size_t		  sz;
@@ -249,6 +250,12 @@ struct 	mdoc_arg {
 	unsigned int	  refcnt;
 };
 
+enum	mdoc_endbody {
+	ENDBODY_NOT = 0,
+	ENDBODY_SPACE,
+	ENDBODY_NOSPACE
+};
+
 enum	mdoc_list {
 	LIST__NONE = 0,
 	LIST_bullet,
@@ -273,6 +280,19 @@ enum	mdoc_disp {
 	DISP_literal
 };
 
+enum	mdoc_auth {
+	AUTH__NONE = 0,
+	AUTH_split,
+	AUTH_nosplit
+};
+
+enum	mdoc_font {
+	FONT__NONE = 0,
+	FONT_Em,
+	FONT_Li,
+	FONT_Sy
+};
+
 struct	mdoc_bd {
 	const char	 *offs; /* -offset */
 	enum mdoc_disp	  type; /* -ragged, etc. */
@@ -284,6 +304,16 @@ struct	mdoc_bl {
 	const char	 *offs; /* -offset */
 	enum mdoc_list	  type; /* -tag, -enum, etc. */
 	int		  comp; /* -compact */
+	size_t		  ncols; /* -column arg count */
+	const char	**cols; /* -column val ptr */
+};
+
+struct	mdoc_bf {
+	enum mdoc_font	  font; /* font */
+};
+
+struct	mdoc_an {
+	enum mdoc_auth	  auth; /* -split, etc. */
 };
 
 /* Node in AST. */
@@ -301,20 +331,24 @@ struct	mdoc_node {
 #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 */
+#define	MDOC_SYNPRETTY	 (1 << 4) /* SYNOPSIS-style formatting */
+#define	MDOC_ENDED	 (1 << 5) /* rendering has been ended */
 	enum mdoc_type	  type; /* AST node type */
 	enum mdoc_sec	  sec; /* current named section */
+	/* FIXME: these can be union'd to shave a few bytes. */
 	struct mdoc_arg	 *args; 	/* BLOCK/ELEM */
-#ifdef	UGLY
 	struct mdoc_node *pending;	/* BLOCK */
-#endif
 	struct mdoc_node *head;		/* BLOCK */
 	struct mdoc_node *body;		/* BLOCK */
 	struct mdoc_node *tail;		/* BLOCK */
 	char		 *string;	/* TEXT */
+	enum mdoc_endbody end;		/* BODY */
 
 	union {
-		struct mdoc_bl Bl;
-		struct mdoc_bd Bd;
+		struct mdoc_an  An;
+		struct mdoc_bd *Bd;
+		struct mdoc_bf *Bf;
+		struct mdoc_bl *Bl;
 	} data;
 };
 
@@ -334,11 +368,9 @@ struct	mdoc;
 /* See mdoc.3 for documentation. */
 
 void	 	  mdoc_free(struct mdoc *);
-struct	mdoc	 *mdoc_alloc(void *, int, mandocmsg);
+struct	mdoc	 *mdoc_alloc(struct regset *, void *, int, mandocmsg);
 void		  mdoc_reset(struct mdoc *);
-int	 	  mdoc_parseln(struct mdoc *, 
-			const struct regset *,
-			int, char *, int);
+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 *);