=================================================================== RCS file: /cvs/mandoc/mandoc.h,v retrieving revision 1.86 retrieving revision 1.94 diff -u -p -r1.86 -r1.94 --- mandoc/mandoc.h 2011/07/21 13:37:04 1.86 +++ mandoc/mandoc.h 2011/07/23 18:41:18 1.94 @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.86 2011/07/21 13:37:04 kristaps Exp $ */ +/* $Id: mandoc.h,v 1.94 2011/07/23 18:41:18 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * @@ -110,10 +110,11 @@ 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 +283,9 @@ 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, /* subexpressions list */ + EQN_MATRIX /* matrix subexpression */ }; enum eqn_markt { @@ -302,24 +305,59 @@ enum eqn_fontt { EQNFONT_NONE = 0, EQNFONT_ROMAN, EQNFONT_BOLD, + EQNFONT_FAT, 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_CCOL, + EQNPILE_RCOL, + EQNPILE_LCOL, + 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) */ + 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 */ }; +/* + * An equation consists of a tree of expressions starting at a given + * line and position. + */ struct eqn { + char *name; /* identifier (or NULL) */ struct eqn_box *root; /* root mathematical expression */ int ln; /* invocation line */ int pos; /* invocation position */ @@ -373,6 +411,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 *);