ag-char-map.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Character mapping generated 08/08/09 10:14:55
  3. *
  4. * This file contains the character classifications
  5. * used by AutoGen and AutoOpts for identifying tokens.
  6. */
  7. #ifndef AG_CHAR_MAP_H_GUARD
  8. #define AG_CHAR_MAP_H_GUARD 1
  9. #ifdef HAVE_CONFIG_H
  10. # if defined(HAVE_INTTYPES_H)
  11. # include <inttypes.h>
  12. # elif defined(HAVE_STDINT_H)
  13. # include <stdint.h>
  14. # else
  15. # ifndef HAVE_INT8_T
  16. typedef signed char int8_t;
  17. # endif
  18. # ifndef HAVE_UINT8_T
  19. typedef unsigned char uint8_t;
  20. # endif
  21. # ifndef HAVE_INT16_T
  22. typedef signed short int16_t;
  23. # endif
  24. # ifndef HAVE_UINT16_T
  25. typedef unsigned short uint16_t;
  26. # endif
  27. # ifndef HAVE_UINT_T
  28. typedef unsigned int uint_t;
  29. # endif
  30. # ifndef HAVE_INT32_T
  31. # if SIZEOF_INT == 4
  32. typedef signed int int32_t;
  33. # elif SIZEOF_LONG == 4
  34. typedef signed long int32_t;
  35. # endif
  36. # endif
  37. # ifndef HAVE_UINT32_T
  38. # if SIZEOF_INT == 4
  39. typedef unsigned int uint32_t;
  40. # elif SIZEOF_LONG == 4
  41. typedef unsigned long uint32_t;
  42. # endif
  43. # endif
  44. # endif /* HAVE_*INT*_H header */
  45. #else /* not HAVE_CONFIG_H -- */
  46. # ifdef __sun
  47. # include <inttypes.h>
  48. # else
  49. # include <stdint.h>
  50. # endif
  51. #endif /* HAVE_CONFIG_H */
  52. #if 0 /* mapping specification source (from autogen.map) */
  53. //
  54. // %guard autoopts_internal
  55. // %file ag-char-map.h
  56. // %table opt-char-cat
  57. //
  58. // %comment
  59. // This file contains the character classifications
  60. // used by AutoGen and AutoOpts for identifying tokens.
  61. // %
  62. //
  63. // lower-case "a-z"
  64. // upper-case "A-Z"
  65. // alphabetic +lower-case +upper-case
  66. // oct-digit "0-7"
  67. // dec-digit "89" +oct-digit
  68. // hex-digit "a-fA-F" +dec-digit
  69. // alphanumeric +alphabetic +dec-digit
  70. // var-first "_" +alphabetic
  71. // variable-name +var-first +dec-digit
  72. // option-name "^-" +variable-name
  73. // value-name ":" +option-name
  74. // horiz-white "\t "
  75. // compound-name "[.]" +value-name +horiz-white
  76. // whitespace "\v\f\r\n\b" +horiz-white
  77. // unquotable "!-~" -"\"#(),;<=>[\\]`{}?*'"
  78. // end-xml-token "/>" +whitespace
  79. // graphic "!-~"
  80. // plus-n-space "+" +whitespace
  81. // punctuation "!-~" -alphanumeric -"_"
  82. // suffix "-._" +alphanumeric
  83. // suffix-fmt "%/" +suffix
  84. // false-type "nNfF0\x00"
  85. //
  86. #endif /* 0 -- mapping spec. source */
  87. typedef uint32_t opt_char_cat_mask_t;
  88. extern opt_char_cat_mask_t const opt_char_cat[128];
  89. static inline int is_opt_char_cat_char(char ch, opt_char_cat_mask_t mask) {
  90. unsigned int ix = (unsigned char)ch;
  91. return ((ix < 0x7F) && ((opt_char_cat[ix] & mask) != 0)); }
  92. #define IS_LOWER_CASE_CHAR(_c) is_opt_char_cat_char((_c), 0x00001)
  93. #define IS_UPPER_CASE_CHAR(_c) is_opt_char_cat_char((_c), 0x00002)
  94. #define IS_ALPHABETIC_CHAR(_c) is_opt_char_cat_char((_c), 0x00003)
  95. #define IS_OCT_DIGIT_CHAR(_c) is_opt_char_cat_char((_c), 0x00004)
  96. #define IS_DEC_DIGIT_CHAR(_c) is_opt_char_cat_char((_c), 0x0000C)
  97. #define IS_HEX_DIGIT_CHAR(_c) is_opt_char_cat_char((_c), 0x0001C)
  98. #define IS_ALPHANUMERIC_CHAR(_c) is_opt_char_cat_char((_c), 0x0000F)
  99. #define IS_VAR_FIRST_CHAR(_c) is_opt_char_cat_char((_c), 0x00023)
  100. #define IS_VARIABLE_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x0002F)
  101. #define IS_OPTION_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x0006F)
  102. #define IS_VALUE_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x000EF)
  103. #define IS_HORIZ_WHITE_CHAR(_c) is_opt_char_cat_char((_c), 0x00100)
  104. #define IS_COMPOUND_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x003EF)
  105. #define IS_WHITESPACE_CHAR(_c) is_opt_char_cat_char((_c), 0x00500)
  106. #define IS_UNQUOTABLE_CHAR(_c) is_opt_char_cat_char((_c), 0x00800)
  107. #define IS_END_XML_TOKEN_CHAR(_c) is_opt_char_cat_char((_c), 0x01500)
  108. #define IS_GRAPHIC_CHAR(_c) is_opt_char_cat_char((_c), 0x02000)
  109. #define IS_PLUS_N_SPACE_CHAR(_c) is_opt_char_cat_char((_c), 0x04500)
  110. #define IS_PUNCTUATION_CHAR(_c) is_opt_char_cat_char((_c), 0x08000)
  111. #define IS_SUFFIX_CHAR(_c) is_opt_char_cat_char((_c), 0x1000F)
  112. #define IS_SUFFIX_FMT_CHAR(_c) is_opt_char_cat_char((_c), 0x3000F)
  113. #define IS_FALSE_TYPE_CHAR(_c) is_opt_char_cat_char((_c), 0x40000)
  114. #ifdef AUTOOPTS_INTERNAL
  115. opt_char_cat_mask_t const opt_char_cat[128] = {
  116. /*x00*/ 0x40000, /*x01*/ 0x00000, /*x02*/ 0x00000, /*x03*/ 0x00000,
  117. /*x04*/ 0x00000, /*x05*/ 0x00000, /*x06*/ 0x00000, /*\a */ 0x00000,
  118. /*\b */ 0x00400, /*\t */ 0x00100, /*\n */ 0x00400, /*\v */ 0x00400,
  119. /*\f */ 0x00400, /*\r */ 0x00400, /*x0E*/ 0x00000, /*x0F*/ 0x00000,
  120. /*x10*/ 0x00000, /*x11*/ 0x00000, /*x12*/ 0x00000, /*x13*/ 0x00000,
  121. /*x14*/ 0x00000, /*x15*/ 0x00000, /*x16*/ 0x00000, /*x17*/ 0x00000,
  122. /*x18*/ 0x00000, /*x19*/ 0x00000, /*x1A*/ 0x00000, /*x1B*/ 0x00000,
  123. /*x1C*/ 0x00000, /*x1D*/ 0x00000, /*x1E*/ 0x00000, /*x1F*/ 0x00000,
  124. /* */ 0x00100, /* ! */ 0x0A800, /* " */ 0x0A000, /* # */ 0x0A000,
  125. /* $ */ 0x0A800, /* % */ 0x2A800, /* & */ 0x0A800, /* ' */ 0x0A000,
  126. /* ( */ 0x0A000, /* ) */ 0x0A000, /* * */ 0x0A000, /* + */ 0x0E800,
  127. /* , */ 0x0A000, /* - */ 0x1A840, /* . */ 0x1AA00, /* / */ 0x2B800,
  128. /* 0 */ 0x42804, /* 1 */ 0x02804, /* 2 */ 0x02804, /* 3 */ 0x02804,
  129. /* 4 */ 0x02804, /* 5 */ 0x02804, /* 6 */ 0x02804, /* 7 */ 0x02804,
  130. /* 8 */ 0x02808, /* 9 */ 0x02808, /* : */ 0x0A880, /* ; */ 0x0A000,
  131. /* < */ 0x0A000, /* = */ 0x0A000, /* > */ 0x0B000, /* ? */ 0x0A000,
  132. /* @ */ 0x0A800, /* A */ 0x02812, /* B */ 0x02812, /* C */ 0x02812,
  133. /* D */ 0x02812, /* E */ 0x02812, /* F */ 0x42812, /* G */ 0x02802,
  134. /* H */ 0x02802, /* I */ 0x02802, /* J */ 0x02802, /* K */ 0x02802,
  135. /* L */ 0x02802, /* M */ 0x02802, /* N */ 0x42802, /* O */ 0x02802,
  136. /* P */ 0x02802, /* Q */ 0x02802, /* R */ 0x02802, /* S */ 0x02802,
  137. /* T */ 0x02802, /* U */ 0x02802, /* V */ 0x02802, /* W */ 0x02802,
  138. /* X */ 0x02802, /* Y */ 0x02802, /* Z */ 0x02802, /* [ */ 0x0A200,
  139. /* \ */ 0x0A000, /* ] */ 0x0A200, /* ^ */ 0x0A840, /* _ */ 0x12820,
  140. /* ` */ 0x0A000, /* a */ 0x02811, /* b */ 0x02811, /* c */ 0x02811,
  141. /* d */ 0x02811, /* e */ 0x02811, /* f */ 0x42811, /* g */ 0x02801,
  142. /* h */ 0x02801, /* i */ 0x02801, /* j */ 0x02801, /* k */ 0x02801,
  143. /* l */ 0x02801, /* m */ 0x02801, /* n */ 0x42801, /* o */ 0x02801,
  144. /* p */ 0x02801, /* q */ 0x02801, /* r */ 0x02801, /* s */ 0x02801,
  145. /* t */ 0x02801, /* u */ 0x02801, /* v */ 0x02801, /* w */ 0x02801,
  146. /* x */ 0x02801, /* y */ 0x02801, /* z */ 0x02801, /* { */ 0x0A000,
  147. /* | */ 0x0A800, /* } */ 0x0A000, /* ~ */ 0x0A800, /*x7F*/ 0x00000
  148. };
  149. #endif /* AUTOOPTS_INTERNAL */
  150. #endif /* AG_CHAR_MAP_H_GUARD */