/src/qtbase/src/3rdparty/emoji-segmenter/emoji_presentation_scanner.c
Line | Count | Source |
1 | | |
2 | | #line 1 "emoji_presentation_scanner.rl" |
3 | | /* Copyright 2019 Google LLC |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at |
8 | | * |
9 | | * https://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #include <stdbool.h> |
19 | | |
20 | | #ifndef EMOJI_LINKAGE |
21 | | #define EMOJI_LINKAGE static |
22 | | #endif |
23 | | |
24 | | |
25 | | #line 23 "emoji_presentation_scanner.c" |
26 | | static const unsigned char _emoji_presentation_trans_keys[] = { |
27 | | 0u, 13u, 14u, 15u, 0u, 13u, 9u, 12u, 10u, 12u, 10u, 10u, 4u, 12u, 4u, 12u, |
28 | | 6u, 6u, 9u, 12u, 8u, 8u, 8u, 10u, 9u, 14u, 0 |
29 | | }; |
30 | | |
31 | | static const char _emoji_presentation_key_spans[] = { |
32 | | 14, 2, 14, 4, 3, 1, 9, 9, |
33 | | 1, 4, 1, 3, 6 |
34 | | }; |
35 | | |
36 | | static const char _emoji_presentation_index_offsets[] = { |
37 | | 0, 15, 18, 33, 38, 42, 44, 54, |
38 | | 64, 66, 71, 73, 77 |
39 | | }; |
40 | | |
41 | | static const char _emoji_presentation_indicies[] = { |
42 | | 1, 1, 1, 2, 0, 0, 0, 1, |
43 | | 0, 0, 0, 0, 0, 1, 0, 4, |
44 | | 5, 3, 6, 6, 7, 8, 9, 9, |
45 | | 10, 11, 9, 9, 9, 9, 9, 12, |
46 | | 9, 5, 13, 14, 15, 0, 13, 16, |
47 | | 17, 16, 13, 0, 17, 16, 16, 16, |
48 | | 16, 16, 13, 16, 17, 16, 17, 16, |
49 | | 16, 16, 16, 5, 13, 14, 15, 16, |
50 | | 5, 18, 5, 13, 19, 20, 18, 14, |
51 | | 21, 23, 22, 13, 22, 5, 13, 14, |
52 | | 15, 16, 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, 12, 0, 2, 5, |
58 | | 2, 5, 2, 10, 11, 2, 2, 2 |
59 | | }; |
60 | | |
61 | | static const char _emoji_presentation_trans_actions[] = { |
62 | | 1, 2, 2, 3, 0, 4, 7, 2, |
63 | | 2, 8, 0, 7, 2, 0, 9, 10, |
64 | | 11, 2, 12, 0, 10, 13, 14, 15 |
65 | | }; |
66 | | |
67 | | static const char _emoji_presentation_to_state_actions[] = { |
68 | | 0, 0, 5, 0, 0, 0, 0, 0, |
69 | | 0, 0, 0, 0, 0 |
70 | | }; |
71 | | |
72 | | static const char _emoji_presentation_from_state_actions[] = { |
73 | | 0, 0, 6, 0, 0, 0, 0, 0, |
74 | | 0, 0, 0, 0, 0 |
75 | | }; |
76 | | |
77 | | static const char _emoji_presentation_eof_trans[] = { |
78 | | 1, 4, 0, 1, 17, 1, 17, 17, |
79 | | 19, 19, 22, 23, 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 26 "emoji_presentation_scanner.rl" |
88 | | |
89 | | |
90 | | |
91 | | #line 100 "emoji_presentation_scanner.rl" |
92 | | |
93 | | |
94 | | EMOJI_LINKAGE 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 | | bool* has_vs) |
99 | 0 | { |
100 | 0 | emoji_text_iter_t ts; |
101 | 0 | emoji_text_iter_t te; |
102 | 0 | const emoji_text_iter_t eof = pe; |
103 | |
|
104 | 0 | (void)ts; |
105 | |
|
106 | 0 | unsigned act; |
107 | 0 | int cs; |
108 | | |
109 | | |
110 | 0 | #line 100 "emoji_presentation_scanner.c" |
111 | 0 | { |
112 | 0 | cs = emoji_presentation_start; |
113 | 0 | ts = 0; |
114 | 0 | te = 0; |
115 | 0 | act = 0; |
116 | 0 | } |
117 | |
|
118 | 0 | #line 106 "emoji_presentation_scanner.c" |
119 | 0 | { |
120 | 0 | int _slen; |
121 | 0 | int _trans; |
122 | 0 | const unsigned char *_keys; |
123 | 0 | const char *_inds; |
124 | 0 | if ( p == pe ) |
125 | 0 | goto _test_eof; |
126 | 0 | _resume: |
127 | 0 | switch ( _emoji_presentation_from_state_actions[cs] ) { |
128 | 0 | case 6: |
129 | 0 | #line 1 "NONE" |
130 | 0 | {ts = p;} |
131 | 0 | break; |
132 | 0 | #line 118 "emoji_presentation_scanner.c" |
133 | 0 | } |
134 | | |
135 | 0 | _keys = _emoji_presentation_trans_keys + (cs<<1); |
136 | 0 | _inds = _emoji_presentation_indicies + _emoji_presentation_index_offsets[cs]; |
137 | |
|
138 | 0 | _slen = _emoji_presentation_key_spans[cs]; |
139 | 0 | _trans = _inds[ _slen > 0 && _keys[0] <=(*p) && |
140 | 0 | (*p) <= _keys[1] ? |
141 | 0 | (*p) - _keys[0] : _slen ]; |
142 | |
|
143 | 0 | _eof_trans: |
144 | 0 | cs = _emoji_presentation_trans_targs[_trans]; |
145 | |
|
146 | 0 | if ( _emoji_presentation_trans_actions[_trans] == 0 ) |
147 | 0 | goto _again; |
148 | | |
149 | 0 | switch ( _emoji_presentation_trans_actions[_trans] ) { |
150 | 0 | case 9: |
151 | 0 | #line 94 "emoji_presentation_scanner.rl" |
152 | 0 | {te = p+1;{ *is_emoji = false; *has_vs = true; return te; }} |
153 | 0 | break; |
154 | 0 | case 15: |
155 | 0 | #line 95 "emoji_presentation_scanner.rl" |
156 | 0 | {te = p+1;{ *is_emoji = true; *has_vs = true; return te; }} |
157 | 0 | break; |
158 | 0 | case 4: |
159 | 0 | #line 96 "emoji_presentation_scanner.rl" |
160 | 0 | {te = p+1;{ *is_emoji = true; *has_vs = false; return te; }} |
161 | 0 | break; |
162 | 0 | case 8: |
163 | 0 | #line 97 "emoji_presentation_scanner.rl" |
164 | 0 | {te = p+1;{ *is_emoji = false; *has_vs = false; return te; }} |
165 | 0 | break; |
166 | 0 | case 13: |
167 | 0 | #line 94 "emoji_presentation_scanner.rl" |
168 | 0 | {te = p;p--;{ *is_emoji = false; *has_vs = true; return te; }} |
169 | 0 | break; |
170 | 0 | case 14: |
171 | 0 | #line 95 "emoji_presentation_scanner.rl" |
172 | 0 | {te = p;p--;{ *is_emoji = true; *has_vs = true; return te; }} |
173 | 0 | break; |
174 | 0 | case 11: |
175 | 0 | #line 96 "emoji_presentation_scanner.rl" |
176 | 0 | {te = p;p--;{ *is_emoji = true; *has_vs = false; return te; }} |
177 | 0 | break; |
178 | 0 | case 12: |
179 | 0 | #line 97 "emoji_presentation_scanner.rl" |
180 | 0 | {te = p;p--;{ *is_emoji = false; *has_vs = false; return te; }} |
181 | 0 | break; |
182 | 0 | case 3: |
183 | 0 | #line 96 "emoji_presentation_scanner.rl" |
184 | 0 | {{p = ((te))-1;}{ *is_emoji = true; *has_vs = false; return te; }} |
185 | 0 | break; |
186 | 0 | case 1: |
187 | 0 | #line 1 "NONE" |
188 | 0 | { switch( act ) { |
189 | 0 | case 2: |
190 | 0 | {{p = ((te))-1;} *is_emoji = true; *has_vs = true; return te; } |
191 | 0 | break; |
192 | 0 | case 3: |
193 | 0 | {{p = ((te))-1;} *is_emoji = true; *has_vs = false; return te; } |
194 | 0 | break; |
195 | 0 | case 4: |
196 | 0 | {{p = ((te))-1;} *is_emoji = false; *has_vs = false; return te; } |
197 | 0 | break; |
198 | 0 | } |
199 | 0 | } |
200 | 0 | break; |
201 | 0 | case 10: |
202 | 0 | #line 1 "NONE" |
203 | 0 | {te = p+1;} |
204 | 0 | #line 95 "emoji_presentation_scanner.rl" |
205 | 0 | {act = 2;} |
206 | 0 | break; |
207 | 0 | case 2: |
208 | 0 | #line 1 "NONE" |
209 | 0 | {te = p+1;} |
210 | 0 | #line 96 "emoji_presentation_scanner.rl" |
211 | 0 | {act = 3;} |
212 | 0 | break; |
213 | 0 | case 7: |
214 | 0 | #line 1 "NONE" |
215 | 0 | {te = p+1;} |
216 | 0 | #line 97 "emoji_presentation_scanner.rl" |
217 | 0 | {act = 4;} |
218 | 0 | break; |
219 | 0 | #line 188 "emoji_presentation_scanner.c" |
220 | 0 | } |
221 | | |
222 | 0 | _again: |
223 | 0 | switch ( _emoji_presentation_to_state_actions[cs] ) { |
224 | 0 | case 5: |
225 | 0 | #line 1 "NONE" |
226 | 0 | {ts = 0;} |
227 | 0 | break; |
228 | 0 | #line 195 "emoji_presentation_scanner.c" |
229 | 0 | } |
230 | | |
231 | 0 | if ( ++p != pe ) |
232 | 0 | goto _resume; |
233 | 0 | _test_eof: {} |
234 | 0 | if ( p == eof ) |
235 | 0 | { |
236 | 0 | if ( _emoji_presentation_eof_trans[cs] > 0 ) { |
237 | 0 | _trans = _emoji_presentation_eof_trans[cs] - 1; |
238 | 0 | goto _eof_trans; |
239 | 0 | } |
240 | 0 | } |
241 | |
|
242 | 0 | } |
243 | | |
244 | 0 | #line 118 "emoji_presentation_scanner.rl" |
245 | | |
246 | | |
247 | | /* Should not be reached. */ |
248 | 0 | *is_emoji = false; |
249 | 0 | *has_vs = false; |
250 | 0 | return p; |
251 | 0 | } |