1259262Stijl/* $OpenBSD: expr.c,v 1.18 2010/09/07 19:58:09 marco Exp $ */
21590Srgrimes/*
3259262Stijl * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
41590Srgrimes *
5259262Stijl * Permission to use, copy, modify, and distribute this software for any
6259262Stijl * purpose with or without fee is hereby granted, provided that the above
7259262Stijl * copyright notice and this permission notice appear in all copies.
81590Srgrimes *
9259262Stijl * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10259262Stijl * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11259262Stijl * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12259262Stijl * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13259262Stijl * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14259262Stijl * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15259262Stijl * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
161590Srgrimes */
1795060Sjmallett#include <sys/cdefs.h>
1895060Sjmallett__FBSDID("$FreeBSD$");
191590Srgrimes
20259262Stijl#include <stdint.h>
21259262Stijl#include <stdio.h>
2295060Sjmallett#include <stddef.h>
2395060Sjmallett#include "mdef.h"
2495060Sjmallett#include "extern.h"
251590Srgrimes
26259262Stijlint32_t end_result;
27259262Stijlconst char *copy_toeval;
28259262Stijlint yyerror(const char *msg);
291590Srgrimes
30259262Stijlextern void yy_scan_string(const char *);
31259262Stijlextern int yyparse(void);
321590Srgrimes
331590Srgrimesint
34259262Stijlyyerror(const char *msg)
351590Srgrimes{
36259262Stijl	fprintf(stderr, "m4: %s in expr %s\n", msg, copy_toeval);
37259262Stijl	return(0);
381590Srgrimes}
391590Srgrimes
40259262Stijlint
41259262Stijlexpr(const char *toeval)
421590Srgrimes{
43259262Stijl	copy_toeval = toeval;
44259262Stijl	yy_scan_string(toeval);
45259262Stijl	yyparse();
46259262Stijl	return end_result;
471590Srgrimes}
48