1// re2c $INPUT -o $OUTPUT -u --encoding-policy ignore 2#include <stdio.h> 3 4#define YYCTYPE unsigned int 5bool scan(const YYCTYPE * start, const YYCTYPE * const limit) 6{ 7 __attribute__((unused)) const YYCTYPE * YYMARKER; // silence compiler warnings when YYMARKER is not used 8# define YYCURSOR start 9Pc: 10 /*!re2c 11 re2c:yyfill:enable = 0; 12 Pc = [\x5f-\x5f\u203f-\u2040\u2054-\u2054\ufe33-\ufe34\ufe4d-\ufe4f\uff3f-\uff3f]; 13 Pc { goto Pc; } 14 * { return YYCURSOR == limit; } 15 */ 16} 17static const unsigned int chars_Pc [] = {0x5f,0x5f, 0x203f,0x2040, 0x2054,0x2054, 0xfe33,0xfe34, 0xfe4d,0xfe4f, 0xff3f,0xff3f, 0x0,0x0}; 18static unsigned int encode_utf32 (const unsigned int * ranges, unsigned int ranges_count, unsigned int * s) 19{ 20 unsigned int * const s_start = s; 21 for (unsigned int i = 0; i < ranges_count; i += 2) 22 for (unsigned int j = ranges[i]; j <= ranges[i + 1]; ++j) 23 *s++ = j; 24 return s - s_start; 25} 26 27int main () 28{ 29 unsigned int * buffer_Pc = new unsigned int [11]; 30 YYCTYPE * s = (YYCTYPE *) buffer_Pc; 31 unsigned int buffer_len = encode_utf32 (chars_Pc, sizeof (chars_Pc) / sizeof (unsigned int), buffer_Pc); 32 /* convert 32-bit code units to YYCTYPE; reuse the same buffer */ 33 for (unsigned int i = 0; i < buffer_len; ++i) s[i] = buffer_Pc[i]; 34 if (!scan (s, s + buffer_len)) 35 printf("test 'Pc' failed\n"); 36 delete [] buffer_Pc; 37 return 0; 38} 39