File indexing completed on 2025-01-19 09:47:48
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_SPIRIT_ASCII_APRIL_26_2006_1106PM)
0009 #define BOOST_SPIRIT_ASCII_APRIL_26_2006_1106PM
0010
0011 #if defined(_MSC_VER)
0012 #pragma once
0013 #endif
0014
0015 #include <climits>
0016 #include <boost/assert.hpp>
0017 #include <boost/cstdint.hpp>
0018
0019
0020
0021
0022 #define BOOST_CC_DIGIT 0x0001
0023 #define BOOST_CC_XDIGIT 0x0002
0024 #define BOOST_CC_ALPHA 0x0004
0025 #define BOOST_CC_CTRL 0x0008
0026 #define BOOST_CC_LOWER 0x0010
0027 #define BOOST_CC_UPPER 0x0020
0028 #define BOOST_CC_SPACE 0x0040
0029 #define BOOST_CC_PUNCT 0x0080
0030
0031 namespace boost { namespace spirit { namespace char_encoding
0032 {
0033
0034
0035
0036
0037
0038
0039
0040 const unsigned char ascii_char_types[] =
0041 {
0042 BOOST_CC_CTRL,
0043 BOOST_CC_CTRL,
0044 BOOST_CC_CTRL,
0045 BOOST_CC_CTRL,
0046 BOOST_CC_CTRL,
0047 BOOST_CC_CTRL,
0048 BOOST_CC_CTRL,
0049 BOOST_CC_CTRL,
0050 BOOST_CC_CTRL,
0051 BOOST_CC_CTRL|BOOST_CC_SPACE,
0052 BOOST_CC_CTRL|BOOST_CC_SPACE,
0053 BOOST_CC_CTRL|BOOST_CC_SPACE,
0054 BOOST_CC_CTRL|BOOST_CC_SPACE,
0055 BOOST_CC_CTRL|BOOST_CC_SPACE,
0056 BOOST_CC_CTRL,
0057 BOOST_CC_CTRL,
0058 BOOST_CC_CTRL,
0059 BOOST_CC_CTRL,
0060 BOOST_CC_CTRL,
0061 BOOST_CC_CTRL,
0062 BOOST_CC_CTRL,
0063 BOOST_CC_CTRL,
0064 BOOST_CC_CTRL,
0065 BOOST_CC_CTRL,
0066 BOOST_CC_CTRL,
0067 BOOST_CC_CTRL,
0068 BOOST_CC_CTRL,
0069 BOOST_CC_CTRL,
0070 BOOST_CC_CTRL,
0071 BOOST_CC_CTRL,
0072 BOOST_CC_CTRL,
0073 BOOST_CC_CTRL,
0074 BOOST_CC_SPACE,
0075 BOOST_CC_PUNCT,
0076 BOOST_CC_PUNCT,
0077 BOOST_CC_PUNCT,
0078 BOOST_CC_PUNCT,
0079 BOOST_CC_PUNCT,
0080 BOOST_CC_PUNCT,
0081 BOOST_CC_PUNCT,
0082 BOOST_CC_PUNCT,
0083 BOOST_CC_PUNCT,
0084 BOOST_CC_PUNCT,
0085 BOOST_CC_PUNCT,
0086 BOOST_CC_PUNCT,
0087 BOOST_CC_PUNCT,
0088 BOOST_CC_PUNCT,
0089 BOOST_CC_PUNCT,
0090 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0091 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0092 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0093 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0094 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0095 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0096 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0097 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0098 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0099 BOOST_CC_DIGIT|BOOST_CC_XDIGIT,
0100 BOOST_CC_PUNCT,
0101 BOOST_CC_PUNCT,
0102 BOOST_CC_PUNCT,
0103 BOOST_CC_PUNCT,
0104 BOOST_CC_PUNCT,
0105 BOOST_CC_PUNCT,
0106 BOOST_CC_PUNCT,
0107 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_UPPER,
0108 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_UPPER,
0109 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_UPPER,
0110 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_UPPER,
0111 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_UPPER,
0112 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_UPPER,
0113 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0114 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0115 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0116 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0117 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0118 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0119 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0120 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0121 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0122 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0123 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0124 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0125 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0126 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0127 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0128 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0129 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0130 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0131 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0132 BOOST_CC_ALPHA|BOOST_CC_UPPER,
0133 BOOST_CC_PUNCT,
0134 BOOST_CC_PUNCT,
0135 BOOST_CC_PUNCT,
0136 BOOST_CC_PUNCT,
0137 BOOST_CC_PUNCT,
0138 BOOST_CC_PUNCT,
0139 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_LOWER,
0140 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_LOWER,
0141 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_LOWER,
0142 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_LOWER,
0143 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_LOWER,
0144 BOOST_CC_ALPHA|BOOST_CC_XDIGIT|BOOST_CC_LOWER,
0145 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0146 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0147 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0148 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0149 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0150 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0151 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0152 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0153 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0154 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0155 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0156 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0157 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0158 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0159 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0160 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0161 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0162 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0163 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0164 BOOST_CC_ALPHA|BOOST_CC_LOWER,
0165 BOOST_CC_PUNCT,
0166 BOOST_CC_PUNCT,
0167 BOOST_CC_PUNCT,
0168 BOOST_CC_PUNCT,
0169 BOOST_CC_CTRL,
0170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0178 };
0179
0180
0181
0182
0183 struct ascii
0184 {
0185 typedef char char_type;
0186 typedef unsigned char classify_type;
0187
0188 static bool
0189 isascii_(int ch)
0190 {
0191 return 0 == (ch & ~0x7f);
0192 }
0193
0194 static bool
0195 ischar(int ch)
0196 {
0197 return isascii_(ch);
0198 }
0199
0200
0201
0202
0203
0204
0205
0206 static bool
0207 strict_ischar(int ch)
0208 {
0209 return ch >= 0 && ch <= 127;
0210 }
0211
0212 static bool
0213 isalnum(int ch)
0214 {
0215 BOOST_ASSERT(strict_ischar(ch));
0216 return (ascii_char_types[ch] & BOOST_CC_ALPHA)
0217 || (ascii_char_types[ch] & BOOST_CC_DIGIT);
0218 }
0219
0220 static bool
0221 isalpha(int ch)
0222 {
0223 BOOST_ASSERT(strict_ischar(ch));
0224 return (ascii_char_types[ch] & BOOST_CC_ALPHA) ? true : false;
0225 }
0226
0227 static bool
0228 isdigit(int ch)
0229 {
0230 BOOST_ASSERT(strict_ischar(ch));
0231 return (ascii_char_types[ch] & BOOST_CC_DIGIT) ? true : false;
0232 }
0233
0234 static bool
0235 isxdigit(int ch)
0236 {
0237 BOOST_ASSERT(strict_ischar(ch));
0238 return (ascii_char_types[ch] & BOOST_CC_XDIGIT) ? true : false;
0239 }
0240
0241 static bool
0242 iscntrl(int ch)
0243 {
0244 BOOST_ASSERT(strict_ischar(ch));
0245 return (ascii_char_types[ch] & BOOST_CC_CTRL) ? true : false;
0246 }
0247
0248 static bool
0249 isgraph(int ch)
0250 {
0251 BOOST_ASSERT(strict_ischar(ch));
0252 return ('\x21' <= ch && ch <= '\x7e');
0253 }
0254
0255 static bool
0256 islower(int ch)
0257 {
0258 BOOST_ASSERT(strict_ischar(ch));
0259 return (ascii_char_types[ch] & BOOST_CC_LOWER) ? true : false;
0260 }
0261
0262 static bool
0263 isprint(int ch)
0264 {
0265 BOOST_ASSERT(strict_ischar(ch));
0266 return ('\x20' <= ch && ch <= '\x7e');
0267 }
0268
0269 static bool
0270 ispunct(int ch)
0271 {
0272 BOOST_ASSERT(strict_ischar(ch));
0273 return (ascii_char_types[ch] & BOOST_CC_PUNCT) ? true : false;
0274 }
0275
0276 static bool
0277 isspace(int ch)
0278 {
0279 BOOST_ASSERT(strict_ischar(ch));
0280 return (ascii_char_types[ch] & BOOST_CC_SPACE) ? true : false;
0281 }
0282
0283 static bool
0284 isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch)
0285 {
0286 BOOST_ASSERT(strict_ischar(ch));
0287 return ('\x09' == ch || '\x20' == ch);
0288 }
0289
0290 static bool
0291 isupper(int ch)
0292 {
0293 BOOST_ASSERT(strict_ischar(ch));
0294 return (ascii_char_types[ch] & BOOST_CC_UPPER) ? true : false;
0295 }
0296
0297
0298
0299
0300
0301 static int
0302 tolower(int ch)
0303 {
0304 BOOST_ASSERT(strict_ischar(ch));
0305 return isupper(ch) ? (ch - 'A' + 'a') : ch;
0306 }
0307
0308 static int
0309 toupper(int ch)
0310 {
0311 BOOST_ASSERT(strict_ischar(ch));
0312 return islower(ch) ? (ch - 'a' + 'A') : ch;
0313 }
0314
0315 static ::boost::uint32_t
0316 toucs4(int ch)
0317 {
0318 BOOST_ASSERT(strict_ischar(ch));
0319 return ch;
0320 }
0321 };
0322
0323 }}}
0324
0325
0326
0327
0328 #undef BOOST_CC_DIGIT
0329 #undef BOOST_CC_XDIGIT
0330 #undef BOOST_CC_ALPHA
0331 #undef BOOST_CC_CTRL
0332 #undef BOOST_CC_LOWER
0333 #undef BOOST_CC_UPPER
0334 #undef BOOST_CC_PUNCT
0335 #undef BOOST_CC_SPACE
0336
0337 #endif