michael@0: /* michael@0: * $Xorg: ifparser.h,v 1.3 2000/08/17 19:41:51 cpqbld Exp $ michael@0: * michael@0: * Copyright 1992 Network Computing Devices, Inc. michael@0: * michael@0: * Permission to use, copy, modify, and distribute this software and its michael@0: * documentation for any purpose and without fee is hereby granted, provided michael@0: * that the above copyright notice appear in all copies and that both that michael@0: * copyright notice and this permission notice appear in supporting michael@0: * documentation, and that the name of Network Computing Devices may not be michael@0: * used in advertising or publicity pertaining to distribution of the software michael@0: * without specific, written prior permission. Network Computing Devices makes michael@0: * no representations about the suitability of this software for any purpose. michael@0: * It is provided ``as is'' without express or implied warranty. michael@0: * michael@0: * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS michael@0: * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, michael@0: * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL, michael@0: * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM michael@0: * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE michael@0: * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR michael@0: * PERFORMANCE OF THIS SOFTWARE. michael@0: * michael@0: * Author: Jim Fulton michael@0: * Network Computing Devices, Inc. michael@0: * michael@0: * Simple if statement processor michael@0: * michael@0: * This module can be used to evaluate string representations of C language michael@0: * if constructs. It accepts the following grammar: michael@0: * michael@0: * EXPRESSION := VALUE michael@0: * | VALUE BINOP EXPRESSION michael@0: * | VALUE '?' EXPRESSION ':' EXPRESSION michael@0: * michael@0: * VALUE := '(' EXPRESSION ')' michael@0: * | '!' VALUE michael@0: * | '-' VALUE michael@0: * | '~' VALUE michael@0: * | 'defined' '(' variable ')' michael@0: * | variable michael@0: * | number michael@0: * michael@0: * BINOP := '*' | '/' | '%' michael@0: * | '+' | '-' michael@0: * | '<<' | '>>' michael@0: * | '<' | '>' | '<=' | '>=' michael@0: * | '==' | '!=' michael@0: * | '&' | '^' | '|' michael@0: * | '&&' | '||' michael@0: * michael@0: * The normal C order of precedence is supported. michael@0: * michael@0: * michael@0: * External Entry Points: michael@0: * michael@0: * ParseIfExpression parse a string for #if michael@0: */ michael@0: michael@0: /* $XFree86: xc/config/makedepend/ifparser.h,v 3.5 2001/07/25 15:04:40 dawes Exp $ */ michael@0: michael@0: #include michael@0: michael@0: typedef int Bool; michael@0: #define False 0 michael@0: #define True 1 michael@0: michael@0: typedef struct _if_parser { michael@0: struct { /* functions */ michael@0: const char *(*handle_error) (struct _if_parser *, const char *, michael@0: const char *); michael@0: long (*eval_variable) (struct _if_parser *, const char *, int); michael@0: int (*eval_defined) (struct _if_parser *, const char *, int); michael@0: } funcs; michael@0: char *data; michael@0: } IfParser; michael@0: michael@0: const char *ParseIfExpression ( michael@0: IfParser *, michael@0: const char *, michael@0: long * michael@0: ); michael@0: