• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2001-2011 Hartmut Kaiser
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #if !defined(BOOST_SPIRIT_CHAR_CLASS_NOVEMBER_10_2006_0907AM)
9 #define BOOST_SPIRIT_CHAR_CLASS_NOVEMBER_10_2006_0907AM
10 
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14 
15 #include <boost/config.hpp>
16 #include <boost/mpl/bool.hpp>
17 #include <boost/spirit/home/support/unused.hpp>
18 #include <boost/spirit/home/support/detail/is_spirit_tag.hpp>
19 #include <boost/type_traits/is_signed.hpp>
20 #include <boost/type_traits/make_unsigned.hpp>
21 #include <boost/type_traits/make_signed.hpp>
22 
23 #if defined(BOOST_MSVC)
24 # pragma warning(push)
25 # pragma warning(disable: 4127) // conditional expression is constant
26 # pragma warning(disable: 4800) // 'int' : forcing value to bool 'true' or 'false' warning
27 #endif
28 
29 namespace boost { namespace spirit { namespace detail
30 {
31     // Here's the thing... typical encodings (except ASCII) deal with unsigned
32     // integers > 127. ASCII uses only 127. Yet, most char and wchar_t are signed.
33     // Thus, a char with value > 127 is negative (e.g. char 233 is -23). When you
34     // cast this to an unsigned int with 32 bits, you get 4294967273!
35     //
36     // The trick is to cast to an unsigned version of the source char first
37     // before casting to the target. {P.S. Don't worry about the code, the
38     // optimizer will optimize the if-else branches}
39 
40     template <typename TargetChar, typename SourceChar>
cast_char(SourceChar ch)41     TargetChar cast_char(SourceChar ch)
42     {
43         if (is_signed<TargetChar>::value != is_signed<SourceChar>::value)
44         {
45             if (is_signed<SourceChar>::value)
46             {
47                  // source is signed, target is unsigned
48                 typedef typename make_unsigned<SourceChar>::type USourceChar;
49                 return TargetChar(USourceChar(ch));
50             }
51             else
52             {
53                  // source is unsigned, target is signed
54                 typedef typename make_signed<SourceChar>::type SSourceChar;
55                 return TargetChar(SSourceChar(ch));
56             }
57         }
58         else
59         {
60             // source and target has same signedness
61             return TargetChar(ch); // just cast
62         }
63     }
64 }}}
65 
66 namespace boost { namespace spirit { namespace tag
67 {
68     struct char_ { BOOST_SPIRIT_IS_TAG() };
69     struct string { BOOST_SPIRIT_IS_TAG() };
70 
71     ///////////////////////////////////////////////////////////////////////////
72     // classification tags
73     struct alnum { BOOST_SPIRIT_IS_TAG() };
74     struct alpha { BOOST_SPIRIT_IS_TAG() };
75     struct digit { BOOST_SPIRIT_IS_TAG() };
76     struct xdigit { BOOST_SPIRIT_IS_TAG() };
77     struct cntrl { BOOST_SPIRIT_IS_TAG() };
78     struct graph { BOOST_SPIRIT_IS_TAG() };
79     struct print { BOOST_SPIRIT_IS_TAG() };
80     struct punct { BOOST_SPIRIT_IS_TAG() };
81     struct space { BOOST_SPIRIT_IS_TAG() };
82     struct blank { BOOST_SPIRIT_IS_TAG() };
83 
84     ///////////////////////////////////////////////////////////////////////////
85     // classification/conversion tags
86     struct no_case { BOOST_SPIRIT_IS_TAG() };
87     struct lower { BOOST_SPIRIT_IS_TAG() };
88     struct upper { BOOST_SPIRIT_IS_TAG() };
89     struct lowernum { BOOST_SPIRIT_IS_TAG() };
90     struct uppernum { BOOST_SPIRIT_IS_TAG() };
91     struct ucs4 { BOOST_SPIRIT_IS_TAG() };
92     struct encoding { BOOST_SPIRIT_IS_TAG() };
93 
94 #if defined(BOOST_SPIRIT_UNICODE)
95 ///////////////////////////////////////////////////////////////////////////
96 //  Unicode Major Categories
97 ///////////////////////////////////////////////////////////////////////////
98     struct letter { BOOST_SPIRIT_IS_TAG() };
99     struct mark { BOOST_SPIRIT_IS_TAG() };
100     struct number { BOOST_SPIRIT_IS_TAG() };
101     struct separator { BOOST_SPIRIT_IS_TAG() };
102     struct other { BOOST_SPIRIT_IS_TAG() };
103     struct punctuation { BOOST_SPIRIT_IS_TAG() };
104     struct symbol { BOOST_SPIRIT_IS_TAG() };
105 
106 ///////////////////////////////////////////////////////////////////////////
107 //  Unicode General Categories
108 ///////////////////////////////////////////////////////////////////////////
109     struct uppercase_letter { BOOST_SPIRIT_IS_TAG() };
110     struct lowercase_letter { BOOST_SPIRIT_IS_TAG() };
111     struct titlecase_letter { BOOST_SPIRIT_IS_TAG() };
112     struct modifier_letter { BOOST_SPIRIT_IS_TAG() };
113     struct other_letter { BOOST_SPIRIT_IS_TAG() };
114 
115     struct nonspacing_mark { BOOST_SPIRIT_IS_TAG() };
116     struct enclosing_mark { BOOST_SPIRIT_IS_TAG() };
117     struct spacing_mark { BOOST_SPIRIT_IS_TAG() };
118 
119     struct decimal_number { BOOST_SPIRIT_IS_TAG() };
120     struct letter_number { BOOST_SPIRIT_IS_TAG() };
121     struct other_number { BOOST_SPIRIT_IS_TAG() };
122 
123     struct space_separator { BOOST_SPIRIT_IS_TAG() };
124     struct line_separator { BOOST_SPIRIT_IS_TAG() };
125     struct paragraph_separator { BOOST_SPIRIT_IS_TAG() };
126 
127     struct control { BOOST_SPIRIT_IS_TAG() };
128     struct format { BOOST_SPIRIT_IS_TAG() };
129     struct private_use { BOOST_SPIRIT_IS_TAG() };
130     struct surrogate { BOOST_SPIRIT_IS_TAG() };
131     struct unassigned { BOOST_SPIRIT_IS_TAG() };
132 
133     struct dash_punctuation { BOOST_SPIRIT_IS_TAG() };
134     struct open_punctuation { BOOST_SPIRIT_IS_TAG() };
135     struct close_punctuation { BOOST_SPIRIT_IS_TAG() };
136     struct connector_punctuation { BOOST_SPIRIT_IS_TAG() };
137     struct other_punctuation { BOOST_SPIRIT_IS_TAG() };
138     struct initial_punctuation { BOOST_SPIRIT_IS_TAG() };
139     struct final_punctuation { BOOST_SPIRIT_IS_TAG() };
140 
141     struct math_symbol { BOOST_SPIRIT_IS_TAG() };
142     struct currency_symbol { BOOST_SPIRIT_IS_TAG() };
143     struct modifier_symbol { BOOST_SPIRIT_IS_TAG() };
144     struct other_symbol { BOOST_SPIRIT_IS_TAG() };
145 
146 ///////////////////////////////////////////////////////////////////////////
147 //  Unicode Derived Categories
148 ///////////////////////////////////////////////////////////////////////////
149     struct alphabetic { BOOST_SPIRIT_IS_TAG() };
150     struct uppercase { BOOST_SPIRIT_IS_TAG() };
151     struct lowercase { BOOST_SPIRIT_IS_TAG() };
152     struct white_space { BOOST_SPIRIT_IS_TAG() };
153     struct hex_digit { BOOST_SPIRIT_IS_TAG() };
154     struct noncharacter_code_point { BOOST_SPIRIT_IS_TAG() };
155     struct default_ignorable_code_point { BOOST_SPIRIT_IS_TAG() };
156 
157 ///////////////////////////////////////////////////////////////////////////
158 //  Unicode Scripts
159 ///////////////////////////////////////////////////////////////////////////
160     struct arabic { BOOST_SPIRIT_IS_TAG() };
161     struct imperial_aramaic { BOOST_SPIRIT_IS_TAG() };
162     struct armenian { BOOST_SPIRIT_IS_TAG() };
163     struct avestan { BOOST_SPIRIT_IS_TAG() };
164     struct balinese { BOOST_SPIRIT_IS_TAG() };
165     struct bamum { BOOST_SPIRIT_IS_TAG() };
166     struct bengali { BOOST_SPIRIT_IS_TAG() };
167     struct bopomofo { BOOST_SPIRIT_IS_TAG() };
168     struct braille { BOOST_SPIRIT_IS_TAG() };
169     struct buginese { BOOST_SPIRIT_IS_TAG() };
170     struct buhid { BOOST_SPIRIT_IS_TAG() };
171     struct canadian_aboriginal { BOOST_SPIRIT_IS_TAG() };
172     struct carian { BOOST_SPIRIT_IS_TAG() };
173     struct cham { BOOST_SPIRIT_IS_TAG() };
174     struct cherokee { BOOST_SPIRIT_IS_TAG() };
175     struct coptic { BOOST_SPIRIT_IS_TAG() };
176     struct cypriot { BOOST_SPIRIT_IS_TAG() };
177     struct cyrillic { BOOST_SPIRIT_IS_TAG() };
178     struct devanagari { BOOST_SPIRIT_IS_TAG() };
179     struct deseret { BOOST_SPIRIT_IS_TAG() };
180     struct egyptian_hieroglyphs { BOOST_SPIRIT_IS_TAG() };
181     struct ethiopic { BOOST_SPIRIT_IS_TAG() };
182     struct georgian { BOOST_SPIRIT_IS_TAG() };
183     struct glagolitic { BOOST_SPIRIT_IS_TAG() };
184     struct gothic { BOOST_SPIRIT_IS_TAG() };
185     struct greek { BOOST_SPIRIT_IS_TAG() };
186     struct gujarati { BOOST_SPIRIT_IS_TAG() };
187     struct gurmukhi { BOOST_SPIRIT_IS_TAG() };
188     struct hangul { BOOST_SPIRIT_IS_TAG() };
189     struct han { BOOST_SPIRIT_IS_TAG() };
190     struct hanunoo { BOOST_SPIRIT_IS_TAG() };
191     struct hebrew { BOOST_SPIRIT_IS_TAG() };
192     struct hiragana { BOOST_SPIRIT_IS_TAG() };
193     struct katakana_or_hiragana { BOOST_SPIRIT_IS_TAG() };
194     struct old_italic { BOOST_SPIRIT_IS_TAG() };
195     struct javanese { BOOST_SPIRIT_IS_TAG() };
196     struct kayah_li { BOOST_SPIRIT_IS_TAG() };
197     struct katakana { BOOST_SPIRIT_IS_TAG() };
198     struct kharoshthi { BOOST_SPIRIT_IS_TAG() };
199     struct khmer { BOOST_SPIRIT_IS_TAG() };
200     struct kannada { BOOST_SPIRIT_IS_TAG() };
201     struct kaithi { BOOST_SPIRIT_IS_TAG() };
202     struct tai_tham { BOOST_SPIRIT_IS_TAG() };
203     struct lao { BOOST_SPIRIT_IS_TAG() };
204     struct latin { BOOST_SPIRIT_IS_TAG() };
205     struct lepcha { BOOST_SPIRIT_IS_TAG() };
206     struct limbu { BOOST_SPIRIT_IS_TAG() };
207     struct linear_b { BOOST_SPIRIT_IS_TAG() };
208     struct lisu { BOOST_SPIRIT_IS_TAG() };
209     struct lycian { BOOST_SPIRIT_IS_TAG() };
210     struct lydian { BOOST_SPIRIT_IS_TAG() };
211     struct malayalam { BOOST_SPIRIT_IS_TAG() };
212     struct mongolian { BOOST_SPIRIT_IS_TAG() };
213     struct meetei_mayek { BOOST_SPIRIT_IS_TAG() };
214     struct myanmar { BOOST_SPIRIT_IS_TAG() };
215     struct nko { BOOST_SPIRIT_IS_TAG() };
216     struct ogham { BOOST_SPIRIT_IS_TAG() };
217     struct ol_chiki { BOOST_SPIRIT_IS_TAG() };
218     struct old_turkic { BOOST_SPIRIT_IS_TAG() };
219     struct oriya { BOOST_SPIRIT_IS_TAG() };
220     struct osmanya { BOOST_SPIRIT_IS_TAG() };
221     struct phags_pa { BOOST_SPIRIT_IS_TAG() };
222     struct inscriptional_pahlavi { BOOST_SPIRIT_IS_TAG() };
223     struct phoenician { BOOST_SPIRIT_IS_TAG() };
224     struct inscriptional_parthian { BOOST_SPIRIT_IS_TAG() };
225     struct rejang { BOOST_SPIRIT_IS_TAG() };
226     struct runic { BOOST_SPIRIT_IS_TAG() };
227     struct samaritan { BOOST_SPIRIT_IS_TAG() };
228     struct old_south_arabian { BOOST_SPIRIT_IS_TAG() };
229     struct saurashtra { BOOST_SPIRIT_IS_TAG() };
230     struct shavian { BOOST_SPIRIT_IS_TAG() };
231     struct sinhala { BOOST_SPIRIT_IS_TAG() };
232     struct sundanese { BOOST_SPIRIT_IS_TAG() };
233     struct syloti_nagri { BOOST_SPIRIT_IS_TAG() };
234     struct syriac { BOOST_SPIRIT_IS_TAG() };
235     struct tagbanwa { BOOST_SPIRIT_IS_TAG() };
236     struct tai_le { BOOST_SPIRIT_IS_TAG() };
237     struct new_tai_lue { BOOST_SPIRIT_IS_TAG() };
238     struct tamil { BOOST_SPIRIT_IS_TAG() };
239     struct tai_viet { BOOST_SPIRIT_IS_TAG() };
240     struct telugu { BOOST_SPIRIT_IS_TAG() };
241     struct tifinagh { BOOST_SPIRIT_IS_TAG() };
242     struct tagalog { BOOST_SPIRIT_IS_TAG() };
243     struct thaana { BOOST_SPIRIT_IS_TAG() };
244     struct thai { BOOST_SPIRIT_IS_TAG() };
245     struct tibetan { BOOST_SPIRIT_IS_TAG() };
246     struct ugaritic { BOOST_SPIRIT_IS_TAG() };
247     struct vai { BOOST_SPIRIT_IS_TAG() };
248     struct old_persian { BOOST_SPIRIT_IS_TAG() };
249     struct cuneiform { BOOST_SPIRIT_IS_TAG() };
250     struct yi { BOOST_SPIRIT_IS_TAG() };
251     struct inherited { BOOST_SPIRIT_IS_TAG() };
252     struct common { BOOST_SPIRIT_IS_TAG() };
253     struct unknown { BOOST_SPIRIT_IS_TAG() };
254 #endif
255 
256     ///////////////////////////////////////////////////////////////////////////
257     // This composite tag type encodes both the character
258     // set and the specific char tag (used for classification
259     // or conversion). char_code_base and char_encoding_base
260     // can be used to test for modifier membership (see modifier.hpp)
261     template <typename CharClass>
262     struct char_code_base {};
263 
264     template <typename CharEncoding>
265     struct char_encoding_base {};
266 
267     template <typename CharClass, typename CharEncoding>
268     struct char_code
269         : char_code_base<CharClass>, char_encoding_base<CharEncoding>
270     {
271         BOOST_SPIRIT_IS_TAG()
272         typedef CharEncoding char_encoding; // e.g. ascii
273         typedef CharClass char_class;       // e.g. tag::alnum
274     };
275 }}}
276 
277 namespace boost { namespace spirit { namespace char_class
278 {
279     ///////////////////////////////////////////////////////////////////////////
280     // Test characters for classification
281     template <typename CharEncoding>
282     struct classify
283     {
284         typedef typename CharEncoding::char_type char_type;
285 
286 #define BOOST_SPIRIT_CLASSIFY(name, isname)                                     \
287         template <typename Char>                                                \
288         static bool                                                             \
289         is(tag::name, Char ch)                                                  \
290         {                                                                       \
291             return CharEncoding::isname                                         \
292                 BOOST_PREVENT_MACRO_SUBSTITUTION                                \
293                     (detail::cast_char<char_type>(ch));                         \
294         }                                                                       \
295         /***/
296 
BOOST_SPIRIT_CLASSIFYboost::spirit::char_class::classify297         BOOST_SPIRIT_CLASSIFY(char_, ischar)
298         BOOST_SPIRIT_CLASSIFY(alnum, isalnum)
299         BOOST_SPIRIT_CLASSIFY(alpha, isalpha)
300         BOOST_SPIRIT_CLASSIFY(digit, isdigit)
301         BOOST_SPIRIT_CLASSIFY(xdigit, isxdigit)
302         BOOST_SPIRIT_CLASSIFY(cntrl, iscntrl)
303         BOOST_SPIRIT_CLASSIFY(graph, isgraph)
304         BOOST_SPIRIT_CLASSIFY(lower, islower)
305         BOOST_SPIRIT_CLASSIFY(print, isprint)
306         BOOST_SPIRIT_CLASSIFY(punct, ispunct)
307         BOOST_SPIRIT_CLASSIFY(space, isspace)
308         BOOST_SPIRIT_CLASSIFY(blank, isblank)
309         BOOST_SPIRIT_CLASSIFY(upper, isupper)
310 
311 #undef BOOST_SPIRIT_CLASSIFY
312 
313         template <typename Char>
314         static bool
315         is(tag::lowernum, Char ch)
316         {
317             return CharEncoding::islower(detail::cast_char<char_type>(ch)) ||
318                    CharEncoding::isdigit(detail::cast_char<char_type>(ch));
319         }
320 
321         template <typename Char>
322         static bool
isboost::spirit::char_class::classify323         is(tag::uppernum, Char ch)
324         {
325             return CharEncoding::isupper(detail::cast_char<char_type>(ch)) ||
326                    CharEncoding::isdigit(detail::cast_char<char_type>(ch));
327         }
328 
329 #if defined(BOOST_SPIRIT_UNICODE)
330 
331 #define BOOST_SPIRIT_UNICODE_CLASSIFY(name)                                     \
332         template <typename Char>                                                \
333         static bool                                                             \
334         is(tag::name, Char ch)                                                  \
335         {                                                                       \
336             return CharEncoding::is_##name(detail::cast_char<char_type>(ch));   \
337         }                                                                       \
338         /***/
339 
340 ///////////////////////////////////////////////////////////////////////////
341 //  Unicode Major Categories
342 ///////////////////////////////////////////////////////////////////////////
343     BOOST_SPIRIT_UNICODE_CLASSIFY(letter)
344     BOOST_SPIRIT_UNICODE_CLASSIFY(mark)
345     BOOST_SPIRIT_UNICODE_CLASSIFY(number)
346     BOOST_SPIRIT_UNICODE_CLASSIFY(separator)
347     BOOST_SPIRIT_UNICODE_CLASSIFY(other)
348     BOOST_SPIRIT_UNICODE_CLASSIFY(punctuation)
349     BOOST_SPIRIT_UNICODE_CLASSIFY(symbol)
350 
351 ///////////////////////////////////////////////////////////////////////////
352 //  Unicode General Categories
353 ///////////////////////////////////////////////////////////////////////////
354     BOOST_SPIRIT_UNICODE_CLASSIFY(uppercase_letter)
355     BOOST_SPIRIT_UNICODE_CLASSIFY(lowercase_letter)
356     BOOST_SPIRIT_UNICODE_CLASSIFY(titlecase_letter)
357     BOOST_SPIRIT_UNICODE_CLASSIFY(modifier_letter)
358     BOOST_SPIRIT_UNICODE_CLASSIFY(other_letter)
359 
360     BOOST_SPIRIT_UNICODE_CLASSIFY(nonspacing_mark)
361     BOOST_SPIRIT_UNICODE_CLASSIFY(enclosing_mark)
362     BOOST_SPIRIT_UNICODE_CLASSIFY(spacing_mark)
363 
364     BOOST_SPIRIT_UNICODE_CLASSIFY(decimal_number)
365     BOOST_SPIRIT_UNICODE_CLASSIFY(letter_number)
366     BOOST_SPIRIT_UNICODE_CLASSIFY(other_number)
367 
368     BOOST_SPIRIT_UNICODE_CLASSIFY(space_separator)
369     BOOST_SPIRIT_UNICODE_CLASSIFY(line_separator)
370     BOOST_SPIRIT_UNICODE_CLASSIFY(paragraph_separator)
371 
372     BOOST_SPIRIT_UNICODE_CLASSIFY(control)
373     BOOST_SPIRIT_UNICODE_CLASSIFY(format)
374     BOOST_SPIRIT_UNICODE_CLASSIFY(private_use)
375     BOOST_SPIRIT_UNICODE_CLASSIFY(surrogate)
376     BOOST_SPIRIT_UNICODE_CLASSIFY(unassigned)
377 
378     BOOST_SPIRIT_UNICODE_CLASSIFY(dash_punctuation)
379     BOOST_SPIRIT_UNICODE_CLASSIFY(open_punctuation)
380     BOOST_SPIRIT_UNICODE_CLASSIFY(close_punctuation)
381     BOOST_SPIRIT_UNICODE_CLASSIFY(connector_punctuation)
382     BOOST_SPIRIT_UNICODE_CLASSIFY(other_punctuation)
383     BOOST_SPIRIT_UNICODE_CLASSIFY(initial_punctuation)
384     BOOST_SPIRIT_UNICODE_CLASSIFY(final_punctuation)
385 
386     BOOST_SPIRIT_UNICODE_CLASSIFY(math_symbol)
387     BOOST_SPIRIT_UNICODE_CLASSIFY(currency_symbol)
388     BOOST_SPIRIT_UNICODE_CLASSIFY(modifier_symbol)
389     BOOST_SPIRIT_UNICODE_CLASSIFY(other_symbol)
390 
391 ///////////////////////////////////////////////////////////////////////////
392 //  Unicode Derived Categories
393 ///////////////////////////////////////////////////////////////////////////
394     BOOST_SPIRIT_UNICODE_CLASSIFY(alphabetic)
395     BOOST_SPIRIT_UNICODE_CLASSIFY(uppercase)
396     BOOST_SPIRIT_UNICODE_CLASSIFY(lowercase)
397     BOOST_SPIRIT_UNICODE_CLASSIFY(white_space)
398     BOOST_SPIRIT_UNICODE_CLASSIFY(hex_digit)
399     BOOST_SPIRIT_UNICODE_CLASSIFY(noncharacter_code_point)
400     BOOST_SPIRIT_UNICODE_CLASSIFY(default_ignorable_code_point)
401 
402 ///////////////////////////////////////////////////////////////////////////
403 //  Unicode Scripts
404 ///////////////////////////////////////////////////////////////////////////
405     BOOST_SPIRIT_UNICODE_CLASSIFY(arabic)
406     BOOST_SPIRIT_UNICODE_CLASSIFY(imperial_aramaic)
407     BOOST_SPIRIT_UNICODE_CLASSIFY(armenian)
408     BOOST_SPIRIT_UNICODE_CLASSIFY(avestan)
409     BOOST_SPIRIT_UNICODE_CLASSIFY(balinese)
410     BOOST_SPIRIT_UNICODE_CLASSIFY(bamum)
411     BOOST_SPIRIT_UNICODE_CLASSIFY(bengali)
412     BOOST_SPIRIT_UNICODE_CLASSIFY(bopomofo)
413     BOOST_SPIRIT_UNICODE_CLASSIFY(braille)
414     BOOST_SPIRIT_UNICODE_CLASSIFY(buginese)
415     BOOST_SPIRIT_UNICODE_CLASSIFY(buhid)
416     BOOST_SPIRIT_UNICODE_CLASSIFY(canadian_aboriginal)
417     BOOST_SPIRIT_UNICODE_CLASSIFY(carian)
418     BOOST_SPIRIT_UNICODE_CLASSIFY(cham)
419     BOOST_SPIRIT_UNICODE_CLASSIFY(cherokee)
420     BOOST_SPIRIT_UNICODE_CLASSIFY(coptic)
421     BOOST_SPIRIT_UNICODE_CLASSIFY(cypriot)
422     BOOST_SPIRIT_UNICODE_CLASSIFY(cyrillic)
423     BOOST_SPIRIT_UNICODE_CLASSIFY(devanagari)
424     BOOST_SPIRIT_UNICODE_CLASSIFY(deseret)
425     BOOST_SPIRIT_UNICODE_CLASSIFY(egyptian_hieroglyphs)
426     BOOST_SPIRIT_UNICODE_CLASSIFY(ethiopic)
427     BOOST_SPIRIT_UNICODE_CLASSIFY(georgian)
428     BOOST_SPIRIT_UNICODE_CLASSIFY(glagolitic)
429     BOOST_SPIRIT_UNICODE_CLASSIFY(gothic)
430     BOOST_SPIRIT_UNICODE_CLASSIFY(greek)
431     BOOST_SPIRIT_UNICODE_CLASSIFY(gujarati)
432     BOOST_SPIRIT_UNICODE_CLASSIFY(gurmukhi)
433     BOOST_SPIRIT_UNICODE_CLASSIFY(hangul)
434     BOOST_SPIRIT_UNICODE_CLASSIFY(han)
435     BOOST_SPIRIT_UNICODE_CLASSIFY(hanunoo)
436     BOOST_SPIRIT_UNICODE_CLASSIFY(hebrew)
437     BOOST_SPIRIT_UNICODE_CLASSIFY(hiragana)
438     BOOST_SPIRIT_UNICODE_CLASSIFY(katakana_or_hiragana)
439     BOOST_SPIRIT_UNICODE_CLASSIFY(old_italic)
440     BOOST_SPIRIT_UNICODE_CLASSIFY(javanese)
441     BOOST_SPIRIT_UNICODE_CLASSIFY(kayah_li)
442     BOOST_SPIRIT_UNICODE_CLASSIFY(katakana)
443     BOOST_SPIRIT_UNICODE_CLASSIFY(kharoshthi)
444     BOOST_SPIRIT_UNICODE_CLASSIFY(khmer)
445     BOOST_SPIRIT_UNICODE_CLASSIFY(kannada)
446     BOOST_SPIRIT_UNICODE_CLASSIFY(kaithi)
447     BOOST_SPIRIT_UNICODE_CLASSIFY(tai_tham)
448     BOOST_SPIRIT_UNICODE_CLASSIFY(lao)
449     BOOST_SPIRIT_UNICODE_CLASSIFY(latin)
450     BOOST_SPIRIT_UNICODE_CLASSIFY(lepcha)
451     BOOST_SPIRIT_UNICODE_CLASSIFY(limbu)
452     BOOST_SPIRIT_UNICODE_CLASSIFY(linear_b)
453     BOOST_SPIRIT_UNICODE_CLASSIFY(lisu)
454     BOOST_SPIRIT_UNICODE_CLASSIFY(lycian)
455     BOOST_SPIRIT_UNICODE_CLASSIFY(lydian)
456     BOOST_SPIRIT_UNICODE_CLASSIFY(malayalam)
457     BOOST_SPIRIT_UNICODE_CLASSIFY(mongolian)
458     BOOST_SPIRIT_UNICODE_CLASSIFY(meetei_mayek)
459     BOOST_SPIRIT_UNICODE_CLASSIFY(myanmar)
460     BOOST_SPIRIT_UNICODE_CLASSIFY(nko)
461     BOOST_SPIRIT_UNICODE_CLASSIFY(ogham)
462     BOOST_SPIRIT_UNICODE_CLASSIFY(ol_chiki)
463     BOOST_SPIRIT_UNICODE_CLASSIFY(old_turkic)
464     BOOST_SPIRIT_UNICODE_CLASSIFY(oriya)
465     BOOST_SPIRIT_UNICODE_CLASSIFY(osmanya)
466     BOOST_SPIRIT_UNICODE_CLASSIFY(phags_pa)
467     BOOST_SPIRIT_UNICODE_CLASSIFY(inscriptional_pahlavi)
468     BOOST_SPIRIT_UNICODE_CLASSIFY(phoenician)
469     BOOST_SPIRIT_UNICODE_CLASSIFY(inscriptional_parthian)
470     BOOST_SPIRIT_UNICODE_CLASSIFY(rejang)
471     BOOST_SPIRIT_UNICODE_CLASSIFY(runic)
472     BOOST_SPIRIT_UNICODE_CLASSIFY(samaritan)
473     BOOST_SPIRIT_UNICODE_CLASSIFY(old_south_arabian)
474     BOOST_SPIRIT_UNICODE_CLASSIFY(saurashtra)
475     BOOST_SPIRIT_UNICODE_CLASSIFY(shavian)
476     BOOST_SPIRIT_UNICODE_CLASSIFY(sinhala)
477     BOOST_SPIRIT_UNICODE_CLASSIFY(sundanese)
478     BOOST_SPIRIT_UNICODE_CLASSIFY(syloti_nagri)
479     BOOST_SPIRIT_UNICODE_CLASSIFY(syriac)
480     BOOST_SPIRIT_UNICODE_CLASSIFY(tagbanwa)
481     BOOST_SPIRIT_UNICODE_CLASSIFY(tai_le)
482     BOOST_SPIRIT_UNICODE_CLASSIFY(new_tai_lue)
483     BOOST_SPIRIT_UNICODE_CLASSIFY(tamil)
484     BOOST_SPIRIT_UNICODE_CLASSIFY(tai_viet)
485     BOOST_SPIRIT_UNICODE_CLASSIFY(telugu)
486     BOOST_SPIRIT_UNICODE_CLASSIFY(tifinagh)
487     BOOST_SPIRIT_UNICODE_CLASSIFY(tagalog)
488     BOOST_SPIRIT_UNICODE_CLASSIFY(thaana)
489     BOOST_SPIRIT_UNICODE_CLASSIFY(thai)
490     BOOST_SPIRIT_UNICODE_CLASSIFY(tibetan)
491     BOOST_SPIRIT_UNICODE_CLASSIFY(ugaritic)
492     BOOST_SPIRIT_UNICODE_CLASSIFY(vai)
493     BOOST_SPIRIT_UNICODE_CLASSIFY(old_persian)
494     BOOST_SPIRIT_UNICODE_CLASSIFY(cuneiform)
495     BOOST_SPIRIT_UNICODE_CLASSIFY(yi)
496     BOOST_SPIRIT_UNICODE_CLASSIFY(inherited)
497     BOOST_SPIRIT_UNICODE_CLASSIFY(common)
498     BOOST_SPIRIT_UNICODE_CLASSIFY(unknown)
499 
500 #undef BOOST_SPIRIT_UNICODE_CLASSIFY
501 #endif
502 
503     };
504 
505     ///////////////////////////////////////////////////////////////////////////
506     // Convert characters
507     template <typename CharEncoding>
508     struct convert
509     {
510         typedef typename CharEncoding::char_type char_type;
511 
512         template <typename Char>
513         static Char
toboost::spirit::char_class::convert514         to(tag::lower, Char ch)
515         {
516             return static_cast<Char>(
517                 CharEncoding::tolower(detail::cast_char<char_type>(ch)));
518         }
519 
520         template <typename Char>
521         static Char
toboost::spirit::char_class::convert522         to(tag::upper, Char ch)
523         {
524             return static_cast<Char>(
525                 CharEncoding::toupper(detail::cast_char<char_type>(ch)));
526         }
527 
528         template <typename Char>
529         static Char
toboost::spirit::char_class::convert530         to(tag::ucs4, Char ch)
531         {
532             return static_cast<Char>(
533                 CharEncoding::toucs4(detail::cast_char<char_type>(ch)));
534         }
535 
536         template <typename Char>
537         static Char
toboost::spirit::char_class::convert538         to(unused_type, Char ch)
539         {
540             return ch;
541         }
542     };
543 
544     ///////////////////////////////////////////////////////////////////////////
545     // Info on character classification
546     template <typename CharEncoding>
547     struct what
548     {
549 #define BOOST_SPIRIT_CLASSIFY_WHAT(name, isname)                                \
550         static char const* is(tag::name)                                        \
551         {                                                                       \
552             return isname;                                                      \
553         }                                                                       \
554         /***/
555 
556         BOOST_SPIRIT_CLASSIFY_WHAT(char_, "char")
557         BOOST_SPIRIT_CLASSIFY_WHAT(alnum, "alnum")
558         BOOST_SPIRIT_CLASSIFY_WHAT(alpha, "alpha")
559         BOOST_SPIRIT_CLASSIFY_WHAT(digit, "digit")
560         BOOST_SPIRIT_CLASSIFY_WHAT(xdigit, "xdigit")
561         BOOST_SPIRIT_CLASSIFY_WHAT(cntrl, "cntrl")
562         BOOST_SPIRIT_CLASSIFY_WHAT(graph, "graph")
563         BOOST_SPIRIT_CLASSIFY_WHAT(lower, "lower")
564         BOOST_SPIRIT_CLASSIFY_WHAT(lowernum, "lowernum")
565         BOOST_SPIRIT_CLASSIFY_WHAT(print, "print")
566         BOOST_SPIRIT_CLASSIFY_WHAT(punct, "punct")
567         BOOST_SPIRIT_CLASSIFY_WHAT(space, "space")
568         BOOST_SPIRIT_CLASSIFY_WHAT(blank, "blank")
569         BOOST_SPIRIT_CLASSIFY_WHAT(upper, "upper")
570         BOOST_SPIRIT_CLASSIFY_WHAT(uppernum, "uppernum")
571         BOOST_SPIRIT_CLASSIFY_WHAT(ucs4, "ucs4")
572 
573 #undef BOOST_SPIRIT_CLASSIFY_WHAT
574 
575 #if defined(BOOST_SPIRIT_UNICODE)
576 
577 #define BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(name)                                \
578         static char const* is(tag::name)                                        \
579         {                                                                       \
580             return BOOST_PP_STRINGIZE(name);                                    \
581         }                                                                       \
582         /***/
583 
584 ///////////////////////////////////////////////////////////////////////////
585 //  Unicode Major Categories
586 ///////////////////////////////////////////////////////////////////////////
587     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(letter)
588     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(mark)
589     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(number)
590     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(separator)
591     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(other)
592     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(punctuation)
593     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(symbol)
594 
595 ///////////////////////////////////////////////////////////////////////////
596 //  Unicode General Categories
597 ///////////////////////////////////////////////////////////////////////////
598     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(uppercase_letter)
599     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lowercase_letter)
600     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(titlecase_letter)
601     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(modifier_letter)
602     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(other_letter)
603 
604     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(nonspacing_mark)
605     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(enclosing_mark)
606     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(spacing_mark)
607 
608     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(decimal_number)
609     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(letter_number)
610     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(other_number)
611 
612     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(space_separator)
613     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(line_separator)
614     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(paragraph_separator)
615 
616     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(control)
617     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(format)
618     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(private_use)
619     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(surrogate)
620     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(unassigned)
621 
622     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(dash_punctuation)
623     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(open_punctuation)
624     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(close_punctuation)
625     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(connector_punctuation)
626     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(other_punctuation)
627     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(initial_punctuation)
628     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(final_punctuation)
629 
630     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(math_symbol)
631     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(currency_symbol)
632     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(modifier_symbol)
633     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(other_symbol)
634 
635 ///////////////////////////////////////////////////////////////////////////
636 //  Unicode Derived Categories
637 ///////////////////////////////////////////////////////////////////////////
638     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(alphabetic)
639     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(uppercase)
640     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lowercase)
641     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(white_space)
642     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(hex_digit)
643     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(noncharacter_code_point)
644     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(default_ignorable_code_point)
645 
646 ///////////////////////////////////////////////////////////////////////////
647 //  Unicode Scripts
648 ///////////////////////////////////////////////////////////////////////////
649     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(arabic)
650     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(imperial_aramaic)
651     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(armenian)
652     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(avestan)
653     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(balinese)
654     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(bamum)
655     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(bengali)
656     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(bopomofo)
657     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(braille)
658     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(buginese)
659     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(buhid)
660     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(canadian_aboriginal)
661     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(carian)
662     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(cham)
663     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(cherokee)
664     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(coptic)
665     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(cypriot)
666     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(cyrillic)
667     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(devanagari)
668     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(deseret)
669     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(egyptian_hieroglyphs)
670     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(ethiopic)
671     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(georgian)
672     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(glagolitic)
673     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(gothic)
674     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(greek)
675     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(gujarati)
676     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(gurmukhi)
677     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(hangul)
678     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(han)
679     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(hanunoo)
680     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(hebrew)
681     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(hiragana)
682     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(katakana_or_hiragana)
683     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(old_italic)
684     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(javanese)
685     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(kayah_li)
686     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(katakana)
687     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(kharoshthi)
688     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(khmer)
689     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(kannada)
690     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(kaithi)
691     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tai_tham)
692     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lao)
693     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(latin)
694     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lepcha)
695     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(limbu)
696     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(linear_b)
697     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lisu)
698     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lycian)
699     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(lydian)
700     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(malayalam)
701     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(mongolian)
702     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(meetei_mayek)
703     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(myanmar)
704     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(nko)
705     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(ogham)
706     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(ol_chiki)
707     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(old_turkic)
708     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(oriya)
709     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(osmanya)
710     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(phags_pa)
711     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(inscriptional_pahlavi)
712     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(phoenician)
713     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(inscriptional_parthian)
714     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(rejang)
715     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(runic)
716     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(samaritan)
717     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(old_south_arabian)
718     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(saurashtra)
719     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(shavian)
720     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(sinhala)
721     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(sundanese)
722     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(syloti_nagri)
723     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(syriac)
724     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tagbanwa)
725     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tai_le)
726     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(new_tai_lue)
727     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tamil)
728     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tai_viet)
729     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(telugu)
730     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tifinagh)
731     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tagalog)
732     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(thaana)
733     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(thai)
734     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(tibetan)
735     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(ugaritic)
736     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(vai)
737     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(old_persian)
738     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(cuneiform)
739     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(yi)
740     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(inherited)
741     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(common)
742     BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT(unknown)
743 
744 #undef BOOST_SPIRIT_UNICODE_CLASSIFY_WHAT
745 #endif
746 
747     };
748 }}}
749 
750 namespace boost { namespace spirit { namespace traits
751 {
752     ///////////////////////////////////////////////////////////////////////////
753     template <typename CharParam, typename CharEncoding>
754     struct ischar
755     {
callboost::spirit::traits::ischar756         static bool call(CharParam const& ch)
757         {
758            return CharEncoding::ischar(int(ch));
759         }
760     };
761 }}}
762 
763 #if defined(BOOST_MSVC)
764 # pragma warning(pop)
765 #endif
766 
767 #endif
768 
769 
770