1 | |
2 | #line 1 "emoji_presentation_scanner.rl" |
3 | // Copyright 2018 The Chromium Authors. All rights reserved. |
4 | // Use of this source code is governed by a BSD-style license that can be |
5 | // found in the LICENSE file. |
6 | |
7 | |
8 | #line 9 "emoji_presentation_scanner.c" |
9 | static const char _emoji_presentation_actions[] = { |
10 | 0, 1, 0, 1, 1, 1, 5, 1, |
11 | 6, 1, 7, 1, 8, 1, 9, 1, |
12 | 10, 1, 11, 2, 2, 3, 2, 2, |
13 | 4 |
14 | }; |
15 | |
16 | static const char _emoji_presentation_key_offsets[] = { |
17 | 0, 5, 7, 14, 18, 20, 21, 24, |
18 | 29, 30, 34, 36 |
19 | }; |
20 | |
21 | static const unsigned char _emoji_presentation_trans_keys[] = { |
22 | 3u, 7u, 13u, 0u, 2u, 14u, 15u, 2u, |
23 | 3u, 6u, 7u, 13u, 0u, 1u, 9u, 10u, |
24 | 11u, 12u, 10u, 12u, 10u, 4u, 10u, 12u, |
25 | 4u, 9u, 10u, 11u, 12u, 6u, 9u, 10u, |
26 | 11u, 12u, 8u, 10u, 9u, 10u, 11u, 12u, |
27 | 14u, 0 |
28 | }; |
29 | |
30 | static const char _emoji_presentation_single_lengths[] = { |
31 | 3, 2, 5, 4, 2, 1, 3, 5, |
32 | 1, 4, 2, 5 |
33 | }; |
34 | |
35 | static const char _emoji_presentation_range_lengths[] = { |
36 | 1, 0, 1, 0, 0, 0, 0, 0, |
37 | 0, 0, 0, 0 |
38 | }; |
39 | |
40 | static const char _emoji_presentation_index_offsets[] = { |
41 | 0, 5, 8, 15, 20, 23, 25, 29, |
42 | 35, 37, 42, 45 |
43 | }; |
44 | |
45 | static const char _emoji_presentation_indicies[] = { |
46 | 2, 1, 1, 1, 0, 4, 5, 3, |
47 | 7, 8, 10, 11, 12, 6, 9, 5, |
48 | 13, 14, 15, 0, 13, 15, 16, 13, |
49 | 16, 15, 13, 15, 16, 15, 5, 13, |
50 | 14, 15, 16, 5, 17, 5, 13, 14, |
51 | 18, 17, 5, 13, 16, 5, 13, 14, |
52 | 15, 4, 16, 0 |
53 | }; |
54 | |
55 | static const char _emoji_presentation_trans_targs[] = { |
56 | 2, 4, 6, 2, 1, 2, 3, 3, |
57 | 7, 2, 8, 9, 11, 0, 2, 5, |
58 | 2, 2, 10 |
59 | }; |
60 | |
61 | static const char _emoji_presentation_trans_actions[] = { |
62 | 17, 19, 19, 15, 0, 7, 22, 19, |
63 | 19, 9, 0, 22, 19, 0, 5, 19, |
64 | 11, 13, 19 |
65 | }; |
66 | |
67 | static const char _emoji_presentation_to_state_actions[] = { |
68 | 0, 0, 1, 0, 0, 0, 0, 0, |
69 | 0, 0, 0, 0 |
70 | }; |
71 | |
72 | static const char _emoji_presentation_from_state_actions[] = { |
73 | 0, 0, 3, 0, 0, 0, 0, 0, |
74 | 0, 0, 0, 0 |
75 | }; |
76 | |
77 | static const char _emoji_presentation_eof_trans[] = { |
78 | 1, 4, 0, 1, 17, 17, 17, 17, |
79 | 18, 18, 17, 17 |
80 | }; |
81 | |
82 | static const int emoji_presentation_start = 2; |
83 | |
84 | static const int emoji_presentation_en_text_and_emoji_run = 2; |
85 | |
86 | |
87 | #line 9 "emoji_presentation_scanner.rl" |
88 | |
89 | |
90 | |
91 | #line 78 "emoji_presentation_scanner.rl" |
92 | |
93 | |
94 | static emoji_text_iter_t |
95 | scan_emoji_presentation (emoji_text_iter_t p, |
96 | const emoji_text_iter_t pe, |
97 | bool* is_emoji) |
98 | { |
99 | emoji_text_iter_t te; |
100 | const emoji_text_iter_t eof = pe; |
101 | |
102 | unsigned act; |
103 | int cs; |
104 | |
105 | |
106 | #line 107 "emoji_presentation_scanner.c" |
107 | { |
108 | cs = emoji_presentation_start; |
109 | te = 0; |
110 | act = 0; |
111 | } |
112 | |
113 | #line 115 "emoji_presentation_scanner.c" |
114 | { |
115 | int _klen; |
116 | unsigned int _trans; |
117 | const char *_acts; |
118 | unsigned int _nacts; |
119 | const unsigned char *_keys; |
120 | |
121 | if ( p == pe ) |
122 | goto _test_eof; |
123 | _resume: |
124 | _acts = _emoji_presentation_actions + _emoji_presentation_from_state_actions[cs]; |
125 | _nacts = (unsigned int) *_acts++; |
126 | while ( _nacts-- > 0 ) { |
127 | switch ( *_acts++ ) { |
128 | case 1: |
129 | #line 1 "NONE" |
130 | break; |
131 | #line 134 "emoji_presentation_scanner.c" |
132 | } |
133 | } |
134 | |
135 | _keys = _emoji_presentation_trans_keys + _emoji_presentation_key_offsets[cs]; |
136 | _trans = _emoji_presentation_index_offsets[cs]; |
137 | |
138 | _klen = _emoji_presentation_single_lengths[cs]; |
139 | if ( _klen > 0 ) { |
140 | const unsigned char *_lower = _keys; |
141 | const unsigned char *_mid; |
142 | const unsigned char *_upper = _keys + _klen - 1; |
143 | while (1) { |
144 | if ( _upper < _lower ) |
145 | break; |
146 | |
147 | _mid = _lower + ((_upper-_lower) >> 1); |
148 | if ( (*p) < *_mid ) |
149 | _upper = _mid - 1; |
150 | else if ( (*p) > *_mid ) |
151 | _lower = _mid + 1; |
152 | else { |
153 | _trans += (unsigned int)(_mid - _keys); |
154 | goto _match; |
155 | } |
156 | } |
157 | _keys += _klen; |
158 | _trans += _klen; |
159 | } |
160 | |
161 | _klen = _emoji_presentation_range_lengths[cs]; |
162 | if ( _klen > 0 ) { |
163 | const unsigned char *_lower = _keys; |
164 | const unsigned char *_mid; |
165 | const unsigned char *_upper = _keys + (_klen<<1) - 2; |
166 | while (1) { |
167 | if ( _upper < _lower ) |
168 | break; |
169 | |
170 | _mid = _lower + (((_upper-_lower) >> 1) & ~1); |
171 | if ( (*p) < _mid[0] ) |
172 | _upper = _mid - 2; |
173 | else if ( (*p) > _mid[1] ) |
174 | _lower = _mid + 2; |
175 | else { |
176 | _trans += (unsigned int)((_mid - _keys)>>1); |
177 | goto _match; |
178 | } |
179 | } |
180 | _trans += _klen; |
181 | } |
182 | |
183 | _match: |
184 | _trans = _emoji_presentation_indicies[_trans]; |
185 | _eof_trans: |
186 | cs = _emoji_presentation_trans_targs[_trans]; |
187 | |
188 | if ( _emoji_presentation_trans_actions[_trans] == 0 ) |
189 | goto _again; |
190 | |
191 | _acts = _emoji_presentation_actions + _emoji_presentation_trans_actions[_trans]; |
192 | _nacts = (unsigned int) *_acts++; |
193 | while ( _nacts-- > 0 ) |
194 | { |
195 | switch ( *_acts++ ) |
196 | { |
197 | case 2: |
198 | #line 1 "NONE" |
199 | {te = p+1;} |
200 | break; |
201 | case 3: |
202 | #line 74 "emoji_presentation_scanner.rl" |
203 | {act = 2;} |
204 | break; |
205 | case 4: |
206 | #line 75 "emoji_presentation_scanner.rl" |
207 | {act = 3;} |
208 | break; |
209 | case 5: |
210 | #line 73 "emoji_presentation_scanner.rl" |
211 | {te = p+1;{ *is_emoji = false; return te; }} |
212 | break; |
213 | case 6: |
214 | #line 74 "emoji_presentation_scanner.rl" |
215 | {te = p+1;{ *is_emoji = true; return te; }} |
216 | break; |
217 | case 7: |
218 | #line 75 "emoji_presentation_scanner.rl" |
219 | {te = p+1;{ *is_emoji = false; return te; }} |
220 | break; |
221 | case 8: |
222 | #line 74 "emoji_presentation_scanner.rl" |
223 | {te = p;p--;{ *is_emoji = true; return te; }} |
224 | break; |
225 | case 9: |
226 | #line 75 "emoji_presentation_scanner.rl" |
227 | {te = p;p--;{ *is_emoji = false; return te; }} |
228 | break; |
229 | case 10: |
230 | #line 74 "emoji_presentation_scanner.rl" |
231 | {{p = ((te))-1;}{ *is_emoji = true; return te; }} |
232 | break; |
233 | case 11: |
234 | #line 1 "NONE" |
235 | { switch( act ) { |
236 | case 2: |
237 | {{p = ((te))-1;} *is_emoji = true; return te; } |
238 | break; |
239 | case 3: |
240 | {{p = ((te))-1;} *is_emoji = false; return te; } |
241 | break; |
242 | } |
243 | } |
244 | break; |
245 | #line 248 "emoji_presentation_scanner.c" |
246 | } |
247 | } |
248 | |
249 | _again: |
250 | _acts = _emoji_presentation_actions + _emoji_presentation_to_state_actions[cs]; |
251 | _nacts = (unsigned int) *_acts++; |
252 | while ( _nacts-- > 0 ) { |
253 | switch ( *_acts++ ) { |
254 | case 0: |
255 | #line 1 "NONE" |
256 | break; |
257 | #line 261 "emoji_presentation_scanner.c" |
258 | } |
259 | } |
260 | |
261 | if ( ++p != pe ) |
262 | goto _resume; |
263 | _test_eof: {} |
264 | if ( p == eof ) |
265 | { |
266 | if ( _emoji_presentation_eof_trans[cs] > 0 ) { |
267 | _trans = _emoji_presentation_eof_trans[cs] - 1; |
268 | goto _eof_trans; |
269 | } |
270 | } |
271 | |
272 | } |
273 | |
274 | #line 94 "emoji_presentation_scanner.rl" |
275 | |
276 | |
277 | /* Should not be reached. */ |
278 | *is_emoji = false; |
279 | return pe; |
280 | } |
281 | |