source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Give lists their own eqn function.
Date: Fri, 22 Jul 2011 05:57:04 -0400 (EDT)	[thread overview]
Message-ID: <201107220957.p6M9v4Oq028457@krisdoz.my.domain> (raw)

Log Message:
-----------
Give lists their own eqn function.

Modified Files:
--------------
    mdocml:
        eqn.c
        mandoc.h
        tree.c

Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/eqn.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -Leqn.c -Leqn.c -u -p -r1.22 -r1.23
--- eqn.c
+++ eqn.c
@@ -56,6 +56,7 @@ enum	eqnpartt {
 	EQN__MAX
 };
 
+static	enum eqn_rest	 eqn_box(struct eqn_node *, struct eqn_box *);
 static	struct eqn_box	*eqn_box_alloc(struct eqn_box *);
 static	void		 eqn_box_free(struct eqn_box *);
 static	struct eqn_def	*eqn_def_find(struct eqn_node *, 
@@ -63,13 +64,13 @@ static	struct eqn_def	*eqn_def_find(stru
 static	int		 eqn_do_define(struct eqn_node *);
 static	int		 eqn_do_set(struct eqn_node *);
 static	int		 eqn_do_undef(struct eqn_node *);
+static	enum eqn_rest	 eqn_eqn(struct eqn_node *, struct eqn_box *);
+static	enum eqn_rest	 eqn_list(struct eqn_node *, struct eqn_box *);
 static	const char	*eqn_nexttok(struct eqn_node *, size_t *);
 static	const char	*eqn_nextrawtok(struct eqn_node *, size_t *);
 static	const char	*eqn_next(struct eqn_node *, 
 				char, size_t *, int);
 static	void		 eqn_rewind(struct eqn_node *);
-static	enum eqn_rest	 eqn_eqn(struct eqn_node *, struct eqn_box *);
-static	enum eqn_rest	 eqn_box(struct eqn_node *, struct eqn_box *);
 
 static	const struct eqnpart eqnparts[EQN__MAX] = {
 	{ { "define", 6 }, eqn_do_define }, /* EQN_DEFINE */
@@ -204,6 +205,51 @@ eqn_eqn(struct eqn_node *ep, struct eqn_
 }
 
 static enum eqn_rest
+eqn_list(struct eqn_node *ep, struct eqn_box *last)
+{
+	struct eqn_box	*bp;
+	const char	*start;
+	size_t		 sz;
+	enum eqn_rest	 c;
+
+	bp = eqn_box_alloc(last);
+	bp->type = EQN_LIST;
+
+	if (NULL == (start = eqn_nexttok(ep, &sz))) {
+		EQN_MSG(MANDOCERR_EQNEOF, ep);
+		return(EQN_ERR);
+	}
+	if (1 != sz || strncmp("{", start, 1)) {
+		EQN_MSG(MANDOCERR_EQNSYNT, ep);
+		return(EQN_ERR);
+	}
+
+	while (EQN_DESCOPE == (c = eqn_eqn(ep, bp))) {
+		eqn_rewind(ep);
+		start = eqn_nexttok(ep, &sz);
+		assert(start);
+		if (5 != sz || strncmp("above", start, 5))
+			break;
+		bp->last->above = 1;
+	}
+
+	if (EQN_DESCOPE != c) {
+		if (EQN_ERR != c)
+			EQN_MSG(MANDOCERR_EQNSCOPE, ep);
+		return(EQN_ERR);
+	}
+
+	eqn_rewind(ep);
+	start = eqn_nexttok(ep, &sz);
+	assert(start);
+	if (1 == sz && 0 == strncmp("}", start, 1))
+		return(EQN_OK);
+
+	EQN_MSG(MANDOCERR_EQNBADSCOPE, ep);
+	return(EQN_ERR);
+}
+
+static enum eqn_rest
 eqn_box(struct eqn_node *ep, struct eqn_box *last)
 {
 	size_t		 sz;
@@ -251,40 +297,9 @@ eqn_box(struct eqn_node *ep, struct eqn_
 			continue;
 		if (strncmp(eqnpiles[i].name, start, sz))
 			continue;
-		if (NULL == (start = eqn_nexttok(ep, &sz))) {
-			EQN_MSG(MANDOCERR_EQNEOF, ep);
-			return(EQN_ERR);
-		}
-		if (1 != sz || strncmp("{", start, 1)) {
-			EQN_MSG(MANDOCERR_EQNSYNT, ep);
-			return(EQN_ERR);
-		}
-
-		while (EQN_DESCOPE == (c = eqn_eqn(ep, last))) {
-			assert(last->last);
+		if (EQN_OK == (c = eqn_list(ep, last)))
 			last->last->pile = (enum eqn_pilet)i;
-			eqn_rewind(ep);
-			start = eqn_nexttok(ep, &sz);
-			assert(start);
-			if (5 != sz || strncmp("above", start, 5))
-				break;
-			last->last->above = 1;
-		}
-
-		if (EQN_DESCOPE != c) {
-			if (EQN_ERR != c)
-				EQN_MSG(MANDOCERR_EQNSCOPE, ep);
-			return(EQN_ERR);
-		}
-
-		eqn_rewind(ep);
-		start = eqn_nexttok(ep, &sz);
-		assert(start);
-		if (1 == sz && 0 == strncmp("}", start, 1))
-			return(EQN_OK);
-
-		EQN_MSG(MANDOCERR_EQNBADSCOPE, ep);
-		return(EQN_ERR);
+		return(c);
 	}
 
 	if (4 == sz && 0 == strncmp("left", start, 4)) {
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.89
retrieving revision 1.90
diff -Lmandoc.h -Lmandoc.h -u -p -r1.89 -r1.90
--- mandoc.h
+++ mandoc.h
@@ -285,7 +285,8 @@ struct	tbl_span {
 enum	eqn_boxt {
 	EQN_ROOT, /* root of parse tree */
 	EQN_TEXT, /* text (number, variable, whatever) */
-	EQN_SUBEXPR /* nested subexpression */
+	EQN_SUBEXPR, /* nested `eqn' subexpression */
+	EQN_LIST /* list of subexpressions */
 };
 
 enum	eqn_markt {
Index: tree.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tree.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -Ltree.c -Ltree.c -u -p -r1.44 -r1.45
--- tree.c
+++ tree.c
@@ -276,6 +276,15 @@ print_box(const struct eqn_box *ep, int 
 			ep->pos, ep->font, ep->mark);
 		print_box(ep->first, indent + 1);
 		break;
+	case (EQN_LIST):
+		printf("eqn-list(%d, %d, %d, %d, %d, %d, \"%s\", \"%s\")\n", 
+			EQN_DEFSIZE == ep->size ? 0 : ep->size,
+			ep->pos, ep->font, ep->mark,
+			ep->pile, ep->above,
+			ep->left ? ep->left : "",
+			ep->right ? ep->right : "");
+		print_box(ep->first, indent + 1);
+		break;
 	case (EQN_SUBEXPR):
 		printf("eqn-subxpr(%d, %d, %d, %d, %d, %d, \"%s\", \"%s\")\n", 
 			EQN_DEFSIZE == ep->size ? 0 : ep->size,
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2011-07-22  9:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201107220957.p6M9v4Oq028457@krisdoz.my.domain \
    --to=kristaps@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).