home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 319_01 / enum.h < prev    next >
Text File  |  1990-06-18  |  3KB  |  124 lines

  1. /*
  2.     CPP V5 -- Header file for all enumerations.
  3.  
  4.     source:  enum.h
  5.     started: June 20, 1986
  6.     version: December 12, 1987; January 19, 1988
  7.  
  8.     Written by Edward K. Ream.
  9.     This software is in the public domain.
  10.  
  11.     See the read.me file for disclaimer and other information.
  12. */
  13.  
  14. /*
  15.     ----------    PARSING    ----------
  16. */
  17.  
  18. /*
  19.     Input Codes and Internal Operator Codes:
  20.     Type fields of parse nodes.
  21. */
  22. typedef enum /* en_tokens */ { NULL_TOK, ERR_TOK,
  23.  
  24. /*    start of key subenum.                */
  25. /*    kdecl subenum.                    */
  26.  
  27. K_AUTO,  K_CHAR, K_CONST, K_DOUBLE,  K_EXTERN,
  28. K_FLOAT, K_INT, K_LONG, K_REGISTER, K_SHORT,
  29. K_STATIC, K_TYPEDEF, K_SIGNED, K_STRUCT, K_UNION,
  30. K_UNSIGNED, K_VOID, K_VOLATILE,
  31.  
  32. /*    kcontrol subenum.                */
  33.  
  34. K_BREAK, K_CASE,
  35. K_CONTINUE, K_DEFAULT, K_DO, K_ELSE, K_ENUM, K_FOR,
  36. K_GOTO, K_IF, K_RETURN, K_SWITCH, K_WHILE,
  37.  
  38. /*    Remainder of key subenum.            */
  39.  
  40. K_ENTRY, K_SIZEOF,
  41.  
  42. /*    Separator and grouping tokens.            */
  43. /*    Start of is_op subenum.                */
  44.  
  45. SEPARATOR_TOK, NL_TOK,
  46. SEMICOLON_TOK, LBRACK_TOK, LCURLY_TOK, LPAREN_TOK, RBRACK_TOK,
  47. RCURLY_TOK, RPAREN_TOK,
  48.  
  49. /*    is_ternop.                    */
  50.  
  51. COLON_TOK, QUESTION_TOK,
  52.  
  53. /*    Start of is_binop enum.                */
  54.  
  55. ARRAY_TOK, ARROW_TOK, DOT_TOK, LAND_TOK, LOR_TOK, COMMA_TOK,
  56.  
  57. /*    is_assnop subenum.                */
  58.  
  59. ASSN_TOK,
  60. AND_ASSN_TOK, DIV_ASSN_TOK, LSHIFT_ASSN_TOK, MINUS_ASSN_TOK, MOD_ASSN_TOK,
  61. OR_ASSN_TOK, PLUS_ASSN_TOK, RSHIFT_ASSN_TOK, STAR_ASSN_TOK, XOR_ASSN_TOK,
  62.  
  63. /*    is_aop, is_abelian  subenum.            */
  64.  
  65. AND_TOK, OR_TOK, PLUS_TOK, STAR_TOK, XOR_TOK,
  66.  
  67. DIV_TOK, LSHIFT_TOK, MINUS_TOK, MOD_TOK, RSHIFT_TOK,
  68.  
  69. /*     end of is_aop.                    */
  70.  
  71. /*    is_relop subenum.                */
  72. /*    Final entries of is_binop subenum.        */
  73.  
  74. EQUAL_TOK, GE_TOK, GT_TOK, LE_TOK, LT_TOK, NE_TOK,
  75.  
  76. /*    Unary operators returned by get_token().    */
  77.  
  78. DEC_TOK, INC_TOK,
  79.  
  80. /*    Start of is_unop subenum.            */
  81.  
  82. NOT_TOK, TILDE_TOK,
  83.  
  84. /*    Unary operators created by expr().        */
  85. /*    End of is_unop subenum.                */
  86.  
  87. CAST_TOK, POST_DEC_TOK, POST_INC_TOK, PRE_DEC_TOK, PRE_INC_TOK,
  88.  
  89. /*    Artificial unary operators; also is_unop    */
  90.  
  91. UAND_TOK, UMINUS_TOK, UPLUS_TOK, USTAR_TOK,
  92.  
  93. /*    Operators with variable operand count        */
  94. /*    Final entries in is_op subenum.            */
  95.  
  96. CALL_TOK,
  97.  
  98. /*    Class tokens.                    */
  99.  
  100. CHAR_TOK, EOP_TOK, ID_TOK, INT_TOK, FLOAT_TOK, LONG_TOK, STRING_TOK,
  101.  
  102. /*    Miscellaneous tokens            */
  103.  
  104. DOTS3, LABEL_TOK
  105.  
  106. } en_tokens;
  107.  
  108. /*
  109.     Most of the unary operators are specials generated in the parser.
  110.     Only NOT_TOK and TILDE_TOK are unambiguously unary.
  111. */
  112. #define is_kdecl(n)    (n >= K_AUTO    && n <= K_VOLATILE)
  113. #define is_kcontrol(n)    (n >= K_BREAK    && n <= K_WHILE)
  114. #define is_key(n)    (n >= K_AUTO    && n <= K_SIZEOF)
  115.  
  116. #define is_op(n)    (n >= SEPARATOR_TOK    && n <= CALL_TOK)
  117. #define is_binop(n)    (n >= ARRAY_TOK    && n <= NE_TOK)
  118. #define is_assnop(n)    (n >= ASSN_TOK    && n <= XOR_ASSN_TOK)
  119. #define is_abelian(n)    (n >= AND_TOK    && n <= XOR_TOK)
  120. #define is_aop(n)    (n >= AND_TOK    && n <= RSHIFT_TOK)
  121. #define is_relop(n)    (n >= EQUAL_TOK    && n <= NE_TOK)
  122. #define is_unop(n)    (n >= NOT_TOK    && n <= USTAR_TOK)
  123. #define is_argop(n)    (n >= COLON_TOK && n <= CALL_TOK)
  124.