File indexing completed on 2018-03-02 18:44:43 UTC
view on githubraw file Latest commit bf5846c3 on 2004-02-25 18:19:54 UTC
bf5846c3a1 Ed H*0001 /*
0002 * $XConsortium: ifparser.h,v 1.1 92/08/22 13:05:39 rws Exp $
0003 * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
0004 *
0005 * Redistribution and use in source and binary forms, with or without
0006 * modification, are permitted provided that the following conditions
0007 * are met:
0008 *
0009 * 1. Redistributions of source code must retain the above copyright
0010 * notice, this list of conditions and the following disclaimer.
0011 *
0012 * 2. Redistributions in binary form must reproduce the above copyright
0013 * notice, this list of conditions and the following disclaimer in
0014 * the documentation and/or other materials provided with the
0015 * distribution.
0016 *
0017 * 3. The name "Carnegie Mellon University" must not be used to
0018 * endorse or promote products derived from this software without
0019 * prior written permission. For permission or any other legal
0020 * details, please contact
0021 * Office of Technology Transfer
0022 * Carnegie Mellon University
0023 * 5000 Forbes Avenue
0024 * Pittsburgh, PA 15213-3890
0025 * (412) 268-4387, fax: (412) 268-7395
0026 * tech-transfer@andrew.cmu.edu
0027 *
0028 * 4. Redistributions of any form whatsoever must retain the following
0029 * acknowledgment:
0030 * "This product includes software developed by Computing Services
0031 * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
0032 *
0033 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
0034 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
0035 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
0036 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0037 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
0038 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
0039 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0040 *
0041 *
0042 * Copyright 1992 Network Computing Devices, Inc.
0043 *
0044 * Permission to use, copy, modify, and distribute this software and its
0045 * documentation for any purpose and without fee is hereby granted, provided
0046 * that the above copyright notice appear in all copies and that both that
0047 * copyright notice and this permission notice appear in supporting
0048 * documentation, and that the name of Network Computing Devices may not be
0049 * used in advertising or publicity pertaining to distribution of the software
0050 * without specific, written prior permission. Network Computing Devices makes
0051 * no representations about the suitability of this software for any purpose.
0052 * It is provided ``as is'' without express or implied warranty.
0053 *
0054 * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
0055 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
0056 * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
0057 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
0058 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
0059 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
0060 * PERFORMANCE OF THIS SOFTWARE.
0061 *
0062 * Author: Jim Fulton
0063 * Network Computing Devices, Inc.
0064 *
0065 * Simple if statement processor
0066 *
0067 * This module can be used to evaluate string representations of C language
0068 * if constructs. It accepts the following grammar:
0069 *
0070 * EXPRESSION := VALUE
0071 * | VALUE BINOP EXPRESSION
0072 *
0073 * VALUE := '(' EXPRESSION ')'
0074 * | '!' VALUE
0075 * | '-' VALUE
0076 * | 'defined' '(' variable ')'
0077 * | variable
0078 * | number
0079 *
0080 * BINOP := '*' | '/' | '%'
0081 * | '+' | '-'
0082 * | '<<' | '>>'
0083 * | '<' | '>' | '<=' | '>='
0084 * | '==' | '!='
0085 * | '&' | '|'
0086 * | '&&' | '||'
0087 *
0088 * The normal C order of precidence is supported.
0089 *
0090 *
0091 * External Entry Points:
0092 *
0093 * ParseIfExpression parse a string for #if
0094 */
0095
0096 #include <stdio.h>
0097
0098 #define const /**/
0099 typedef int Bool;
0100 #define False 0
0101 #define True 1
0102
0103 typedef struct _if_parser {
0104 struct { /* functions */
0105 char *(*handle_error) (/* struct _if_parser *, const char *,
0106 const char * */);
0107 int (*eval_variable) (/* struct _if_parser *, const char *, int */);
0108 int (*eval_defined) (/* struct _if_parser *, const char *, int */);
0109 } funcs;
0110 char *data;
0111 } IfParser;
0112
0113
0114