1228063Sbapt/* $OpenBSD: expr.c,v 1.18 2010/09/07 19:58:09 marco Exp $ */ 21590Srgrimes/* 3228063Sbapt * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org> 41590Srgrimes * 5228063Sbapt * Permission to use, copy, modify, and distribute this software for any 6228063Sbapt * purpose with or without fee is hereby granted, provided that the above 7228063Sbapt * copyright notice and this permission notice appear in all copies. 81590Srgrimes * 9228063Sbapt * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10228063Sbapt * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11228063Sbapt * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12228063Sbapt * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13228063Sbapt * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14228063Sbapt * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15228063Sbapt * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 161590Srgrimes */ 1795060Sjmallett#include <sys/cdefs.h> 1895060Sjmallett__FBSDID("$FreeBSD$"); 191590Srgrimes 20228063Sbapt#include <stdint.h> 21228063Sbapt#include <stdio.h> 2295060Sjmallett#include <stddef.h> 2395060Sjmallett#include "mdef.h" 2495060Sjmallett#include "extern.h" 251590Srgrimes 26228063Sbaptint32_t end_result; 27241777Sedstatic const char *copy_toeval; 28228063Sbaptint yyerror(const char *msg); 291590Srgrimes 30228063Sbaptextern void yy_scan_string(const char *); 31228063Sbaptextern int yyparse(void); 321590Srgrimes 331590Srgrimesint 34228063Sbaptyyerror(const char *msg) 351590Srgrimes{ 36228063Sbapt fprintf(stderr, "m4: %s in expr %s\n", msg, copy_toeval); 37228063Sbapt return(0); 381590Srgrimes} 391590Srgrimes 40228063Sbaptint 41228063Sbaptexpr(const char *toeval) 421590Srgrimes{ 43228063Sbapt copy_toeval = toeval; 44228063Sbapt yy_scan_string(toeval); 45228063Sbapt yyparse(); 46228063Sbapt return end_result; 471590Srgrimes} 48