aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandoc.h
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-21 23:30:39 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-21 23:30:39 +0000
commit1f1fa3776c03b51f845d9d9f54cbc3c980f6ead6 (patch)
tree203d6d6ad512f6d6a7d032cf8117556ef029a660 /mandoc.h
parent3ee412a268eff0c9e52bb141dc3289eda00a6d53 (diff)
downloadmandoc-1f1fa3776c03b51f845d9d9f54cbc3c980f6ead6.tar.gz
mandoc-1f1fa3776c03b51f845d9d9f54cbc3c980f6ead6.tar.zst
mandoc-1f1fa3776c03b51f845d9d9f54cbc3c980f6ead6.zip
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.h27
1 files changed, 22 insertions, 5 deletions
diff --git a/mandoc.h b/mandoc.h
index 556a88a8..7431e95b 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.88 2011/07/21 15:21:13 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.89 2011/07/21 23:30:39 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 *);