xref: /freebsd/contrib/mandoc/eqn_parse.h (revision c1c95add8c80843ba15d784f95c361d795b1f593)
1*c1c95addSBrooks Davis /* $Id: eqn_parse.h,v 1.4 2022/04/13 20:26:19 schwarze Exp $ */
27295610fSBaptiste Daroussin /*
3*c1c95addSBrooks Davis  * Copyright (c) 2014, 2017, 2018, 2022 Ingo Schwarze <schwarze@openbsd.org>
47295610fSBaptiste Daroussin  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
57295610fSBaptiste Daroussin  *
67295610fSBaptiste Daroussin  * Permission to use, copy, modify, and distribute this software for any
77295610fSBaptiste Daroussin  * purpose with or without fee is hereby granted, provided that the above
87295610fSBaptiste Daroussin  * copyright notice and this permission notice appear in all copies.
97295610fSBaptiste Daroussin  *
107295610fSBaptiste Daroussin  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
117295610fSBaptiste Daroussin  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
127295610fSBaptiste Daroussin  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
137295610fSBaptiste Daroussin  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
147295610fSBaptiste Daroussin  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
157295610fSBaptiste Daroussin  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
167295610fSBaptiste Daroussin  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
177295610fSBaptiste Daroussin  *
187295610fSBaptiste Daroussin  * External interface of the eqn(7) parser.
197295610fSBaptiste Daroussin  * For use in the roff(7) and eqn(7) parsers only.
207295610fSBaptiste Daroussin  */
217295610fSBaptiste Daroussin 
227295610fSBaptiste Daroussin struct roff_node;
237295610fSBaptiste Daroussin struct eqn_box;
247295610fSBaptiste Daroussin struct eqn_def;
257295610fSBaptiste Daroussin 
267295610fSBaptiste Daroussin struct	eqn_node {
277295610fSBaptiste Daroussin 	struct roff_node *node;    /* Syntax tree of this equation. */
287295610fSBaptiste Daroussin 	struct eqn_def	 *defs;    /* Array of definitions. */
297295610fSBaptiste Daroussin 	char		 *data;    /* Source code of this equation. */
307295610fSBaptiste Daroussin 	char		 *start;   /* First byte of the current token. */
317295610fSBaptiste Daroussin 	char		 *end;	   /* First byte of the next token. */
327295610fSBaptiste Daroussin 	size_t		  defsz;   /* Number of definitions. */
337295610fSBaptiste Daroussin 	size_t		  sz;      /* Length of the source code. */
347295610fSBaptiste Daroussin 	size_t		  toksz;   /* Length of the current token. */
35*c1c95addSBrooks Davis 	int		  sublen;  /* End of rightmost substitution, so far. */
36*c1c95addSBrooks Davis 	int		  subcnt;  /* Number of recursive substitutions. */
377295610fSBaptiste Daroussin 	int		  gsize;   /* Default point size. */
387295610fSBaptiste Daroussin 	int		  delim;   /* In-line delimiters enabled. */
397295610fSBaptiste Daroussin 	char		  odelim;  /* In-line opening delimiter. */
407295610fSBaptiste Daroussin 	char		  cdelim;  /* In-line closing delimiter. */
417295610fSBaptiste Daroussin };
427295610fSBaptiste Daroussin 
437295610fSBaptiste Daroussin 
447295610fSBaptiste Daroussin struct eqn_node	*eqn_alloc(void);
457295610fSBaptiste Daroussin struct eqn_box	*eqn_box_new(void);
467295610fSBaptiste Daroussin void		 eqn_box_free(struct eqn_box *);
477295610fSBaptiste Daroussin void		 eqn_free(struct eqn_node *);
487295610fSBaptiste Daroussin void		 eqn_parse(struct eqn_node *);
497295610fSBaptiste Daroussin void		 eqn_read(struct eqn_node *, const char *);
507295610fSBaptiste Daroussin void		 eqn_reset(struct eqn_node *);
51