You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ifparser.h 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * $XConsortium: ifparser.h,v 1.1 92/08/22 13:05:39 rws Exp $
  3. *
  4. * Copyright 1992 Network Computing Devices, Inc.
  5. *
  6. * Permission to use, copy, modify, and distribute this software and its
  7. * documentation for any purpose and without fee is hereby granted, provided
  8. * that the above copyright notice appear in all copies and that both that
  9. * copyright notice and this permission notice appear in supporting
  10. * documentation, and that the name of Network Computing Devices may not be
  11. * used in advertising or publicity pertaining to distribution of the software
  12. * without specific, written prior permission. Network Computing Devices makes
  13. * no representations about the suitability of this software for any purpose.
  14. * It is provided ``as is'' without express or implied warranty.
  15. *
  16. * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  17. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  18. * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
  19. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  20. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  21. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  22. * PERFORMANCE OF THIS SOFTWARE.
  23. *
  24. * Author: Jim Fulton
  25. * Network Computing Devices, Inc.
  26. *
  27. * Simple if statement processor
  28. *
  29. * This module can be used to evaluate string representations of C language
  30. * if constructs. It accepts the following grammar:
  31. *
  32. * EXPRESSION := VALUE
  33. * | VALUE BINOP EXPRESSION
  34. *
  35. * VALUE := '(' EXPRESSION ')'
  36. * | '!' VALUE
  37. * | '-' VALUE
  38. * | 'defined' '(' variable ')'
  39. * | variable
  40. * | number
  41. *
  42. * BINOP := '*' | '/' | '%'
  43. * | '+' | '-'
  44. * | '<<' | '>>'
  45. * | '<' | '>' | '<=' | '>='
  46. * | '==' | '!='
  47. * | '&' | '|'
  48. * | '&&' | '||'
  49. *
  50. * The normal C order of precidence is supported.
  51. *
  52. *
  53. * External Entry Points:
  54. *
  55. * ParseIfExpression parse a string for #if
  56. */
  57. #include <stdio.h>
  58. #define const /**/
  59. typedef int Bool;
  60. #define False 0
  61. #define True 1
  62. typedef struct _if_parser {
  63. struct { /* functions */
  64. char *(*handle_error) (/* struct _if_parser *, const char *,
  65. const char * */);
  66. int (*eval_variable) (/* struct _if_parser *, const char *, int */);
  67. int (*eval_defined) (/* struct _if_parser *, const char *, int */);
  68. } funcs;
  69. char *data;
  70. } IfParser;
  71. char *ParseIfExpression (/* IfParser *, const char *, int * */);