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;
21
22static _khmer_syllable_machine_trans_keys: [u8; 82] = [
23 2, 8, 2, 6, 2, 8, 2, 6, 0, 0, 2, 6, 2, 8, 2, 6, 2, 8, 2, 6, 2, 6, 2, 8, 2, 6, 0, 0, 2, 6, 2, 8,
24 2, 6, 2, 8, 2, 6, 2, 8, 0, 11, 2, 11, 2, 11, 2, 11, 7, 7, 2, 7, 2, 11, 2, 11, 2, 11, 0, 0, 2,
25 8, 2, 11, 2, 11, 7, 7, 2, 7, 2, 11, 2, 11, 0, 0, 2, 11, 2, 11, 0, 0,
26];
27static _khmer_syllable_machine_char_class: [i8; 31] = [
28 0, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3, 1, 4, 1, 0, 1, 1, 1, 5, 6, 7, 1, 1, 1, 8, 9, 10, 11, 0, 0,
29];
30static _khmer_syllable_machine_index_offsets: [i16; 42] = [
31 0, 7, 12, 19, 24, 25, 30, 37, 42, 49, 54, 59, 66, 71, 72, 77, 84, 89, 96, 101, 108, 120, 130,
32 140, 150, 151, 157, 167, 177, 187, 188, 195, 205, 215, 216, 222, 232, 242, 243, 253, 0, 0,
33];
34static _khmer_syllable_machine_indices: [i8; 265] = [
35 1, 0, 0, 2, 3, 0, 4, 1, 0, 0, 0, 3, 1, 0, 0, 0, 3, 0, 4, 5, 0, 0, 0, 4, 6, 7, 0, 0, 0, 8, 9, 0,
36 0, 0, 10, 0, 4, 9, 0, 0, 0, 10, 11, 0, 0, 0, 12, 0, 4, 11, 0, 0, 0, 12, 14, 13, 13, 13, 15, 14,
37 16, 16, 16, 15, 16, 17, 18, 16, 16, 16, 17, 19, 20, 16, 16, 16, 21, 22, 16, 16, 16, 23, 16, 17,
38 22, 16, 16, 16, 23, 24, 16, 16, 16, 25, 16, 17, 24, 16, 16, 16, 25, 14, 16, 16, 26, 15, 16, 17,
39 29, 28, 30, 2, 31, 28, 15, 19, 17, 23, 25, 21, 33, 32, 34, 2, 3, 6, 4, 10, 12, 8, 35, 32, 36,
40 32, 3, 6, 4, 10, 12, 8, 5, 32, 36, 32, 4, 6, 32, 32, 32, 8, 6, 7, 32, 36, 32, 8, 6, 37, 32, 36,
41 32, 10, 6, 4, 32, 32, 8, 38, 32, 36, 32, 12, 6, 4, 10, 32, 8, 35, 32, 34, 32, 3, 6, 4, 10, 12,
42 8, 29, 14, 39, 39, 39, 15, 39, 17, 41, 40, 42, 40, 15, 19, 17, 23, 25, 21, 18, 40, 42, 40, 17,
43 19, 40, 40, 40, 21, 19, 20, 40, 42, 40, 21, 19, 43, 40, 42, 40, 23, 19, 17, 40, 40, 21, 44, 40,
44 42, 40, 25, 19, 17, 23, 40, 21, 45, 46, 40, 31, 26, 15, 19, 17, 23, 25, 21, 41, 40, 31, 40, 15,
45 19, 17, 23, 25, 21, 0, 0,
46];
47static _khmer_syllable_machine_index_defaults: [i8; 42] = [
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 28, 32, 32, 32, 32, 32,
49 32, 32, 32, 32, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0,
50];
51static _khmer_syllable_machine_cond_targs: [i8; 49] = [
52 20, 1, 28, 22, 23, 3, 24, 5, 25, 7, 26, 9, 27, 20, 10, 31, 20, 32, 12, 33, 14, 34, 16, 35, 18,
53 36, 39, 20, 20, 21, 30, 37, 20, 0, 29, 2, 4, 6, 8, 20, 20, 11, 13, 15, 17, 38, 19, 0, 0,
54];
55static _khmer_syllable_machine_cond_actions: [i8; 49] = [
56 1, 0, 2, 2, 2, 0, 0, 0, 2, 0, 2, 0, 2, 3, 0, 4, 5, 2, 0, 0, 0, 2, 0, 2, 0, 2, 4, 0, 8, 2, 9, 0,
57 10, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 0, 4, 0, 0, 0,
58];
59static _khmer_syllable_machine_to_state_actions: [i8; 42] = [
60 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62];
63static _khmer_syllable_machine_from_state_actions: [i8; 42] = [
64 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
65 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66];
67static _khmer_syllable_machine_eof_trans: [i8; 42] = [
68 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14, 17, 17, 17, 17, 17, 17, 17, 17, 17, 28, 33, 33, 33, 33, 33,
69 33, 33, 33, 33, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 0, 0,
70];
71static khmer_syllable_machine_start: i32 = 20;
72static khmer_syllable_machine_first_final: i32 = 20;
73static khmer_syllable_machine_error: i32 = -1;
74static khmer_syllable_machine_en_main: i32 = 20;
75#[derive(Clone, Copy)]
76pub enum SyllableType {
77 ConsonantSyllable = 0,
78 BrokenCluster,
79 NonKhmerCluster,
80}
81
82pub fn find_syllables_khmer(buffer: &mut Buffer) {
83 let mut cs = 0;
84 let mut ts = 0;
85 let mut te = 0;
86 let mut act = 0;
87 let mut p = 0;
88 let pe = buffer.len;
89 let eof = buffer.len;
90 let mut syllable_serial = 1u8;
91
92 macro_rules! found_syllable {
93 ($kind:expr) => {{
94 found_syllable(ts, te, &mut syllable_serial, $kind, buffer);
95 }};
96 }
97
98 {
99 cs = (khmer_syllable_machine_start) as i32;
100 ts = 0;
101 te = 0;
102 act = 0;
103 }
104
105 {
106 let mut _trans = 0;
107 let mut _keys: i32 = 0;
108 let mut _inds: i32 = 0;
109 let mut _ic = 0;
110 '_resume: while (p != pe || p == eof) {
111 '_again: while (true) {
112 match (_khmer_syllable_machine_from_state_actions[(cs) as usize]) {
113 7 => {
114 ts = p;
115 }
116
117 _ => {}
118 }
119 if (p == eof) {
120 {
121 if (_khmer_syllable_machine_eof_trans[(cs) as usize] > 0) {
122 {
123 _trans =
124 (_khmer_syllable_machine_eof_trans[(cs) as usize]) as u32 - 1;
125 }
126 }
127 }
128 } else {
129 {
130 _keys = (cs << 1) as i32;
131 _inds = (_khmer_syllable_machine_index_offsets[(cs) as usize]) as i32;
132 if ((buffer.info[p].indic_category() as u8) <= 29
133 && (buffer.info[p].indic_category() as u8) >= 1)
134 {
135 {
136 _ic = (_khmer_syllable_machine_char_class
137 [((buffer.info[p].indic_category() as u8) as i32 - 1) as usize])
138 as i32;
139 if (_ic
140 <= (_khmer_syllable_machine_trans_keys[(_keys + 1) as usize])
141 as i32
142 && _ic
143 >= (_khmer_syllable_machine_trans_keys[(_keys) as usize])
144 as i32)
145 {
146 _trans = (_khmer_syllable_machine_indices[(_inds
147 + (_ic
148 - (_khmer_syllable_machine_trans_keys[(_keys) as usize])
149 as i32)
150 as i32)
151 as usize])
152 as u32;
153 } else {
154 _trans = (_khmer_syllable_machine_index_defaults[(cs) as usize])
155 as u32;
156 }
157 }
158 } else {
159 {
160 _trans =
161 (_khmer_syllable_machine_index_defaults[(cs) as usize]) as u32;
162 }
163 }
164 }
165 }
166 cs = (_khmer_syllable_machine_cond_targs[(_trans) as usize]) as i32;
167 if (_khmer_syllable_machine_cond_actions[(_trans) as usize] != 0) {
168 {
169 match (_khmer_syllable_machine_cond_actions[(_trans) as usize]) {
170 2 => {
171 te = p + 1;
172 }
173 8 => {
174 te = p + 1;
175 {
176 found_syllable!(SyllableType::NonKhmerCluster);
177 }
178 }
179 10 => {
180 te = p;
181 p = p - 1;
182 {
183 found_syllable!(SyllableType::ConsonantSyllable);
184 }
185 }
186 12 => {
187 te = p;
188 p = p - 1;
189 {
190 found_syllable!(SyllableType::BrokenCluster);
191 }
192 }
193 11 => {
194 te = p;
195 p = p - 1;
196 {
197 found_syllable!(SyllableType::NonKhmerCluster);
198 }
199 }
200 1 => {
201 p = (te) - 1;
202 {
203 found_syllable!(SyllableType::ConsonantSyllable);
204 }
205 }
206 5 => {
207 p = (te) - 1;
208 {
209 found_syllable!(SyllableType::BrokenCluster);
210 }
211 }
212 3 => match (act) {
213 2 => {
214 p = (te) - 1;
215 {
216 found_syllable!(SyllableType::BrokenCluster);
217 }
218 }
219 3 => {
220 p = (te) - 1;
221 {
222 found_syllable!(SyllableType::NonKhmerCluster);
223 }
224 }
225
226 _ => {}
227 },
228 4 => {
229 {
230 {
231 te = p + 1;
232 }
233 }
234 {
235 {
236 act = 2;
237 }
238 }
239 }
240 9 => {
241 {
242 {
243 te = p + 1;
244 }
245 }
246 {
247 {
248 act = 3;
249 }
250 }
251 }
252
253 _ => {}
254 }
255 }
256 }
257 break '_again;
258 }
259 if (p == eof) {
260 {
261 if (cs >= 20) {
262 break '_resume;
263 }
264 }
265 } else {
266 {
267 match (_khmer_syllable_machine_to_state_actions[(cs) as usize]) {
268 6 => {
269 ts = 0;
270 }
271
272 _ => {}
273 }
274 p += 1;
275 continue '_resume;
276 }
277 }
278 break '_resume;
279 }
280 }
281}
282
283#[inline]
284fn found_syllable(
285 start: usize,
286 end: usize,
287 syllable_serial: &mut u8,
288 kind: SyllableType,
289 buffer: &mut Buffer,
290) {
291 for i: usize in start..end {
292 buffer.info[i].set_syllable((*syllable_serial << 4) | kind as u8);
293 }
294
295 *syllable_serial += 1;
296
297 if *syllable_serial == 16 {
298 *syllable_serial = 1;
299 }
300}
301