1#![allow(
2 dead_code,
3 non_upper_case_globals,
4 unused_assignments,
5 unused_parens,
6 while_true,
7 clippy::assign_op_pattern,
8 clippy::collapsible_if,
9 clippy::comparison_chain,
10 clippy::double_parens,
11 clippy::unnecessary_cast,
12 clippy::single_match,
13 clippy::never_loop
14)]
15
16use super::buffer::{hb_buffer_t, HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE};
17
18static _myanmar_syllable_machine_trans_keys: [u8; 108] = [
19 0, 22, 1, 22, 3, 22, 3, 22, 1, 22, 3, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 0, 8, 1,
20 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 3, 22,
21 1, 22, 3, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 0, 8, 1, 22, 1, 22, 1, 22, 1, 22, 1,
22 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 0, 22, 0, 8, 0, 0,
23];
24static _myanmar_syllable_machine_char_class: [i8; 59] = [
25 0, 0, 1, 2, 3, 3, 4, 5, 6, 7, 7, 4, 4, 4, 8, 4, 4, 9, 4, 10, 11, 12, 13, 4, 4, 4, 4, 4, 4, 4,
26 4, 14, 4, 4, 15, 16, 17, 18, 19, 20, 21, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 22, 0, 0,
27];
28static _myanmar_syllable_machine_index_offsets: [i16; 55] = [
29 0, 23, 45, 65, 85, 107, 127, 149, 171, 193, 215, 237, 257, 266, 288, 310, 332, 354, 376, 398,
30 420, 442, 464, 486, 508, 530, 550, 570, 592, 612, 634, 656, 678, 700, 722, 742, 751, 773, 795,
31 817, 839, 861, 883, 905, 927, 949, 971, 993, 1015, 1037, 1059, 1081, 1104, 0, 0,
32];
33static _myanmar_syllable_machine_indices: [i8; 1115] = [
34 2, 3, 4, 5, 1, 6, 7, 2, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26,
35 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 27, 26, 23, 27, 23, 23,
36 23, 23, 23, 23, 23, 32, 41, 23, 23, 23, 23, 38, 23, 23, 27, 26, 23, 27, 23, 23, 23, 23, 23, 23,
37 23, 23, 23, 23, 23, 23, 23, 38, 23, 23, 27, 42, 23, 26, 23, 27, 38, 23, 23, 23, 23, 23, 23, 23,
38 27, 23, 23, 23, 23, 38, 23, 23, 27, 26, 23, 27, 23, 23, 23, 23, 23, 23, 23, 23, 27, 23, 23, 23,
39 23, 38, 23, 23, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 43, 23, 23, 32, 44, 45, 23, 23, 23, 38,
40 23, 44, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 23, 23, 23, 32, 23, 23, 23, 23, 23, 38, 23, 23,
41 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 43, 23, 23, 32, 23, 23, 23, 23, 23, 38, 23, 23, 27, 24,
42 23, 26, 23, 27, 28, 23, 23, 23, 43, 23, 23, 32, 44, 23, 23, 23, 23, 38, 23, 23, 27, 24, 23, 26,
43 23, 27, 28, 23, 23, 23, 43, 23, 23, 32, 44, 23, 23, 23, 23, 38, 23, 44, 27, 26, 23, 27, 23, 23,
44 23, 23, 23, 23, 23, 32, 23, 23, 23, 23, 23, 38, 23, 23, 27, 2, 23, 23, 23, 23, 23, 23, 23, 2,
45 24, 23, 26, 23, 27, 28, 23, 23, 23, 29, 30, 23, 32, 23, 23, 23, 23, 23, 38, 23, 23, 27, 24, 23,
46 26, 23, 27, 28, 23, 23, 23, 23, 30, 23, 32, 23, 23, 23, 23, 23, 38, 23, 23, 27, 24, 23, 26, 23,
47 27, 28, 23, 23, 23, 29, 30, 31, 32, 23, 23, 23, 23, 23, 38, 46, 23, 27, 24, 23, 26, 23, 27, 28,
48 23, 23, 23, 29, 30, 31, 32, 23, 23, 23, 23, 23, 38, 23, 23, 27, 24, 23, 26, 23, 27, 28, 23, 23,
49 23, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 23, 40, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 29,
50 30, 31, 32, 46, 23, 23, 23, 23, 38, 23, 40, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31,
51 32, 46, 23, 23, 23, 23, 38, 23, 23, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 23,
52 34, 23, 36, 23, 38, 23, 40, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 46, 34, 23,
53 23, 23, 38, 23, 40, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 47, 34, 35, 36, 23,
54 38, 23, 40, 27, 24, 23, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 23, 34, 35, 36, 23, 38, 23,
55 40, 27, 24, 25, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 23, 40, 27,
56 49, 48, 6, 48, 48, 48, 48, 48, 48, 48, 13, 50, 48, 48, 48, 48, 19, 48, 48, 6, 49, 51, 6, 51,
57 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 19, 51, 51, 6, 52, 48, 49, 48, 6, 19, 48, 48,
58 48, 48, 48, 48, 48, 6, 48, 48, 48, 48, 19, 48, 48, 6, 49, 48, 6, 48, 48, 48, 48, 48, 48, 48,
59 48, 6, 48, 48, 48, 48, 19, 48, 48, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 53, 48, 48, 13, 54, 55,
60 48, 48, 48, 19, 48, 54, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 48, 48, 48, 13, 48, 48, 48, 48, 48,
61 19, 48, 48, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 53, 48, 48, 13, 48, 48, 48, 48, 48, 19, 48, 48,
62 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 53, 48, 48, 13, 54, 48, 48, 48, 48, 19, 48, 48, 6, 3, 48,
63 49, 48, 6, 7, 48, 48, 48, 53, 48, 48, 13, 54, 48, 48, 48, 48, 19, 48, 54, 6, 49, 48, 6, 48, 48,
64 48, 48, 48, 48, 48, 13, 48, 48, 48, 48, 48, 19, 48, 48, 6, 56, 48, 48, 48, 48, 48, 48, 48, 56,
65 3, 4, 49, 48, 6, 7, 48, 48, 48, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 6, 3, 48, 49,
66 48, 6, 7, 48, 48, 48, 10, 11, 48, 13, 48, 48, 48, 48, 48, 19, 48, 48, 6, 3, 48, 49, 48, 6, 7,
67 48, 48, 48, 48, 11, 48, 13, 48, 48, 48, 48, 48, 19, 48, 48, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48,
68 10, 11, 12, 13, 48, 48, 48, 48, 48, 19, 57, 48, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 10, 11, 12,
69 13, 48, 48, 48, 48, 48, 19, 48, 48, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 10, 11, 12, 13, 14, 15,
70 16, 17, 18, 19, 48, 21, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 10, 11, 12, 13, 57, 48, 48, 48, 48,
71 19, 48, 21, 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 10, 11, 12, 13, 57, 48, 48, 48, 48, 19, 48, 48,
72 6, 3, 48, 49, 48, 6, 7, 48, 48, 48, 10, 11, 12, 13, 48, 15, 48, 17, 48, 19, 48, 21, 6, 3, 48,
73 49, 48, 6, 7, 48, 48, 48, 10, 11, 12, 13, 57, 15, 48, 48, 48, 19, 48, 21, 6, 3, 48, 49, 48, 6,
74 7, 48, 48, 48, 10, 11, 12, 13, 58, 15, 16, 17, 48, 19, 48, 21, 6, 3, 48, 49, 48, 6, 7, 48, 48,
75 48, 10, 11, 12, 13, 48, 15, 16, 17, 48, 19, 48, 21, 6, 3, 4, 49, 48, 6, 7, 48, 48, 48, 10, 11,
76 12, 13, 14, 15, 16, 17, 18, 19, 48, 21, 6, 24, 25, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32,
77 59, 34, 35, 36, 37, 38, 39, 40, 27, 24, 60, 26, 23, 27, 28, 23, 23, 23, 29, 30, 31, 32, 33, 34,
78 35, 36, 37, 38, 23, 40, 27, 2, 3, 4, 49, 48, 6, 7, 2, 2, 48, 10, 11, 12, 13, 14, 15, 16, 17,
79 18, 19, 20, 21, 6, 2, 61, 61, 61, 61, 61, 61, 2, 2, 0, 0,
80];
81static _myanmar_syllable_machine_index_defaults: [i8; 55] = [
82 1, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
83 23, 48, 51, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
84 48, 23, 23, 48, 61, 0, 0,
85];
86static _myanmar_syllable_machine_cond_targs: [i8; 64] = [
87 0, 0, 1, 25, 35, 0, 26, 30, 49, 52, 37, 38, 39, 29, 41, 42, 44, 45, 46, 27, 48, 43, 26, 0, 2,
88 12, 0, 3, 7, 13, 14, 15, 6, 17, 18, 20, 21, 22, 4, 24, 19, 11, 5, 8, 9, 10, 16, 23, 0, 0, 34,
89 0, 28, 31, 32, 33, 36, 40, 47, 50, 51, 0, 0, 0,
90];
91static _myanmar_syllable_machine_cond_actions: [i8; 64] = [
92 0, 3, 0, 0, 0, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 0, 8, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0,
94 0,
95];
96static _myanmar_syllable_machine_to_state_actions: [i8; 55] = [
97 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99];
100static _myanmar_syllable_machine_from_state_actions: [i8; 55] = [
101 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103];
104static _myanmar_syllable_machine_eof_trans: [i8; 55] = [
105 1, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
106 24, 49, 52, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
107 49, 24, 24, 49, 62, 0, 0,
108];
109static myanmar_syllable_machine_start: i32 = 0;
110static myanmar_syllable_machine_first_final: i32 = 0;
111static myanmar_syllable_machine_error: i32 = -1;
112static myanmar_syllable_machine_en_main: i32 = 0;
113#[derive(Clone, Copy)]
114pub enum SyllableType {
115 ConsonantSyllable = 0,
116 PunctuationCluster,
117 BrokenCluster,
118 NonMyanmarCluster,
119}
120
121pub fn find_syllables_myanmar(buffer: &mut hb_buffer_t) {
122 let mut cs = 0;
123 let mut ts = 0;
124 let mut te;
125 let mut act = 0;
126 let mut p = 0;
127 let pe = buffer.len;
128 let eof = buffer.len;
129 let mut syllable_serial = 1u8;
130
131 macro_rules! found_syllable {
132 ($kind:expr) => {{
133 found_syllable(ts, te, &mut syllable_serial, $kind, buffer);
134 }};
135 }
136
137 {
138 cs = (myanmar_syllable_machine_start) as i32;
139 ts = 0;
140 te = 0;
141 act = 0;
142 }
143
144 {
145 let mut _trans = 0;
146 let mut _keys: i32 = 0;
147 let mut _inds: i32 = 0;
148 let mut _ic = 0;
149 '_resume: while (p != pe || p == eof) {
150 '_again: while (true) {
151 match (_myanmar_syllable_machine_from_state_actions[(cs) as usize]) {
152 2 => {
153 ts = p;
154 }
155
156 _ => {}
157 }
158 if (p == eof) {
159 {
160 if (_myanmar_syllable_machine_eof_trans[(cs) as usize] > 0) {
161 {
162 _trans =
163 (_myanmar_syllable_machine_eof_trans[(cs) as usize]) as u32 - 1;
164 }
165 }
166 }
167 } else {
168 {
169 _keys = (cs << 1) as i32;
170 _inds = (_myanmar_syllable_machine_index_offsets[(cs) as usize]) as i32;
171 if ((buffer.info[p].myanmar_category() as u8) <= 57
172 && (buffer.info[p].myanmar_category() as u8) >= 1)
173 {
174 {
175 _ic = (_myanmar_syllable_machine_char_class[((buffer.info[p]
176 .myanmar_category()
177 as u8)
178 as i32
179 - 1)
180 as usize]) as i32;
181 if (_ic
182 <= (_myanmar_syllable_machine_trans_keys[(_keys + 1) as usize])
183 as i32
184 && _ic
185 >= (_myanmar_syllable_machine_trans_keys[(_keys) as usize])
186 as i32)
187 {
188 _trans = (_myanmar_syllable_machine_indices[(_inds
189 + (_ic
190 - (_myanmar_syllable_machine_trans_keys
191 [(_keys) as usize])
192 as i32)
193 as i32)
194 as usize])
195 as u32;
196 } else {
197 _trans = (_myanmar_syllable_machine_index_defaults
198 [(cs) as usize])
199 as u32;
200 }
201 }
202 } else {
203 {
204 _trans = (_myanmar_syllable_machine_index_defaults[(cs) as usize])
205 as u32;
206 }
207 }
208 }
209 }
210 cs = (_myanmar_syllable_machine_cond_targs[(_trans) as usize]) as i32;
211 if (_myanmar_syllable_machine_cond_actions[(_trans) as usize] != 0) {
212 {
213 match (_myanmar_syllable_machine_cond_actions[(_trans) as usize]) {
214 8 => {
215 te = p + 1;
216 {
217 found_syllable!(SyllableType::ConsonantSyllable);
218 }
219 }
220 4 => {
221 te = p + 1;
222 {
223 found_syllable!(SyllableType::NonMyanmarCluster);
224 }
225 }
226 10 => {
227 te = p + 1;
228 {
229 found_syllable!(SyllableType::BrokenCluster);
230 buffer.scratch_flags |=
231 HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE;
232 }
233 }
234 3 => {
235 te = p + 1;
236 {
237 found_syllable!(SyllableType::NonMyanmarCluster);
238 }
239 }
240 7 => {
241 te = p;
242 p = p - 1;
243 {
244 found_syllable!(SyllableType::ConsonantSyllable);
245 }
246 }
247 9 => {
248 te = p;
249 p = p - 1;
250 {
251 found_syllable!(SyllableType::BrokenCluster);
252 buffer.scratch_flags |=
253 HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE;
254 }
255 }
256 12 => {
257 te = p;
258 p = p - 1;
259 {
260 found_syllable!(SyllableType::NonMyanmarCluster);
261 }
262 }
263 11 => match (act) {
264 2 => {
265 p = (te) - 1;
266 {
267 found_syllable!(SyllableType::NonMyanmarCluster);
268 }
269 }
270 3 => {
271 p = (te) - 1;
272 {
273 found_syllable!(SyllableType::BrokenCluster);
274 buffer.scratch_flags |=
275 HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE;
276 }
277 }
278
279 _ => {}
280 },
281 6 => {
282 {
283 {
284 te = p + 1;
285 }
286 }
287 {
288 {
289 act = 2;
290 }
291 }
292 }
293 5 => {
294 {
295 {
296 te = p + 1;
297 }
298 }
299 {
300 {
301 act = 3;
302 }
303 }
304 }
305
306 _ => {}
307 }
308 }
309 }
310 break '_again;
311 }
312 if (p == eof) {
313 {
314 if (cs >= 0) {
315 break '_resume;
316 }
317 }
318 } else {
319 {
320 match (_myanmar_syllable_machine_to_state_actions[(cs) as usize]) {
321 1 => {
322 ts = 0;
323 }
324
325 _ => {}
326 }
327 p += 1;
328 continue '_resume;
329 }
330 }
331 break '_resume;
332 }
333 }
334}
335
336#[inline]
337fn found_syllable(
338 start: usize,
339 end: usize,
340 syllable_serial: &mut u8,
341 kind: SyllableType,
342 buffer: &mut hb_buffer_t,
343) {
344 for i in start..end {
345 buffer.info[i].set_syllable((*syllable_serial << 4) | kind as u8);
346 }
347
348 *syllable_serial += 1;
349
350 if *syllable_serial == 16 {
351 *syllable_serial = 1;
352 }
353}