1 /* predefined array sizes */
2 #define FNLEN 32 /* font name length */
3 #define SZLEN 32 /* point size length */
4 #define LNLEN 1000 /* line length */
5 #define NMLEN 32 /* macro name length */
6 #define RLEN 8 /* register name length */
7 #define NPILES 32 /* number of piled items */
8 #define NSIZES 8 /* number of bracket sizes */
9 #define GNLEN 32 /* glyph name length */
10 #define BRLEN 64 /* bracket definition length */
12 /* registers used by neateqn */
13 #define EQNSZ ".eqnsz" /* register for surrounding point size */
14 #define EQNFN ".eqnfn" /* register for surrounding font */
15 #define EQNS "10" /* eqn-collected line register */
16 #define EQNMK ".eqnmk" /* eqn horizontal mark */
19 #define MIN(a, b) ((a) < (b) ? (a) : (b))
20 #define MAX(a, b) ((a) < (b) ? (b) : (a))
21 #define LEN(a) (sizeof(a) / sizeof((a)[0]))
23 /* token and atom types */
24 #define T_TOK(t) ((t) & 0x00ff)
25 #define T_ATOM(t) ((t) & 0x00f0)
26 #define T_FONT(t) ((t) & T_ITALIC)
27 #define T_ATOMIDX(t) ((((t) >> 4) & 15) - 1)
29 #define T_EOF 0x0000 /* parser-specific */
30 #define T_SPACE 0x0001
32 #define T_KEYWORD 0x0003
33 #define T_ORD 0x0010 /* ordinary */
34 #define T_LETTER 0x0011
35 #define T_NUMBER 0x0012
36 #define T_STRING 0x0013
38 #define T_BIGOP 0x0020 /* big operators */
39 #define T_BINOP 0x0030 /* binary operators */
40 #define T_RELOP 0x0040 /* relational symbol */
41 #define T_LEFT 0x0050 /* opening token */
42 #define T_RIGHT 0x0060 /* closing token */
43 #define T_PUNC 0x0070 /* punctuation symbol */
44 #define T_INNER 0x0080 /* like fractions */
46 #define T_ITALIC 0x0100 /* atom with italic font */
48 /* spaces in hundredths of em */
49 #define S_S1 e_thinspace /* thin space */
50 #define S_S2 e_mediumspace /* medium space */
51 #define S_S3 e_thickspace /* thick space */
56 void in_define(char *name
, char *def
);
57 int in_expand(char *name
, char **args
);
58 int in_macrocall(char *name
);
62 void in_lineset(int n
);
67 void tok_eqnout(char *s
);
70 char *tok_poptext(int sep
);
71 int tok_jmp(char *kwd
);
73 int tok_sep(int soft
);
78 /* default definitions and operators */
79 int def_type(char *s
);
80 void def_typeput(char *s
, int type
);
81 void def_pieces(char *sign
, char **top
, char **mid
, char **bot
, char **cen
);
82 void def_sizes(char *sign
, char *sizes
[]);
83 int def_brcost(int type
);
84 void def_piecesput(char *sign
, char *top
, char *mid
, char *bot
, char *cen
);
85 void def_sizesput(char *sign
, char *sizes
[]);
86 void def_brcostput(int type
, int cost
);
87 extern char *def_macros
[][2];
89 /* variable length string buffer */
91 char *s
; /* allocated buffer */
92 int sz
; /* buffer size */
93 int n
; /* length of the string stored in s */
96 void sbuf_init(struct sbuf
*sbuf
);
97 void sbuf_done(struct sbuf
*sbuf
);
98 char *sbuf_buf(struct sbuf
*sbuf
);
99 void sbuf_add(struct sbuf
*sbuf
, int c
);
100 void sbuf_append(struct sbuf
*sbuf
, char *s
);
101 void sbuf_printf(struct sbuf
*sbuf
, char *s
, ...);
102 void sbuf_cut(struct sbuf
*sbuf
, int n
);
103 int sbuf_len(struct sbuf
*sbuf
);
104 int sbuf_empty(struct sbuf
*sbuf
);
116 #define TS_MK(s, p) (((s) << 4) | (p))
117 #define TS_0(s) ((s) & 0x01) /* primed variant */
118 #define TS_MK0(s) ((s) | 0x01) /* make style primed */
119 #define TS_SZ(s) ((s) >> 4) /* character size */
120 #define TS_DX(s) ((s) == TS_D || (s) == TS_D0)
121 #define TS_TXT(s) ((s) & 0x02) /* text style */
123 int ts_sup(int style
);
124 int ts_sub(int style
);
125 int ts_denom(int style
);
126 int ts_num(int style
);
130 struct sbuf raw
; /* the contents */
131 int szreg
, szown
; /* number register holding box size */
132 int reg
; /* register holding the contents */
133 int atoms
; /* the number of atoms inserted */
134 int tbeg
, tcur
; /* type of the first and the last atoms */
135 int style
; /* tex style (TS_*) */
136 char *tomark
; /* register for saving box width */
139 struct box
*box_alloc(int szreg
, int at_pre
, int style
);
140 void box_free(struct box
*box
);
141 void box_puttext(struct box
*box
, int type
, char *s
, ...);
142 void box_putf(struct box
*box
, char *s
, ...);
143 int box_size(struct box
*box
, char *val
);
144 void box_merge(struct box
*box
, struct box
*sub
, int breakable
);
145 void box_sub(struct box
*box
, struct box
*sub
, struct box
*sup
);
146 void box_from(struct box
*box
, struct box
*lim
, struct box
*llim
, struct box
*ulim
);
147 void box_over(struct box
*box
, struct box
*num
, struct box
*denom
);
148 void box_sqrt(struct box
*box
, struct box
*sub
);
149 void box_bar(struct box
*box
);
150 void box_under(struct box
*box
);
151 void box_accent(struct box
*box
, char *c
);
152 void box_wrap(struct box
*box
, struct box
*sub
, char *left
, char *right
);
153 void box_move(struct box
*box
, int dy
, int dx
);
154 void box_gap(struct box
*box
, int n
);
155 char *box_buf(struct box
*box
);
156 char *box_toreg(struct box
*box
);
157 void box_vertspace(struct box
*box
);
158 int box_empty(struct box
*box
);
159 void box_markpos(struct box
*box
, char *regname
);
160 void box_vcenter(struct box
*box
, struct box
*sub
);
161 void box_pile(struct box
*box
, struct box
**pile
, int adj
, int rowspace
);
162 void box_matrix(struct box
*box
, int ncols
, struct box
*cols
[][NPILES
],
163 int *adj
, int colspace
, int rowspace
);
165 /* managing registers */
166 char *escarg(char *arg
);
173 char *nregname(int id
);
174 char *sregname(int id
);
175 void reg_reset(void);
177 /* eqn global variables */
178 extern int e_axisheight
;
179 extern int e_minimumsize
;
180 extern int e_overhang
;
181 extern int e_nulldelim
;
182 extern int e_scriptspace
;
183 extern int e_thinspace
;
184 extern int e_mediumspace
;
185 extern int e_thickspace
;
195 extern int e_supdrop
;
196 extern int e_subdrop
;
197 extern int e_xheight
;
198 extern int e_rulethickness
;
199 extern int e_bigopspacing1
;
200 extern int e_bigopspacing2
;
201 extern int e_bigopspacing3
;
202 extern int e_bigopspacing4
;
203 extern int e_bigopspacing5
;
204 extern int e_columnsep
;
205 extern int e_baselinesep
;
206 extern int e_bodyheight
;
207 extern int e_bodydepth
;
208 void def_set(char *name
, int val
);