diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-21 23:30:39 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-21 23:30:39 +0000 |
commit | 561fdaf67b6be484562a755697a834c21b10e4d9 (patch) | |
tree | 3f7792cc5662c919c2fc20e0490f6ec09d7e41a4 /mandoc.h | |
parent | ff6ddfd72fee08b3063dffb618af31325e51beea (diff) | |
download | mandoc-561fdaf67b6be484562a755697a834c21b10e4d9.tar.gz |
Complete eqn.7 parsing. Features all productions from the original 1975
CACM paper in an LR(1) parse (1 -> eqn_rewind()). Right now the code is
a little jungly, but will clear up as I consolidate parse components.
The AST structure will also be cleaned up, as right now it's pretty ad
hoc (this won't change the parse itself). I added the mandoc_strndup()
function will here.
Diffstat (limited to 'mandoc.h')
-rw-r--r-- | mandoc.h | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -114,6 +114,9 @@ enum mandocerr { 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 */ @@ -313,10 +316,17 @@ enum eqn_post { EQNPOS_SUB, EQNPOS_TO, EQNPOS_FROM, - EQNPOS_ABOVE, 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. @@ -325,12 +335,18 @@ 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 */ - enum eqn_post pos; /* position of next box */ + 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 */ + int above; /* next node is above */ }; /* @@ -391,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 *); |