home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / h / lexdef.h < prev    next >
C/C++ Source or Header  |  2002-01-18  |  2KB  |  76 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. extern struct toktab toktab[];    /* token table */
  30. extern struct toktab *restab[];    /* reserved word index */
  31.  
  32. #define T_Ident        &toktab[0]
  33. #define T_Int        &toktab[1]
  34. #define T_Real        &toktab[2]
  35. #define T_String    &toktab[3]
  36. #define T_Cset        &toktab[4]
  37. #define T_Eof        &toktab[5]
  38.  
  39. /*
  40.  * t_flags values for token table.
  41.  */
  42.  
  43. #define Beginner 1        /* token can follow a semicolon */
  44. #define Ender    2        /* token can precede a semicolon */
  45.  
  46. /*
  47.  * optab contains token information along with pointers to implementation
  48.  *  information for each operator. Special symbols are also included.
  49.  */
  50. #define Unary  1
  51. #define Binary 2
  52.  
  53. struct optab {
  54.    struct toktab tok;        /* token information for the operator symbol */
  55.    int expected;         /* what is expected in data base: Unary/Binary */
  56.    struct implement *unary;  /* data base entry for unary version */
  57.    struct implement *binary; /* data base entry for binary version */
  58.    };
  59.  
  60. extern struct optab optab[]; /* operator table */
  61. extern int asgn_loc;         /* index in optab of assignment */
  62. extern int semicol_loc;      /* index in optab of semicolon */
  63. extern int plus_loc;         /* index in optab of addition */
  64. extern int minus_loc;        /* index in optab of subtraction */
  65.  
  66. /*
  67.  * Miscellaneous.
  68.  */
  69.  
  70. #define isoctal(c) ((c)>='0'&&(c)<='7')    /* macro to test for octal digit */
  71. #define NextChar   nextchar()        /* macro to get next character */
  72. #define PushChar(c) peekc=(c)        /* macro to push back a character */
  73.  
  74. #define Comment '#'            /* comment beginner */
  75. #define Escape  '\\'            /* string literal escape character */
  76.