xref: /freebsd/contrib/mandoc/eqn.h (revision 882f88ff77194ef2eea005232780468404438788)
1 /*	$Id: eqn.h,v 1.1 2018/12/13 05:23:38 schwarze Exp $ */
2 /*
3  * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  *
17  * Public data types for eqn(7) syntax trees.
18  */
19 
20 enum	eqn_boxt {
21 	EQN_TEXT,	/* Text, e.g. number, variable, operator, ... */
22 	EQN_SUBEXPR,	/* Nested eqn(7) subexpression. */
23 	EQN_LIST,	/* List, for example in braces. */
24 	EQN_PILE,	/* Vertical pile. */
25 	EQN_MATRIX	/* List of columns. */
26 };
27 
28 enum	eqn_fontt {
29 	EQNFONT_NONE = 0,
30 	EQNFONT_ROMAN,
31 	EQNFONT_BOLD,
32 	EQNFONT_FAT,
33 	EQNFONT_ITALIC,
34 	EQNFONT__MAX
35 };
36 
37 enum	eqn_post {
38 	EQNPOS_NONE = 0,
39 	EQNPOS_SUP,
40 	EQNPOS_SUBSUP,
41 	EQNPOS_SUB,
42 	EQNPOS_TO,
43 	EQNPOS_FROM,
44 	EQNPOS_FROMTO,
45 	EQNPOS_OVER,
46 	EQNPOS_SQRT,
47 	EQNPOS__MAX
48 };
49 
50  /*
51  * A "box" is a parsed mathematical expression as defined by the eqn.7
52  * grammar.
53  */
54 struct	eqn_box {
55 	struct eqn_box	 *parent;
56 	struct eqn_box	 *prev;
57 	struct eqn_box	 *next;
58 	struct eqn_box	 *first;   /* First child node. */
59 	struct eqn_box	 *last;    /* Last child node. */
60 	char		 *text;    /* Text (or NULL). */
61 	char		 *left;    /* Left-hand fence. */
62 	char		 *right;   /* Right-hand fence. */
63 	char		 *top;     /* Symbol above. */
64 	char		 *bottom;  /* Symbol below. */
65 	size_t		  expectargs; /* Maximal number of arguments. */
66 	size_t		  args;    /* Actual number of arguments. */
67 	int		  size;    /* Font size. */
68 #define	EQN_DEFSIZE	  INT_MIN
69 	enum eqn_boxt	  type;    /* Type of node. */
70 	enum eqn_fontt	  font;    /* Font in this box. */
71 	enum eqn_post	  pos;     /* Position of the next box. */
72 };
73