=================================================================== RCS file: /cvs/mandoc/mandoc.h,v retrieving revision 1.85 retrieving revision 1.91 diff -u -p -r1.85 -r1.91 --- mandoc/mandoc.h 2011/07/21 13:18:24 1.85 +++ mandoc/mandoc.h 2011/07/22 14:55:07 1.91 @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.85 2011/07/21 13:18:24 kristaps Exp $ */ +/* $Id: mandoc.h,v 1.91 2011/07/22 14:55:07 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * @@ -110,10 +110,12 @@ enum mandocerr { MANDOCERR_ERROR, /* ===== start of errors ===== */ /* related to equations */ - MANDOCERR_EQNARGS, /* bad equation macro arguments */ MANDOCERR_EQNNEST, /* too many nested equation defines */ MANDOCERR_EQNNSCOPE, /* unexpected equation scope closure*/ MANDOCERR_EQNSCOPE, /* equation scope open on exit */ + MANDOCERR_EQNBADSCOPE, /* overlapping equation scopes */ + MANDOCERR_EQNEOF, /* unexpected end of equation */ + MANDOCERR_EQNSYNT, /* equation syntax error */ /* related to tables */ MANDOCERR_TBL, /* bad table syntax */ @@ -282,7 +284,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 { @@ -298,18 +301,58 @@ enum eqn_markt { EQNMARK__MAX }; -/* +enum eqn_fontt { + EQNFONT_NONE = 0, + EQNFONT_ROMAN, + EQNFONT_BOLD, + EQNFONT_ITALIC, + EQNFONT__MAX +}; + +enum eqn_post { + EQNPOS_NONE = 0, + EQNPOS_OVER, + EQNPOS_SUP, + EQNPOS_SUB, + EQNPOS_TO, + EQNPOS_FROM, + EQNPOS__MAX +}; + +enum eqn_pilet { + EQNPILE_NONE = 0, + EQNPILE_CPILE, + EQNPILE_RPILE, + EQNPILE_LPILE, + EQNPILE__MAX +}; + + /* * A "box" is a parsed mathematical expression as defined by the eqn.7 * grammar. */ struct eqn_box { + int size; /* font size of expression */ +#define EQN_DEFSIZE INT_MIN enum eqn_boxt type; /* type of node */ - struct eqn_box *child; /* child node */ - struct eqn_box *next; /* next in tree */ + struct eqn_box *first; /* first child node */ + struct eqn_box *last; /* last child node */ + struct eqn_box *next; /* node sibling */ + struct eqn_box *parent; /* node sibling */ char *text; /* text (or NULL) */ - enum eqn_markt mark; /* whether 'marked' */ + char *left; + char *right; + enum eqn_post pos; /* position of next box */ + enum eqn_markt mark; /* a mark about the box */ + enum eqn_fontt font; /* font of box */ + enum eqn_pilet pile; /* equation piling */ + int above; /* next node is above */ }; +/* + * 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 */ @@ -364,6 +407,7 @@ void *mandoc_calloc(size_t, size_t); void *mandoc_malloc(size_t); void *mandoc_realloc(void *, size_t); char *mandoc_strdup(const char *); +char *mandoc_strndup(const char *, size_t); enum mandoc_esc mandoc_escape(const char **, const char **, int *);