home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part04 / Aux / base.c next >
Encoding:
C/C++ Source or Header  |  1987-10-14  |  754 b   |  55 lines

  1. /*
  2. **    A program to prepare a base for spell and style
  3. */
  4.  
  5. #include    <stdio.h>
  6. #include    "std.h"
  7.  
  8. typedef    struct    s_entry
  9. {
  10.     bool    reflexive;
  11.     char    *replacement;
  12. } Entry;
  13.  
  14. Entry    table[5] =    /* we use subscripts 1 to 4 */
  15. {
  16.     {    FALSE,    ""        },
  17.     {    TRUE,    "EQUATION"    },
  18.     {    FALSE,    "(REFERENCE)"    },
  19.     {    FALSE,    "PROGRAM"    },
  20.     {    FALSE,    "PICTURE"    },
  21. };
  22.  
  23. int    more = TRUE;
  24.  
  25. main()
  26. {
  27.     extern    char    yytext[];
  28.     reg    int    code;
  29.  
  30.     code = yylex();
  31.     while (more)
  32.     {
  33.         if (code <= 0)
  34.             fputs(yytext, stdout);
  35.         else
  36.         {
  37.             reg    int    oldcode;
  38.             reg    int    newcode;
  39.  
  40.             oldcode = code;
  41.             newcode = table[code].reflexive? code: -code;
  42.  
  43.             code = yylex();
  44.             while (more && code != newcode)
  45.                 code = yylex();
  46.             
  47.             printf(table[oldcode].replacement);
  48.         }
  49.  
  50.         code = yylex();
  51.     }
  52.  
  53.     exit(0);
  54. }
  55.