ifparser.h

Go to the documentation of this file.
00001 /*
00002  * $XConsortium: ifparser.h,v 1.1 92/08/22 13:05:39 rws Exp $
00003  *
00004  * Copyright 1992 Network Computing Devices, Inc.
00005  * 
00006  * Permission to use, copy, modify, and distribute this software and its
00007  * documentation for any purpose and without fee is hereby granted, provided
00008  * that the above copyright notice appear in all copies and that both that
00009  * copyright notice and this permission notice appear in supporting
00010  * documentation, and that the name of Network Computing Devices may not be
00011  * used in advertising or publicity pertaining to distribution of the software
00012  * without specific, written prior permission.  Network Computing Devices makes
00013  * no representations about the suitability of this software for any purpose.
00014  * It is provided ``as is'' without express or implied warranty.
00015  * 
00016  * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
00017  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
00018  * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
00019  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00020  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00021  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00022  * PERFORMANCE OF THIS SOFTWARE.
00023  * 
00024  * Author:  Jim Fulton
00025  *          Network Computing Devices, Inc.
00026  * 
00027  * Simple if statement processor
00028  *
00029  * This module can be used to evaluate string representations of C language
00030  * if constructs.  It accepts the following grammar:
00031  * 
00032  *     EXPRESSION  :=  VALUE
00033  *        |  VALUE  BINOP  EXPRESSION
00034  * 
00035  *     VALUE    :=  '('  EXPRESSION  ')'
00036  *        |  '!'  VALUE
00037  *        |  '-'  VALUE
00038  *        |  'defined'  '('  variable  ')'
00039  *        |  variable
00040  *        |  number
00041  * 
00042  *     BINOP    :=  '*'  |  '/'  |  '%'
00043  *        |  '+'  |  '-'
00044  *        |  '<<'  |  '>>'
00045  *        |  '<'  |  '>'  |  '<='  |  '>='
00046  *        |  '=='  |  '!='
00047  *        |  '&'  |  '|'
00048  *        |  '&&'  |  '||'
00049  * 
00050  * The normal C order of precidence is supported.
00051  * 
00052  * 
00053  * External Entry Points:
00054  * 
00055  *     ParseIfExpression    parse a string for #if
00056  */
00057 
00058 #include <stdio.h>
00059 
00060 struct IfParser {
00061   struct {        /* functions */
00062     const char *(*handle_error) (IfParser *, const char *, const char *);
00063     int (*eval_variable) (IfParser *, const char *, int);
00064     int (*eval_defined) (IfParser *, const char *, int);
00065   } funcs;
00066   char *data;
00067 };
00068 
00069 const char *ParseIfExpression(IfParser *, const char *, int *);
00070 

Generated on Fri Nov 28 04:28:50 2008 for HOOPLE Libraries by  doxygen 1.5.1