home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / h / lexdef.h < prev    next >
C/C++ Source or Header  |  1996-03-22  |  2KB  |  81 lines

  1. /*
  2.  * lexdef.h -- common definitions for use with the lexical analyzer.
  3.  */
  4.  
  5. /*
  6.  * Miscellaneous globals.
  7.  */
  8. extern int yychar;        /* parser's current input token type */
  9. extern int yynerrs;        /* number of errors in parse */
  10. extern int nocode;        /* true to suppress code generation */
  11.  
  12. extern int in_line;        /* current line number in input */
  13. extern int incol;        /* current column number in input */
  14. extern int peekc;        /* one character look-ahead */
  15. extern FILE *srcfile;        /* current input file */
  16.  
  17. extern int tfatals;        /* total fatal errors */
  18.  
  19. /*
  20.  * Token table structure.
  21.  */
  22.  
  23. struct toktab {
  24.    char *t_word;        /* token */
  25.    int  t_type;            /* token type returned by yylex */
  26.    int  t_flags;        /* flags for semicolon insertion */
  27.    };
  28.  
  29. #ifdef CRAY
  30. extern struct toktab toktab[35];    /* compiler bug workaround */
  31. #else                    /* CRAY */
  32. extern struct toktab toktab[];    /* token table */
  33. #endif                    /* CRAY */
  34.  
  35. extern struct toktab *restab[];    /* reserved word index */
  36.  
  37. #define T_Ident        &toktab[0]
  38. #define T_Int        &toktab[1]
  39. #define T_Real        &toktab[2]
  40. #define T_String    &toktab[3]
  41. #define T_Cset        &toktab[4]
  42. #define T_Eof        &toktab[5]
  43.  
  44. /*
  45.  * t_flags values for token table.
  46.  */
  47.  
  48. #define Beginner 1        /* token can follow a semicolon */
  49. #define Ender    2        /* token can precede a semicolon */
  50.  
  51. /*
  52.  * optab contains token information along with pointers to implementation
  53.  *  information for each operator. Special symbols are also included.
  54.  */
  55. #define Unary  1
  56. #define Binary 2
  57.  
  58. struct optab {
  59.    struct toktab tok;        /* token information for the operator symbol */
  60.    int expected;         /* what is expected in data base: Unary/Binary */
  61.    struct implement *unary;  /* data base entry for unary version */
  62.    struct implement *binary; /* data base entry for binary version */
  63.    };
  64.  
  65. extern struct optab optab[]; /* operator table */
  66. extern int asgn_loc;         /* index in optab of assignment */
  67. extern int semicol_loc;      /* index in optab of semicolon */
  68. extern int plus_loc;         /* index in optab of addition */
  69. extern int minus_loc;        /* index in optab of subtraction */
  70.  
  71. /*
  72.  * Miscellaneous.
  73.  */
  74.  
  75. #define isoctal(c) ((c)>='0'&&(c)<='7')    /* macro to test for octal digit */
  76. #define NextChar   nextchar()        /* macro to get next character */
  77. #define PushChar(c) peekc=(c)        /* macro to push back a character */
  78.  
  79. #define Comment '#'            /* comment beginner */
  80. #define Escape  '\\'            /* string literal escape character */
  81.