* mdocml: Full support for eqn positionals (above, over, sup, sub, etc.).
@ 2011-07-21 14:13 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-07-21 14:13 UTC (permalink / raw)
To: source
Log Message:
-----------
Full support for eqn positionals (above, over, sup, sub, etc.).
Modified Files:
--------------
mdocml:
eqn.7
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.17
retrieving revision 1.18
diff -Leqn.c -Leqn.c -u -p -r1.17 -r1.18
--- eqn.c
+++ eqn.c
@@ -80,11 +80,22 @@ static const struct eqnstr eqnmarks[EQNM
};
static const struct eqnstr eqnfonts[EQNFONT__MAX] = {
+ { "", 0 },
{ "roman", 5 },
{ "bold", 4 },
{ "italic", 6 },
};
+static const struct eqnstr eqnposs[EQNPOS__MAX] = {
+ { "", 0 },
+ { "over", 4 },
+ { "sup", 3 },
+ { "sub", 3 },
+ { "to", 2 },
+ { "from", 4 },
+ { "above", 5 },
+};
+
/* ARGSUSED */
enum rofferr
eqn_read(struct eqn_node **epp, int ln,
@@ -189,8 +200,7 @@ eqn_box(struct eqn_node *ep, struct eqn_
*sv = last;
nextc = 1;
- font = EQNFONT_NONE;
-
+ font = EQNFONT_NONE;
again:
if (NULL == (start = eqn_nexttok(ep, &sz)))
return(0);
@@ -201,6 +211,15 @@ again:
if (strncmp(eqnfonts[i].name, start, sz))
continue;
font = (enum eqn_fontt)i;
+ goto again;
+ }
+
+ for (i = 0; i < (int)EQNFONT__MAX; i++) {
+ if (eqnposs[i].sz != sz)
+ continue;
+ if (strncmp(eqnposs[i].name, start, sz))
+ continue;
+ last->pos = (enum eqn_post)i;
goto again;
}
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -Lmandoc.h -Lmandoc.h -u -p -r1.86 -r1.87
--- mandoc.h
+++ mandoc.h
@@ -306,6 +306,17 @@ enum eqn_fontt {
EQNFONT__MAX
};
+enum eqn_post {
+ EQNPOS_NONE = 0,
+ EQNPOS_OVER,
+ EQNPOS_SUP,
+ EQNPOS_SUB,
+ EQNPOS_TO,
+ EQNPOS_FROM,
+ EQNPOS_ABOVE,
+ EQNPOS__MAX
+};
+
/*
* A "box" is a parsed mathematical expression as defined by the eqn.7
* grammar.
@@ -314,11 +325,16 @@ struct eqn_box {
enum eqn_boxt type; /* type of node */
struct eqn_box *child; /* child node */
struct eqn_box *next; /* next in tree */
+ enum eqn_post pos; /* position of next box */
char *text; /* text (or NULL) */
enum eqn_markt mark; /* a mark about the box */
enum eqn_fontt font; /* font of box */
};
+/*
+ * An equation consists of a tree of expressions starting at a given
+ * line and position.
+ */
struct eqn {
struct eqn_box *root; /* root mathematical expression */
int ln; /* invocation line */
Index: eqn.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/eqn.7,v
retrieving revision 1.10
retrieving revision 1.11
diff -Leqn.7 -Leqn.7 -u -p -r1.10 -r1.11
--- eqn.7
+++ eqn.7
@@ -67,9 +67,15 @@ box : text
| DEFINE text text
| SET text text
| UNDEF text
+ | box pos box
| box mark
| font box
text : TEXT
+pos : OVER
+ | SUP
+ | SUB
+ | TO
+ | FROM
mark : DOT
| DOTDOT
| HAT
Index: tree.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tree.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -Ltree.c -Ltree.c -u -p -r1.41 -r1.42
--- tree.c
+++ tree.c
@@ -270,18 +270,18 @@ print_box(const struct eqn_box *ep, int
switch (ep->type) {
case (EQN_ROOT):
- printf("eqn-root(%d, %d)\n",
- ep->font, ep->mark);
+ printf("eqn-root(%d, %d, %d)\n",
+ ep->pos, ep->font, ep->mark);
print_box(ep->child, indent + 1);
break;
case (EQN_SUBEXPR):
- printf("eqn-subxpr(%d, %d)\n",
- ep->font, ep->mark);
+ printf("eqn-subxpr(%d, %d, %d)\n",
+ ep->pos, ep->font, ep->mark);
print_box(ep->child, indent + 1);
break;
case (EQN_TEXT):
- printf("eqn-text(%d, %d): [%s]\n",
- ep->font, ep->mark, ep->text);
+ printf("eqn-text(%d, %d, %d): [%s]\n",
+ ep->pos, ep->font, ep->mark, ep->text);
break;
default:
break;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-07-21 14:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21 14:13 mdocml: Full support for eqn positionals (above, over, sup, sub, etc.) kristaps
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).