1*67d9f38eSkre /* $NetBSD: expr.c,v 1.21 2019/03/26 23:31:45 kre Exp $ */
2f3efdb75Schristos /* $OpenBSD: expr.c,v 1.17 2006/01/20 23:10:19 espie Exp $ */
3a7c89f0fSglass /*
4f3efdb75Schristos * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
5a7c89f0fSglass *
6f3efdb75Schristos * Permission to use, copy, modify, and distribute this software for any
7f3efdb75Schristos * purpose with or without fee is hereby granted, provided that the above
8f3efdb75Schristos * copyright notice and this permission notice appear in all copies.
9a7c89f0fSglass *
10f3efdb75Schristos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11f3efdb75Schristos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12f3efdb75Schristos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13f3efdb75Schristos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14f3efdb75Schristos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15f3efdb75Schristos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16f3efdb75Schristos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1761f28255Scgd */
18b2f78261Sjmc #if HAVE_NBTOOL_CONFIG_H
19b2f78261Sjmc #include "nbtool_config.h"
20b2f78261Sjmc #endif
216f9ec05aSlukem #include <sys/cdefs.h>
22*67d9f38eSkre __RCSID("$NetBSD: expr.c,v 1.21 2019/03/26 23:31:45 kre Exp $");
23f3efdb75Schristos #include <stdint.h>
244b087712Stv #include <stdio.h>
25f3efdb75Schristos #include <stddef.h>
266f9ec05aSlukem #include "mdef.h"
276f9ec05aSlukem #include "extern.h"
286f9ec05aSlukem
29f3efdb75Schristos int32_t end_result;
30f3efdb75Schristos const char *copy_toeval;
31a7c89f0fSglass
32f3efdb75Schristos extern void yy_scan_string(const char *);
33f3efdb75Schristos extern int yyparse(void);
34f3efdb75Schristos extern int yyerror(const char *);
3561f28255Scgd
36a7c89f0fSglass int
yyerror(const char * msg)37f3efdb75Schristos yyerror(const char *msg)
380d66213fSglass {
39*67d9f38eSkre fprintf(stderr, "m4:%s:%lu: %s in expr %s\n", infile[ilevel].name,
405eea377eSchristos infile[ilevel].lineno, msg, copy_toeval);
41f3efdb75Schristos return(0);
420d66213fSglass }
430d66213fSglass
44f3efdb75Schristos int
expr(const char * toeval)45f3efdb75Schristos expr(const char *toeval)
46a7c89f0fSglass {
47f3efdb75Schristos copy_toeval = toeval;
48f3efdb75Schristos yy_scan_string(toeval);
49f3efdb75Schristos yyparse();
50f3efdb75Schristos return end_result;
51a7c89f0fSglass }
52