xref: /netbsd-src/external/bsd/mdocml/dist/eqn_parse.h (revision 544c191c349c1704c9d5e679d12ec15cff579663)
1*544c191cSchristos /*	Id: eqn_parse.h,v 1.3 2018/12/14 06:33:14 schwarze Exp  */
2*544c191cSchristos /*
3*544c191cSchristos  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4*544c191cSchristos  * Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
5*544c191cSchristos  *
6*544c191cSchristos  * Permission to use, copy, modify, and distribute this software for any
7*544c191cSchristos  * purpose with or without fee is hereby granted, provided that the above
8*544c191cSchristos  * copyright notice and this permission notice appear in all copies.
9*544c191cSchristos  *
10*544c191cSchristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11*544c191cSchristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*544c191cSchristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13*544c191cSchristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*544c191cSchristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*544c191cSchristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*544c191cSchristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*544c191cSchristos  *
18*544c191cSchristos  * External interface of the eqn(7) parser.
19*544c191cSchristos  * For use in the roff(7) and eqn(7) parsers only.
20*544c191cSchristos  */
21*544c191cSchristos 
22*544c191cSchristos struct roff_node;
23*544c191cSchristos struct eqn_box;
24*544c191cSchristos struct eqn_def;
25*544c191cSchristos 
26*544c191cSchristos struct	eqn_node {
27*544c191cSchristos 	struct roff_node *node;    /* Syntax tree of this equation. */
28*544c191cSchristos 	struct eqn_def	 *defs;    /* Array of definitions. */
29*544c191cSchristos 	char		 *data;    /* Source code of this equation. */
30*544c191cSchristos 	char		 *start;   /* First byte of the current token. */
31*544c191cSchristos 	char		 *end;	   /* First byte of the next token. */
32*544c191cSchristos 	size_t		  defsz;   /* Number of definitions. */
33*544c191cSchristos 	size_t		  sz;      /* Length of the source code. */
34*544c191cSchristos 	size_t		  toksz;   /* Length of the current token. */
35*544c191cSchristos 	int		  gsize;   /* Default point size. */
36*544c191cSchristos 	int		  delim;   /* In-line delimiters enabled. */
37*544c191cSchristos 	char		  odelim;  /* In-line opening delimiter. */
38*544c191cSchristos 	char		  cdelim;  /* In-line closing delimiter. */
39*544c191cSchristos };
40*544c191cSchristos 
41*544c191cSchristos 
42*544c191cSchristos struct eqn_node	*eqn_alloc(void);
43*544c191cSchristos struct eqn_box	*eqn_box_new(void);
44*544c191cSchristos void		 eqn_box_free(struct eqn_box *);
45*544c191cSchristos void		 eqn_free(struct eqn_node *);
46*544c191cSchristos void		 eqn_parse(struct eqn_node *);
47*544c191cSchristos void		 eqn_read(struct eqn_node *, const char *);
48*544c191cSchristos void		 eqn_reset(struct eqn_node *);
49