1// re2c $INPUT -o $OUTPUT -8 --encoding-policy ignore
2#include <stdio.h>
3#include "utf8.h"
4#define YYCTYPE unsigned char
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
9Sm:
10	/*!re2c
11		re2c:yyfill:enable = 0;
12		Sm = [\x2b-\x2b\x3c-\x3e\x7c-\x7c\x7e-\x7e\xac-\xac\xb1-\xb1\xd7-\xd7\xf7-\xf7\u03f6-\u03f6\u0606-\u0608\u2044-\u2044\u2052-\u2052\u207a-\u207c\u208a-\u208c\u2118-\u2118\u2140-\u2144\u214b-\u214b\u2190-\u2194\u219a-\u219b\u21a0-\u21a0\u21a3-\u21a3\u21a6-\u21a6\u21ae-\u21ae\u21ce-\u21cf\u21d2-\u21d2\u21d4-\u21d4\u21f4-\u22ff\u2320-\u2321\u237c-\u237c\u239b-\u23b3\u23dc-\u23e1\u25b7-\u25b7\u25c1-\u25c1\u25f8-\u25ff\u266f-\u266f\u27c0-\u27c4\u27c7-\u27e5\u27f0-\u27ff\u2900-\u2982\u2999-\u29d7\u29dc-\u29fb\u29fe-\u2aff\u2b30-\u2b44\u2b47-\u2b4c\ufb29-\ufb29\ufe62-\ufe62\ufe64-\ufe66\uff0b-\uff0b\uff1c-\uff1e\uff5c-\uff5c\uff5e-\uff5e\uffe2-\uffe2\uffe9-\uffec\U0001d6c1-\U0001d6c1\U0001d6db-\U0001d6db\U0001d6fb-\U0001d6fb\U0001d715-\U0001d715\U0001d735-\U0001d735\U0001d74f-\U0001d74f\U0001d76f-\U0001d76f\U0001d789-\U0001d789\U0001d7a9-\U0001d7a9\U0001d7c3-\U0001d7c3\U0001eef0-\U0001eef1];
13		Sm { goto Sm; }
14		* { return YYCURSOR == limit; }
15	*/
16}
17static const unsigned int chars_Sm [] = {0x2b,0x2b,  0x3c,0x3e,  0x7c,0x7c,  0x7e,0x7e,  0xac,0xac,  0xb1,0xb1,  0xd7,0xd7,  0xf7,0xf7,  0x3f6,0x3f6,  0x606,0x608,  0x2044,0x2044,  0x2052,0x2052,  0x207a,0x207c,  0x208a,0x208c,  0x2118,0x2118,  0x2140,0x2144,  0x214b,0x214b,  0x2190,0x2194,  0x219a,0x219b,  0x21a0,0x21a0,  0x21a3,0x21a3,  0x21a6,0x21a6,  0x21ae,0x21ae,  0x21ce,0x21cf,  0x21d2,0x21d2,  0x21d4,0x21d4,  0x21f4,0x22ff,  0x2320,0x2321,  0x237c,0x237c,  0x239b,0x23b3,  0x23dc,0x23e1,  0x25b7,0x25b7,  0x25c1,0x25c1,  0x25f8,0x25ff,  0x266f,0x266f,  0x27c0,0x27c4,  0x27c7,0x27e5,  0x27f0,0x27ff,  0x2900,0x2982,  0x2999,0x29d7,  0x29dc,0x29fb,  0x29fe,0x2aff,  0x2b30,0x2b44,  0x2b47,0x2b4c,  0xfb29,0xfb29,  0xfe62,0xfe62,  0xfe64,0xfe66,  0xff0b,0xff0b,  0xff1c,0xff1e,  0xff5c,0xff5c,  0xff5e,0xff5e,  0xffe2,0xffe2,  0xffe9,0xffec,  0x1d6c1,0x1d6c1,  0x1d6db,0x1d6db,  0x1d6fb,0x1d6fb,  0x1d715,0x1d715,  0x1d735,0x1d735,  0x1d74f,0x1d74f,  0x1d76f,0x1d76f,  0x1d789,0x1d789,  0x1d7a9,0x1d7a9,  0x1d7c3,0x1d7c3,  0x1eef0,0x1eef1,  0x0,0x0};
18static unsigned int encode_utf8 (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 - 2; i += 2)
22		for (unsigned int j = ranges[i]; j <= ranges[i + 1]; ++j)
23			s += re2c::utf8::rune_to_bytes (s, j);
24	re2c::utf8::rune_to_bytes (s, ranges[ranges_count - 1]);
25	return s - s_start + 1;
26}
27
28int main ()
29{
30	unsigned int * buffer_Sm = new unsigned int [3796];
31	YYCTYPE * s = (YYCTYPE *) buffer_Sm;
32	unsigned int buffer_len = encode_utf8 (chars_Sm, sizeof (chars_Sm) / sizeof (unsigned int), buffer_Sm);
33	/* convert 32-bit code units to YYCTYPE; reuse the same buffer */
34	for (unsigned int i = 0; i < buffer_len; ++i) s[i] = buffer_Sm[i];
35	if (!scan (s, s + buffer_len))
36		printf("test 'Sm' failed\n");
37	delete [] buffer_Sm;
38	return 0;
39}
40