home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / bool-eval / bool.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-31  |  3.7 KB  |  113 lines

  1. /* (c) copyright 1987 jim frost
  2.  * all rights reserved
  3.  *
  4.  * this program is copyrighted material.  the author gives permission
  5.  * to duplicate and redistribute this program provided the following
  6.  * conditions are met:
  7.  *   - this copyright notice is not removed.
  8.  *   - all duplicate copies or distributions contain full source
  9.  *     and documentation, including copyright notices.
  10.  *   - duplicate copies or distributions outside a single site are
  11.  *     original distributions without modifications.  (this is to keep
  12.  *     bastardized versions from showing up all over thie place.)
  13.  *
  14.  * this program source may be modified provided the following
  15.  * conditions are met:
  16.  *   - modified source is not distributed to other sites.
  17.  *   - modifications (including, but not limited to, bug fixes) are
  18.  *     sent to the author if the modifications are to be distributed.
  19.  *     no modified source is to be distributed unless done so by the
  20.  *     author.
  21.  *
  22.  * no warranty, either express or implied, is given for this program.
  23.  * the author makes no guarantees of fitness for any use of this
  24.  * program.  the author is not responsible for damages resulting from
  25.  * the use of this program for any purpose.
  26.  *
  27.  * 'site' refers to one or more computers under a single management.
  28.  * 'author' refers to the copyright holder, jim frost.
  29.  * 'source' refers to all files related to this program.
  30.  * 'documentation' refers to non-compilable files in the distribution.
  31.  *
  32.  * basically this notice is to keep me out of trouble should anything
  33.  * go wrong (i really *do* test these things though) and to make sure
  34.  * that the distribution of code is centralized.  makes bug fixes and
  35.  * enhancements much easier.
  36.  *
  37.  * thank you for your attention to this copyright notice.  if everyone
  38.  * follows this, you may find this a useful tool that is pretty well
  39.  * supported.
  40.  *
  41.  * author information:
  42.  *   jim frost                    permanent usnail address:
  43.  *   madd@bucsb.bu.edu            75 washington street
  44.  *   ..!harvard!bu-cs!bucsb!madd  laconia, nh  03246.
  45.  */
  46. /* bool.h:
  47.  *
  48.  * definition file for ttable.c
  49.  */
  50.  
  51. #include <stdio.h>
  52.  
  53. #define PROG     "bool"    /* our name */
  54. #define MAXTOKEN 32        /* maximum length of a token */
  55.  
  56. typedef struct bool_exp {
  57.   int opcode,          /* operation code/constant/token */
  58.       value;           /* token number/opcode char */
  59.   char n1,             /* unary "not" indicators */
  60.        n2;
  61.   struct bool_exp *b1, /* boolean expressions */
  62.                   *b2;
  63. } BOOL_EXP;
  64.  
  65. /*
  66.  * opcode field values
  67.  */
  68.  
  69. #define UNDEF -1 /* undefined operation */
  70. #define TRUE   0
  71. #define FALSE  1
  72. #define TOKEN  2
  73. #define OR     3
  74. #define AND    4
  75. #define XOR    5
  76.  
  77. typedef struct token_list {
  78.   char token[MAXTOKEN];    /* character representation of the token */
  79.   int  number,             /* numeric token representation */
  80.        value;              /* current value of token */
  81.   struct token_list *next; /* next token in list */
  82. } TOKEN_LIST;
  83.  
  84. typedef struct func_list {
  85.   char func[MAXTOKEN];     /* name of this function */
  86.   BOOL_EXP *bool_exp;      /* boolean expression */
  87.   struct func_list *next;  /* next function in list */
  88. } FUNC_LIST;
  89.  
  90. BOOL_EXP   *build(),
  91.            *newbnode();
  92. FUNC_LIST  *new_func();
  93. TOKEN_LIST *new_token();
  94. void       eval_file(),
  95.            eval_func(),
  96.            free_tree(),
  97.            panic(),
  98.            print_token(),
  99.            print_tree();
  100. int        begtok(),
  101.            eval_tree(),
  102.            get_token(),
  103.            intok(),
  104.            token_val();
  105. char       *malloc(),
  106.            *strcpy();
  107.  
  108. #define cget(F,C) if (!feof(F)) {\
  109.                     C= fgetc(F);\
  110.                     if ((!no_print) && (C != EOF))\
  111.                       printf("%c",C);\
  112.                   } else
  113.