1*c17ca14eSmarco /* $OpenBSD: expr.c,v 1.18 2010/09/07 19:58:09 marco Exp $ */
2df930be7Sderaadt /*
368d37339Sespie * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
4df930be7Sderaadt *
568d37339Sespie * Permission to use, copy, modify, and distribute this software for any
668d37339Sespie * purpose with or without fee is hereby granted, provided that the above
768d37339Sespie * copyright notice and this permission notice appear in all copies.
8df930be7Sderaadt *
968d37339Sespie * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1068d37339Sespie * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1168d37339Sespie * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1268d37339Sespie * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1368d37339Sespie * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1468d37339Sespie * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1568d37339Sespie * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16df930be7Sderaadt */
170b7a013eSespie #include <stdint.h>
18bb34cd6cSespie #include <stdio.h>
1968d37339Sespie #include <stddef.h>
20488b8021Sespie #include "mdef.h"
21bb34cd6cSespie #include "extern.h"
22df930be7Sderaadt
2368d37339Sespie int32_t end_result;
2468d37339Sespie const char *copy_toeval;
25df930be7Sderaadt
2668d37339Sespie extern void yy_scan_string(const char *);
2768d37339Sespie extern int yyparse(void);
28df930be7Sderaadt
29df930be7Sderaadt int
yyerror(const char * msg)3068d37339Sespie yyerror(const char *msg)
31df930be7Sderaadt {
3268d37339Sespie fprintf(stderr, "m4: %s in expr %s\n", msg, copy_toeval);
3368d37339Sespie return(0);
34df930be7Sderaadt }
35df930be7Sderaadt
3668d37339Sespie int
expr(const char * toeval)3768d37339Sespie expr(const char *toeval)
38df930be7Sderaadt {
3968d37339Sespie copy_toeval = toeval;
4068d37339Sespie yy_scan_string(toeval);
4168d37339Sespie yyparse();
4268d37339Sespie return end_result;
43df930be7Sderaadt }
44