1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/* Generated by re2c */
#line 1 "unicode_group_Ps.8--encoding-policy(substitute).re"
#include <stdio.h>
#include "utf8.h"
#define YYCTYPE unsigned char
bool scan(const YYCTYPE * start, const YYCTYPE * const limit)
{
__attribute__((unused)) const YYCTYPE * YYMARKER; // silence compiler warnings when YYMARKER is not used
# define YYCURSOR start
Ps:
#line 13 "unicode_group_Ps.8--encoding-policy(substitute).c"
{
YYCTYPE yych;
yych = *YYCURSOR;
switch (yych) {
case '(':
case '[':
case '{': goto yy4;
case 0xE0: goto yy6;
case 0xE1: goto yy7;
case 0xE2: goto yy8;
case 0xE3: goto yy9;
case 0xEF: goto yy10;
default: goto yy2;
}
yy2:
++YYCURSOR;
yy3:
#line 13 "unicode_group_Ps.8--encoding-policy(substitute).re"
{ return YYCURSOR == limit; }
#line 33 "unicode_group_Ps.8--encoding-policy(substitute).c"
yy4:
++YYCURSOR;
#line 12 "unicode_group_Ps.8--encoding-policy(substitute).re"
{ goto Ps; }
#line 38 "unicode_group_Ps.8--encoding-policy(substitute).c"
yy6:
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
case 0xBC: goto yy11;
default: goto yy3;
}
yy7:
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
case 0x9A: goto yy13;
default: goto yy3;
}
yy8:
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
case 0x80: goto yy14;
case 0x81: goto yy15;
case 0x82: goto yy16;
case 0x8C: goto yy17;
case 0x9D: goto yy18;
case 0x9F: goto yy19;
case 0xA6: goto yy20;
case 0xA7: goto yy21;
case 0xB8: goto yy22;
default: goto yy3;
}
yy9:
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
case 0x80: goto yy23;
default: goto yy3;
}
yy10:
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
case 0xB4: goto yy24;
case 0xB8: goto yy25;
case 0xB9: goto yy26;
case 0xBC: goto yy27;
case 0xBD: goto yy28;
default: goto yy3;
}
yy11:
yych = *++YYCURSOR;
switch (yych) {
case 0xBA:
case 0xBC: goto yy4;
default: goto yy12;
}
yy12:
YYCURSOR = YYMARKER;
goto yy3;
yy13:
yych = *++YYCURSOR;
switch (yych) {
case 0x9B: goto yy4;
default: goto yy12;
}
yy14:
yych = *++YYCURSOR;
switch (yych) {
case 0x9A:
case 0x9E: goto yy4;
default: goto yy12;
}
yy15:
yych = *++YYCURSOR;
switch (yych) {
case 0x85:
case 0xBD: goto yy4;
default: goto yy12;
}
yy16:
yych = *++YYCURSOR;
switch (yych) {
case 0x8D: goto yy4;
default: goto yy12;
}
yy17:
yych = *++YYCURSOR;
switch (yych) {
case 0xA9: goto yy4;
default: goto yy12;
}
yy18:
yych = *++YYCURSOR;
switch (yych) {
case 0xA8:
case 0xAA:
case 0xAC:
case 0xAE:
case 0xB0:
case 0xB2:
case 0xB4: goto yy4;
default: goto yy12;
}
yy19:
yych = *++YYCURSOR;
switch (yych) {
case 0x85:
case 0xA6:
case 0xA8:
case 0xAA:
case 0xAC:
case 0xAE: goto yy4;
default: goto yy12;
}
yy20:
yych = *++YYCURSOR;
switch (yych) {
case 0x83:
case 0x85:
case 0x87:
case 0x89:
case 0x8B:
case 0x8D:
case 0x8F:
case 0x91:
case 0x93:
case 0x95:
case 0x97: goto yy4;
default: goto yy12;
}
yy21:
yych = *++YYCURSOR;
switch (yych) {
case 0x98:
case 0x9A:
case 0xBC: goto yy4;
default: goto yy12;
}
yy22:
yych = *++YYCURSOR;
switch (yych) {
case 0xA2:
case 0xA4:
case 0xA6:
case 0xA8: goto yy4;
default: goto yy12;
}
yy23:
yych = *++YYCURSOR;
switch (yych) {
case 0x88:
case 0x8A:
case 0x8C:
case 0x8E:
case 0x90:
case 0x94:
case 0x96:
case 0x98:
case 0x9A:
case 0x9D: goto yy4;
default: goto yy12;
}
yy24:
yych = *++YYCURSOR;
switch (yych) {
case 0xBE: goto yy4;
default: goto yy12;
}
yy25:
yych = *++YYCURSOR;
switch (yych) {
case 0x97:
case 0xB5:
case 0xB7:
case 0xB9:
case 0xBB:
case 0xBD:
case 0xBF: goto yy4;
default: goto yy12;
}
yy26:
yych = *++YYCURSOR;
switch (yych) {
case 0x81:
case 0x83:
case 0x87:
case 0x99:
case 0x9B:
case 0x9D: goto yy4;
default: goto yy12;
}
yy27:
yych = *++YYCURSOR;
switch (yych) {
case 0x88:
case 0xBB: goto yy4;
default: goto yy12;
}
yy28:
yych = *++YYCURSOR;
switch (yych) {
case 0x9B:
case 0x9F:
case 0xA2: goto yy4;
default: goto yy12;
}
}
#line 14 "unicode_group_Ps.8--encoding-policy(substitute).re"
}
static const unsigned int chars_Ps [] = {0x28,0x28, 0x5b,0x5b, 0x7b,0x7b, 0xf3a,0xf3a, 0xf3c,0xf3c, 0x169b,0x169b, 0x201a,0x201a, 0x201e,0x201e, 0x2045,0x2045, 0x207d,0x207d, 0x208d,0x208d, 0x2329,0x2329, 0x2768,0x2768, 0x276a,0x276a, 0x276c,0x276c, 0x276e,0x276e, 0x2770,0x2770, 0x2772,0x2772, 0x2774,0x2774, 0x27c5,0x27c5, 0x27e6,0x27e6, 0x27e8,0x27e8, 0x27ea,0x27ea, 0x27ec,0x27ec, 0x27ee,0x27ee, 0x2983,0x2983, 0x2985,0x2985, 0x2987,0x2987, 0x2989,0x2989, 0x298b,0x298b, 0x298d,0x298d, 0x298f,0x298f, 0x2991,0x2991, 0x2993,0x2993, 0x2995,0x2995, 0x2997,0x2997, 0x29d8,0x29d8, 0x29da,0x29da, 0x29fc,0x29fc, 0x2e22,0x2e22, 0x2e24,0x2e24, 0x2e26,0x2e26, 0x2e28,0x2e28, 0x3008,0x3008, 0x300a,0x300a, 0x300c,0x300c, 0x300e,0x300e, 0x3010,0x3010, 0x3014,0x3014, 0x3016,0x3016, 0x3018,0x3018, 0x301a,0x301a, 0x301d,0x301d, 0xfd3e,0xfd3e, 0xfe17,0xfe17, 0xfe35,0xfe35, 0xfe37,0xfe37, 0xfe39,0xfe39, 0xfe3b,0xfe3b, 0xfe3d,0xfe3d, 0xfe3f,0xfe3f, 0xfe41,0xfe41, 0xfe43,0xfe43, 0xfe47,0xfe47, 0xfe59,0xfe59, 0xfe5b,0xfe5b, 0xfe5d,0xfe5d, 0xff08,0xff08, 0xff3b,0xff3b, 0xff5b,0xff5b, 0xff5f,0xff5f, 0xff62,0xff62, 0x0,0x0};
static unsigned int encode_utf8 (const unsigned int * ranges, unsigned int ranges_count, unsigned char * s)
{
unsigned char * const s_start = s;
for (unsigned int i = 0; i < ranges_count - 2; i += 2)
for (unsigned int j = ranges[i]; j <= ranges[i + 1]; ++j)
s += re2c::utf8::rune_to_bytes (s, j);
re2c::utf8::rune_to_bytes (s, ranges[ranges_count - 1]);
return s - s_start + 1;
}
int main ()
{
YYCTYPE * buffer_Ps = new YYCTYPE [292];
unsigned int buffer_len = encode_utf8 (chars_Ps, sizeof (chars_Ps) / sizeof (unsigned int), buffer_Ps);
if (!scan (reinterpret_cast<const YYCTYPE *> (buffer_Ps), reinterpret_cast<const YYCTYPE *> (buffer_Ps + buffer_len)))
printf("test 'Ps' failed\n");
delete [] buffer_Ps;
return 0;
}
|