1// This file is autogenerated. Do not edit it!
2//
3// See docs/ragel.md for details.
4
5#![allow(
6 dead_code,
7 non_upper_case_globals,
8 unused_assignments,
9 unused_parens,
10 while_true,
11 clippy::assign_op_pattern,
12 clippy::collapsible_if,
13 clippy::comparison_chain,
14 clippy::double_parens,
15 clippy::unnecessary_cast,
16 clippy::single_match,
17 clippy::never_loop
18)]
19
20use crate::buffer::Buffer;
21use crate::complex::machine_cursor::MachineCursor;
22use crate::complex::universal::category;
23use crate::GlyphInfo;
24use core::cell::Cell;
25
26static _use_syllable_machine_trans_keys: [u8; 126] = [
27 1, 1, 1, 1, 0, 37, 5, 34, 5, 34, 1, 1, 10, 34, 11, 34, 12, 33, 13, 33, 14, 33, 31, 32, 32, 32,
28 12, 34, 12, 34, 12, 34, 1, 1, 12, 34, 11, 34, 11, 34, 11, 34, 10, 34, 10, 34, 10, 34, 5, 34, 1,
29 34, 7, 7, 3, 3, 5, 34, 27, 28, 28, 28, 5, 34, 10, 34, 11, 34, 12, 33, 13, 33, 14, 33, 31, 32,
30 32, 32, 12, 34, 12, 34, 12, 34, 12, 34, 11, 34, 11, 34, 11, 34, 10, 34, 10, 34, 10, 34, 5, 34,
31 1, 34, 1, 1, 3, 3, 7, 7, 1, 34, 5, 34, 27, 28, 28, 28, 1, 4, 36, 38, 35, 38, 35, 37, 0, 0,
32];
33static _use_syllable_machine_char_class: [i8; 55] = [
34 0, 1, 2, 2, 3, 4, 2, 2, 2, 2, 2, 5, 6, 7, 2, 2, 2, 2, 8, 9, 2, 2, 10, 11, 12, 13, 14, 15, 16,
35 17, 18, 19, 20, 21, 22, 23, 2, 24, 25, 26, 2, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
36 0, 0,
37];
38static _use_syllable_machine_index_offsets: [i16; 64] = [
39 0, 1, 2, 40, 70, 100, 101, 126, 150, 172, 193, 213, 215, 216, 239, 262, 285, 286, 309, 333,
40 357, 381, 406, 431, 456, 486, 520, 521, 522, 552, 554, 555, 585, 610, 634, 656, 677, 697, 699,
41 700, 723, 746, 769, 792, 816, 840, 864, 889, 914, 939, 969, 1003, 1004, 1005, 1006, 1040, 1070,
42 1072, 1073, 1077, 1080, 1084, 0, 0,
43];
44static _use_syllable_machine_indices: [i8; 1089] = [
45 1, 2, 4, 5, 6, 7, 8, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 13, 20, 21, 22, 23, 24, 25,
46 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 9, 36, 6, 37, 39, 40, 38, 38, 38, 41, 42, 43, 44, 45,
47 46, 47, 41, 48, 5, 49, 50, 51, 52, 53, 54, 55, 38, 38, 38, 56, 57, 58, 59, 40, 39, 40, 38, 38,
48 38, 41, 42, 43, 44, 45, 46, 47, 41, 48, 49, 49, 50, 51, 52, 53, 54, 55, 38, 38, 38, 56, 57, 58,
49 59, 40, 39, 41, 42, 43, 44, 45, 38, 38, 38, 38, 38, 38, 50, 51, 52, 53, 54, 55, 38, 38, 38, 42,
50 57, 58, 59, 61, 42, 43, 44, 45, 38, 38, 38, 38, 38, 38, 38, 38, 38, 53, 54, 55, 38, 38, 38, 38,
51 57, 58, 59, 61, 43, 44, 45, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 57,
52 58, 59, 44, 45, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 57, 58, 59, 45,
53 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 57, 58, 59, 57, 58, 58, 43, 44,
54 45, 38, 38, 38, 38, 38, 38, 38, 38, 38, 53, 54, 55, 38, 38, 38, 38, 57, 58, 59, 61, 43, 44, 45,
55 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 54, 55, 38, 38, 38, 38, 57, 58, 59, 61, 43, 44, 45, 38,
56 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 55, 38, 38, 38, 38, 57, 58, 59, 61, 63, 43, 44, 45, 38,
57 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 57, 58, 59, 61, 42, 43, 44, 45, 38,
58 38, 38, 38, 38, 38, 50, 51, 52, 53, 54, 55, 38, 38, 38, 42, 57, 58, 59, 61, 42, 43, 44, 45, 38,
59 38, 38, 38, 38, 38, 38, 51, 52, 53, 54, 55, 38, 38, 38, 42, 57, 58, 59, 61, 42, 43, 44, 45, 38,
60 38, 38, 38, 38, 38, 38, 38, 52, 53, 54, 55, 38, 38, 38, 42, 57, 58, 59, 61, 41, 42, 43, 44, 45,
61 38, 47, 41, 38, 38, 38, 50, 51, 52, 53, 54, 55, 38, 38, 38, 42, 57, 58, 59, 61, 41, 42, 43, 44,
62 45, 38, 38, 41, 38, 38, 38, 50, 51, 52, 53, 54, 55, 38, 38, 38, 42, 57, 58, 59, 61, 41, 42, 43,
63 44, 45, 46, 47, 41, 38, 38, 38, 50, 51, 52, 53, 54, 55, 38, 38, 38, 42, 57, 58, 59, 61, 39, 40,
64 38, 38, 38, 41, 42, 43, 44, 45, 46, 47, 41, 48, 38, 49, 50, 51, 52, 53, 54, 55, 38, 38, 38, 56,
65 57, 58, 59, 40, 39, 60, 60, 60, 60, 60, 60, 60, 60, 60, 42, 43, 44, 45, 60, 60, 60, 60, 60, 60,
66 60, 60, 60, 53, 54, 55, 60, 60, 60, 60, 57, 58, 59, 61, 65, 7, 39, 40, 38, 38, 38, 41, 42, 43,
67 44, 45, 46, 47, 41, 48, 5, 49, 50, 51, 52, 53, 54, 55, 12, 67, 38, 56, 57, 58, 59, 40, 12, 67,
68 67, 1, 70, 69, 69, 69, 13, 14, 15, 16, 17, 18, 19, 13, 20, 22, 22, 23, 24, 25, 26, 27, 28, 69,
69 69, 69, 32, 33, 34, 35, 70, 13, 14, 15, 16, 17, 69, 69, 69, 69, 69, 69, 23, 24, 25, 26, 27, 28,
70 69, 69, 69, 14, 33, 34, 35, 71, 14, 15, 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 26, 27, 28,
71 69, 69, 69, 69, 33, 34, 35, 71, 15, 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
72 69, 69, 69, 33, 34, 35, 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
73 33, 34, 35, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 33, 34, 35, 33,
74 34, 34, 15, 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 26, 27, 28, 69, 69, 69, 69, 33, 34, 35,
75 71, 15, 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 27, 28, 69, 69, 69, 69, 33, 34, 35, 71,
76 15, 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 28, 69, 69, 69, 69, 33, 34, 35, 71, 15,
77 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 33, 34, 35, 71, 14, 15,
78 16, 17, 69, 69, 69, 69, 69, 69, 23, 24, 25, 26, 27, 28, 69, 69, 69, 14, 33, 34, 35, 71, 14, 15,
79 16, 17, 69, 69, 69, 69, 69, 69, 69, 24, 25, 26, 27, 28, 69, 69, 69, 14, 33, 34, 35, 71, 14, 15,
80 16, 17, 69, 69, 69, 69, 69, 69, 69, 69, 25, 26, 27, 28, 69, 69, 69, 14, 33, 34, 35, 71, 13, 14,
81 15, 16, 17, 69, 19, 13, 69, 69, 69, 23, 24, 25, 26, 27, 28, 69, 69, 69, 14, 33, 34, 35, 71, 13,
82 14, 15, 16, 17, 69, 69, 13, 69, 69, 69, 23, 24, 25, 26, 27, 28, 69, 69, 69, 14, 33, 34, 35, 71,
83 13, 14, 15, 16, 17, 18, 19, 13, 69, 69, 69, 23, 24, 25, 26, 27, 28, 69, 69, 69, 14, 33, 34, 35,
84 71, 1, 70, 69, 69, 69, 13, 14, 15, 16, 17, 18, 19, 13, 20, 69, 22, 23, 24, 25, 26, 27, 28, 69,
85 69, 69, 32, 33, 34, 35, 70, 1, 69, 69, 69, 69, 69, 69, 69, 69, 69, 14, 15, 16, 17, 69, 69, 69,
86 69, 69, 69, 69, 69, 69, 26, 27, 28, 69, 69, 69, 69, 33, 34, 35, 71, 1, 73, 10, 5, 69, 69, 5, 1,
87 70, 10, 69, 69, 13, 14, 15, 16, 17, 18, 19, 13, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 69,
88 32, 33, 34, 35, 70, 1, 70, 69, 69, 69, 13, 14, 15, 16, 17, 18, 19, 13, 20, 21, 22, 23, 24, 25,
89 26, 27, 28, 69, 69, 69, 32, 33, 34, 35, 70, 29, 30, 30, 5, 72, 72, 5, 75, 74, 36, 36, 75, 74,
90 75, 36, 74, 37, 0, 0,
91];
92static _use_syllable_machine_index_defaults: [i8; 64] = [
93 0, 0, 6, 38, 38, 60, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 62, 38, 38, 38, 38, 38, 38, 38,
94 38, 60, 64, 66, 38, 68, 68, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
95 69, 69, 69, 72, 69, 69, 69, 69, 69, 69, 72, 74, 74, 74, 0, 0,
96];
97static _use_syllable_machine_cond_targs: [i8; 78] = [
98 2, 31, 42, 2, 2, 3, 2, 26, 28, 51, 52, 54, 29, 32, 33, 34, 35, 36, 46, 47, 48, 55, 49, 43, 44,
99 45, 39, 40, 41, 56, 57, 58, 50, 37, 38, 2, 59, 61, 2, 4, 5, 6, 7, 8, 9, 10, 21, 22, 23, 24, 18,
100 19, 20, 13, 14, 15, 25, 11, 12, 2, 2, 16, 2, 17, 2, 27, 2, 30, 2, 2, 0, 1, 2, 53, 2, 60, 0, 0,
101];
102static _use_syllable_machine_cond_actions: [i8; 78] = [
103 1, 2, 2, 0, 5, 0, 6, 0, 0, 0, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0,
104 2, 0, 0, 7, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 11,
105 0, 12, 0, 13, 0, 14, 15, 0, 0, 16, 0, 17, 0, 0, 0,
106];
107static _use_syllable_machine_to_state_actions: [i8; 64] = [
108 0, 0, 3, 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,
109 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, 0,
110];
111static _use_syllable_machine_from_state_actions: [i8; 64] = [
112 0, 0, 4, 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,
113 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, 0,
114];
115static _use_syllable_machine_eof_trans: [i8; 64] = [
116 1, 1, 4, 39, 39, 61, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 63, 39, 39, 39, 39, 39, 39, 39,
117 39, 61, 65, 67, 39, 69, 69, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
118 70, 70, 70, 73, 70, 70, 70, 70, 70, 70, 73, 75, 75, 75, 0, 0,
119];
120static use_syllable_machine_start: i32 = 2;
121static use_syllable_machine_first_final: i32 = 2;
122static use_syllable_machine_error: i32 = -1;
123static use_syllable_machine_en_main: i32 = 2;
124#[derive(Clone, Copy)]
125pub enum SyllableType {
126 IndependentCluster,
127 ViramaTerminatedCluster,
128 SakotTerminatedCluster,
129 StandardCluster,
130 NumberJoinerTerminatedCluster,
131 NumeralCluster,
132 SymbolCluster,
133 HieroglyphCluster,
134 BrokenCluster,
135 NonCluster,
136}
137
138pub fn find_syllables(buffer: &mut Buffer) {
139 let mut cs = 0;
140 let infos = Cell::as_slice_of_cells(Cell::from_mut(&mut buffer.info));
141 let p0 = MachineCursor::new(infos, included);
142 let mut p = p0;
143 let mut ts = p0;
144 let mut te = p0;
145 let pe = p.end();
146 let eof = p.end();
147 let mut syllable_serial = 1u8;
148
149 // Please manually replace assignments of 0 to p, ts, and te
150 // to use p0 instead
151
152 macro_rules! found_syllable {
153 ($kind:expr) => {{
154 found_syllable(ts.index(), te.index(), &mut syllable_serial, $kind, infos);
155 }};
156 }
157
158 {
159 cs = (use_syllable_machine_start) as i32;
160 ts = p0;
161 te = p0;
162 }
163
164 {
165 let mut _trans = 0;
166 let mut _keys: i32 = 0;
167 let mut _inds: i32 = 0;
168 let mut _ic = 0;
169 '_resume: while (p != pe || p == eof) {
170 '_again: while (true) {
171 match (_use_syllable_machine_from_state_actions[(cs) as usize]) {
172 4 => {
173 ts = p;
174 }
175
176 _ => {}
177 }
178 if (p == eof) {
179 {
180 if (_use_syllable_machine_eof_trans[(cs) as usize] > 0) {
181 {
182 _trans =
183 (_use_syllable_machine_eof_trans[(cs) as usize]) as u32 - 1;
184 }
185 }
186 }
187 } else {
188 {
189 _keys = (cs << 1) as i32;
190 _inds = (_use_syllable_machine_index_offsets[(cs) as usize]) as i32;
191 if ((infos[p.index()].get().use_category() as u8) <= 52) {
192 {
193 _ic = (_use_syllable_machine_char_class[((infos[p.index()]
194 .get()
195 .use_category()
196 as u8)
197 as i32
198 - 0)
199 as usize]) as i32;
200 if (_ic
201 <= (_use_syllable_machine_trans_keys[(_keys + 1) as usize])
202 as i32
203 && _ic
204 >= (_use_syllable_machine_trans_keys[(_keys) as usize])
205 as i32)
206 {
207 _trans = (_use_syllable_machine_indices[(_inds
208 + (_ic
209 - (_use_syllable_machine_trans_keys[(_keys) as usize])
210 as i32)
211 as i32)
212 as usize])
213 as u32;
214 } else {
215 _trans = (_use_syllable_machine_index_defaults[(cs) as usize])
216 as u32;
217 }
218 }
219 } else {
220 {
221 _trans =
222 (_use_syllable_machine_index_defaults[(cs) as usize]) as u32;
223 }
224 }
225 }
226 }
227 cs = (_use_syllable_machine_cond_targs[(_trans) as usize]) as i32;
228 if (_use_syllable_machine_cond_actions[(_trans) as usize] != 0) {
229 {
230 match (_use_syllable_machine_cond_actions[(_trans) as usize]) {
231 2 => {
232 te = p + 1;
233 }
234 5 => {
235 te = p + 1;
236 {
237 found_syllable!(SyllableType::IndependentCluster);
238 }
239 }
240 9 => {
241 te = p + 1;
242 {
243 found_syllable!(SyllableType::StandardCluster);
244 }
245 }
246 7 => {
247 te = p + 1;
248 {
249 found_syllable!(SyllableType::BrokenCluster);
250 }
251 }
252 6 => {
253 te = p + 1;
254 {
255 found_syllable!(SyllableType::NonCluster);
256 }
257 }
258 10 => {
259 te = p;
260 p = p - 1;
261 {
262 found_syllable!(SyllableType::ViramaTerminatedCluster);
263 }
264 }
265 11 => {
266 te = p;
267 p = p - 1;
268 {
269 found_syllable!(SyllableType::SakotTerminatedCluster);
270 }
271 }
272 8 => {
273 te = p;
274 p = p - 1;
275 {
276 found_syllable!(SyllableType::StandardCluster);
277 }
278 }
279 13 => {
280 te = p;
281 p = p - 1;
282 {
283 found_syllable!(SyllableType::NumberJoinerTerminatedCluster);
284 }
285 }
286 12 => {
287 te = p;
288 p = p - 1;
289 {
290 found_syllable!(SyllableType::NumeralCluster);
291 }
292 }
293 14 => {
294 te = p;
295 p = p - 1;
296 {
297 found_syllable!(SyllableType::SymbolCluster);
298 }
299 }
300 17 => {
301 te = p;
302 p = p - 1;
303 {
304 found_syllable!(SyllableType::HieroglyphCluster);
305 }
306 }
307 15 => {
308 te = p;
309 p = p - 1;
310 {
311 found_syllable!(SyllableType::BrokenCluster);
312 }
313 }
314 16 => {
315 te = p;
316 p = p - 1;
317 {
318 found_syllable!(SyllableType::NonCluster);
319 }
320 }
321 1 => {
322 p = (te) - 1;
323 {
324 found_syllable!(SyllableType::BrokenCluster);
325 }
326 }
327
328 _ => {}
329 }
330 }
331 }
332 break '_again;
333 }
334 if (p == eof) {
335 {
336 if (cs >= 2) {
337 break '_resume;
338 }
339 }
340 } else {
341 {
342 match (_use_syllable_machine_to_state_actions[(cs) as usize]) {
343 3 => {
344 ts = p0;
345 }
346
347 _ => {}
348 }
349 p += 1;
350 continue '_resume;
351 }
352 }
353 break '_resume;
354 }
355 }
356}
357
358#[inline]
359fn found_syllable(
360 start: usize,
361 end: usize,
362 syllable_serial: &mut u8,
363 kind: SyllableType,
364 buffer: &[Cell<GlyphInfo>],
365) {
366 for i: usize in start..end {
367 let mut glyph: GlyphInfo = buffer[i].get();
368 glyph.set_syllable((*syllable_serial << 4) | kind as u8);
369 buffer[i].set(val:glyph);
370 }
371
372 *syllable_serial += 1;
373
374 if *syllable_serial == 16 {
375 *syllable_serial = 1;
376 }
377}
378
379fn not_standard_default_ignorable(i: &GlyphInfo) -> bool {
380 !(matches!(i.use_category(), category::O | category::RSV) && i.is_default_ignorable())
381}
382
383fn included(infos: &[Cell<GlyphInfo>], i: usize) -> bool {
384 let glyph: GlyphInfo = infos[i].get();
385 if !not_standard_default_ignorable(&glyph) {
386 return false;
387 }
388 if glyph.use_category() == category::ZWNJ {
389 for glyph2: &Cell in &infos[i + 1..] {
390 if not_standard_default_ignorable(&glyph2.get()) {
391 return !glyph2.get().is_unicode_mark();
392 }
393 }
394 }
395 true
396}
397