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