Imported Upstream version 3.4.0
[platform/upstream/harfbuzz.git] / src / hb-ot-shape-complex-khmer-machine.hh
1
2 #line 1 "hb-ot-shape-complex-khmer-machine.rl"
3 /*
4  * Copyright © 2011,2012  Google, Inc.
5  *
6  *  This is part of HarfBuzz, a text shaping library.
7  *
8  * Permission is hereby granted, without written agreement and without
9  * license or royalty fees, to use, copy, modify, and distribute this
10  * software and its documentation for any purpose, provided that the
11  * above copyright notice and the following two paragraphs appear in
12  * all copies of this software.
13  *
14  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18  * DAMAGE.
19  *
20  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
23  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25  *
26  * Google Author(s): Behdad Esfahbod
27  */
28
29 #ifndef HB_OT_SHAPE_COMPLEX_KHMER_MACHINE_HH
30 #define HB_OT_SHAPE_COMPLEX_KHMER_MACHINE_HH
31
32 #include "hb.hh"
33
34 enum khmer_syllable_type_t {
35   khmer_consonant_syllable,
36   khmer_broken_cluster,
37   khmer_non_khmer_cluster,
38 };
39
40
41 #line 42 "hb-ot-shape-complex-khmer-machine.hh"
42 #define khmer_syllable_machine_ex_C 1u
43 #define khmer_syllable_machine_ex_Coeng 14u
44 #define khmer_syllable_machine_ex_DOTTEDCIRCLE 12u
45 #define khmer_syllable_machine_ex_PLACEHOLDER 11u
46 #define khmer_syllable_machine_ex_Ra 16u
47 #define khmer_syllable_machine_ex_Robatic 20u
48 #define khmer_syllable_machine_ex_V 2u
49 #define khmer_syllable_machine_ex_VAbv 26u
50 #define khmer_syllable_machine_ex_VBlw 27u
51 #define khmer_syllable_machine_ex_VPre 28u
52 #define khmer_syllable_machine_ex_VPst 29u
53 #define khmer_syllable_machine_ex_Xgroup 21u
54 #define khmer_syllable_machine_ex_Ygroup 22u
55 #define khmer_syllable_machine_ex_ZWJ 6u
56 #define khmer_syllable_machine_ex_ZWNJ 5u
57
58
59 #line 60 "hb-ot-shape-complex-khmer-machine.hh"
60 static const unsigned char _khmer_syllable_machine_trans_keys[] = {
61         5u, 26u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, 5u, 21u, 
62         5u, 26u, 5u, 21u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, 
63         5u, 21u, 5u, 26u, 5u, 21u, 5u, 26u, 1u, 29u, 5u, 29u, 5u, 29u, 5u, 29u, 
64         22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 26u, 5u, 29u, 
65         5u, 29u, 22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 29u, 5u, 29u, 
66         0
67 };
68
69 static const char _khmer_syllable_machine_key_spans[] = {
70         22, 17, 22, 17, 16, 17, 22, 17, 
71         22, 17, 17, 22, 17, 16, 17, 22, 
72         17, 22, 17, 22, 29, 25, 25, 25, 
73         1, 18, 25, 25, 25, 16, 22, 25, 
74         25, 1, 18, 25, 25, 16, 25, 25
75 };
76
77 static const short _khmer_syllable_machine_index_offsets[] = {
78         0, 23, 41, 64, 82, 99, 117, 140, 
79         158, 181, 199, 217, 240, 258, 275, 293, 
80         316, 334, 357, 375, 398, 428, 454, 480, 
81         506, 508, 527, 553, 579, 605, 622, 645, 
82         671, 697, 699, 718, 744, 770, 787, 813
83 };
84
85 static const char _khmer_syllable_machine_indicies[] = {
86         1, 1, 0, 0, 0, 0, 0, 0, 
87         0, 0, 0, 0, 0, 0, 0, 2, 
88         3, 0, 0, 0, 0, 4, 0, 1, 
89         1, 0, 0, 0, 0, 0, 0, 0, 
90         0, 0, 0, 0, 0, 0, 0, 3, 
91         0, 1, 1, 0, 0, 0, 0, 0, 
92         0, 0, 0, 0, 0, 0, 0, 0, 
93         0, 3, 0, 0, 0, 0, 4, 0, 
94         5, 5, 0, 0, 0, 0, 0, 0, 
95         0, 0, 0, 0, 0, 0, 0, 0, 
96         4, 0, 6, 6, 0, 0, 0, 0, 
97         0, 0, 0, 0, 0, 0, 0, 0, 
98         0, 6, 0, 7, 7, 0, 0, 0, 
99         0, 0, 0, 0, 0, 0, 0, 0, 
100         0, 0, 0, 8, 0, 9, 9, 0, 
101         0, 0, 0, 0, 0, 0, 0, 0, 
102         0, 0, 0, 0, 0, 10, 0, 0, 
103         0, 0, 4, 0, 9, 9, 0, 0, 
104         0, 0, 0, 0, 0, 0, 0, 0, 
105         0, 0, 0, 0, 10, 0, 11, 11, 
106         0, 0, 0, 0, 0, 0, 0, 0, 
107         0, 0, 0, 0, 0, 0, 12, 0, 
108         0, 0, 0, 4, 0, 11, 11, 0, 
109         0, 0, 0, 0, 0, 0, 0, 0, 
110         0, 0, 0, 0, 0, 12, 0, 14, 
111         14, 13, 13, 13, 13, 13, 13, 13, 
112         13, 13, 13, 13, 13, 13, 13, 15, 
113         13, 14, 14, 16, 16, 16, 16, 16, 
114         16, 16, 16, 16, 16, 16, 16, 16, 
115         16, 15, 16, 16, 16, 16, 17, 16, 
116         18, 18, 16, 16, 16, 16, 16, 16, 
117         16, 16, 16, 16, 16, 16, 16, 16, 
118         17, 16, 19, 19, 16, 16, 16, 16, 
119         16, 16, 16, 16, 16, 16, 16, 16, 
120         16, 19, 16, 20, 20, 16, 16, 16, 
121         16, 16, 16, 16, 16, 16, 16, 16, 
122         16, 16, 16, 21, 16, 22, 22, 16, 
123         16, 16, 16, 16, 16, 16, 16, 16, 
124         16, 16, 16, 16, 16, 23, 16, 16, 
125         16, 16, 17, 16, 22, 22, 16, 16, 
126         16, 16, 16, 16, 16, 16, 16, 16, 
127         16, 16, 16, 16, 23, 16, 24, 24, 
128         16, 16, 16, 16, 16, 16, 16, 16, 
129         16, 16, 16, 16, 16, 16, 25, 16, 
130         16, 16, 16, 17, 16, 24, 24, 16, 
131         16, 16, 16, 16, 16, 16, 16, 16, 
132         16, 16, 16, 16, 16, 25, 16, 14, 
133         14, 16, 16, 16, 16, 16, 16, 16, 
134         16, 16, 16, 16, 16, 16, 26, 15, 
135         16, 16, 16, 16, 17, 16, 28, 28, 
136         27, 27, 29, 29, 27, 27, 27, 27, 
137         2, 2, 27, 30, 27, 28, 27, 27, 
138         27, 27, 15, 19, 27, 27, 27, 17, 
139         23, 25, 21, 27, 32, 32, 31, 31, 
140         31, 31, 31, 31, 31, 33, 31, 31, 
141         31, 31, 31, 2, 3, 6, 31, 31, 
142         31, 4, 10, 12, 8, 31, 34, 34, 
143         31, 31, 31, 31, 31, 31, 31, 35, 
144         31, 31, 31, 31, 31, 31, 3, 6, 
145         31, 31, 31, 4, 10, 12, 8, 31, 
146         5, 5, 31, 31, 31, 31, 31, 31, 
147         31, 35, 31, 31, 31, 31, 31, 31, 
148         4, 6, 31, 31, 31, 31, 31, 31, 
149         8, 31, 6, 31, 7, 7, 31, 31, 
150         31, 31, 31, 31, 31, 35, 31, 31, 
151         31, 31, 31, 31, 8, 6, 31, 36, 
152         36, 31, 31, 31, 31, 31, 31, 31, 
153         35, 31, 31, 31, 31, 31, 31, 10, 
154         6, 31, 31, 31, 4, 31, 31, 8, 
155         31, 37, 37, 31, 31, 31, 31, 31, 
156         31, 31, 35, 31, 31, 31, 31, 31, 
157         31, 12, 6, 31, 31, 31, 4, 10, 
158         31, 8, 31, 34, 34, 31, 31, 31, 
159         31, 31, 31, 31, 33, 31, 31, 31, 
160         31, 31, 31, 3, 6, 31, 31, 31, 
161         4, 10, 12, 8, 31, 28, 28, 31, 
162         31, 31, 31, 31, 31, 31, 31, 31, 
163         31, 31, 31, 31, 28, 31, 14, 14, 
164         38, 38, 38, 38, 38, 38, 38, 38, 
165         38, 38, 38, 38, 38, 38, 15, 38, 
166         38, 38, 38, 17, 38, 40, 40, 39, 
167         39, 39, 39, 39, 39, 39, 41, 39, 
168         39, 39, 39, 39, 39, 15, 19, 39, 
169         39, 39, 17, 23, 25, 21, 39, 18, 
170         18, 39, 39, 39, 39, 39, 39, 39, 
171         41, 39, 39, 39, 39, 39, 39, 17, 
172         19, 39, 39, 39, 39, 39, 39, 21, 
173         39, 19, 39, 20, 20, 39, 39, 39, 
174         39, 39, 39, 39, 41, 39, 39, 39, 
175         39, 39, 39, 21, 19, 39, 42, 42, 
176         39, 39, 39, 39, 39, 39, 39, 41, 
177         39, 39, 39, 39, 39, 39, 23, 19, 
178         39, 39, 39, 17, 39, 39, 21, 39, 
179         43, 43, 39, 39, 39, 39, 39, 39, 
180         39, 41, 39, 39, 39, 39, 39, 39, 
181         25, 19, 39, 39, 39, 17, 23, 39, 
182         21, 39, 44, 44, 39, 39, 39, 39, 
183         39, 39, 39, 39, 39, 39, 39, 39, 
184         39, 44, 39, 45, 45, 39, 39, 39, 
185         39, 39, 39, 39, 30, 39, 39, 39, 
186         39, 39, 26, 15, 19, 39, 39, 39, 
187         17, 23, 25, 21, 39, 40, 40, 39, 
188         39, 39, 39, 39, 39, 39, 30, 39, 
189         39, 39, 39, 39, 39, 15, 19, 39, 
190         39, 39, 17, 23, 25, 21, 39, 0
191 };
192
193 static const char _khmer_syllable_machine_trans_targs[] = {
194         20, 1, 28, 22, 23, 3, 24, 5, 
195         25, 7, 26, 9, 27, 20, 10, 31, 
196         20, 32, 12, 33, 14, 34, 16, 35, 
197         18, 36, 39, 20, 21, 30, 37, 20, 
198         0, 29, 2, 4, 6, 8, 20, 20, 
199         11, 13, 15, 17, 38, 19
200 };
201
202 static const char _khmer_syllable_machine_trans_actions[] = {
203         1, 0, 2, 2, 2, 0, 0, 0, 
204         2, 0, 2, 0, 2, 3, 0, 4, 
205         5, 2, 0, 0, 0, 2, 0, 2, 
206         0, 2, 4, 8, 2, 9, 0, 10, 
207         0, 0, 0, 0, 0, 0, 11, 12, 
208         0, 0, 0, 0, 4, 0
209 };
210
211 static const char _khmer_syllable_machine_to_state_actions[] = {
212         0, 0, 0, 0, 0, 0, 0, 0, 
213         0, 0, 0, 0, 0, 0, 0, 0, 
214         0, 0, 0, 0, 6, 0, 0, 0, 
215         0, 0, 0, 0, 0, 0, 0, 0, 
216         0, 0, 0, 0, 0, 0, 0, 0
217 };
218
219 static const char _khmer_syllable_machine_from_state_actions[] = {
220         0, 0, 0, 0, 0, 0, 0, 0, 
221         0, 0, 0, 0, 0, 0, 0, 0, 
222         0, 0, 0, 0, 7, 0, 0, 0, 
223         0, 0, 0, 0, 0, 0, 0, 0, 
224         0, 0, 0, 0, 0, 0, 0, 0
225 };
226
227 static const unsigned char _khmer_syllable_machine_eof_trans[] = {
228         1, 1, 1, 1, 1, 1, 1, 1, 
229         1, 1, 14, 17, 17, 17, 17, 17, 
230         17, 17, 17, 17, 0, 32, 32, 32, 
231         32, 32, 32, 32, 32, 32, 39, 40, 
232         40, 40, 40, 40, 40, 40, 40, 40
233 };
234
235 static const int khmer_syllable_machine_start = 20;
236 static const int khmer_syllable_machine_first_final = 20;
237 static const int khmer_syllable_machine_error = -1;
238
239 static const int khmer_syllable_machine_en_main = 20;
240
241
242 #line 43 "hb-ot-shape-complex-khmer-machine.rl"
243
244
245
246 #line 86 "hb-ot-shape-complex-khmer-machine.rl"
247
248
249 #define found_syllable(syllable_type) \
250   HB_STMT_START { \
251     if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
252     for (unsigned int i = ts; i < te; i++) \
253       info[i].syllable() = (syllable_serial << 4) | syllable_type; \
254     syllable_serial++; \
255     if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
256   } HB_STMT_END
257
258 static void
259 find_syllables_khmer (hb_buffer_t *buffer)
260 {
261   unsigned int p, pe, eof, ts, te, act HB_UNUSED;
262   int cs;
263   hb_glyph_info_t *info = buffer->info;
264   
265 #line 266 "hb-ot-shape-complex-khmer-machine.hh"
266         {
267         cs = khmer_syllable_machine_start;
268         ts = 0;
269         te = 0;
270         act = 0;
271         }
272
273 #line 106 "hb-ot-shape-complex-khmer-machine.rl"
274
275
276   p = 0;
277   pe = eof = buffer->len;
278
279   unsigned int syllable_serial = 1;
280   
281 #line 282 "hb-ot-shape-complex-khmer-machine.hh"
282         {
283         int _slen;
284         int _trans;
285         const unsigned char *_keys;
286         const char *_inds;
287         if ( p == pe )
288                 goto _test_eof;
289 _resume:
290         switch ( _khmer_syllable_machine_from_state_actions[cs] ) {
291         case 7:
292 #line 1 "NONE"
293         {ts = p;}
294         break;
295 #line 296 "hb-ot-shape-complex-khmer-machine.hh"
296         }
297
298         _keys = _khmer_syllable_machine_trans_keys + (cs<<1);
299         _inds = _khmer_syllable_machine_indicies + _khmer_syllable_machine_index_offsets[cs];
300
301         _slen = _khmer_syllable_machine_key_spans[cs];
302         _trans = _inds[ _slen > 0 && _keys[0] <=( info[p].khmer_category()) &&
303                 ( info[p].khmer_category()) <= _keys[1] ?
304                 ( info[p].khmer_category()) - _keys[0] : _slen ];
305
306 _eof_trans:
307         cs = _khmer_syllable_machine_trans_targs[_trans];
308
309         if ( _khmer_syllable_machine_trans_actions[_trans] == 0 )
310                 goto _again;
311
312         switch ( _khmer_syllable_machine_trans_actions[_trans] ) {
313         case 2:
314 #line 1 "NONE"
315         {te = p+1;}
316         break;
317         case 8:
318 #line 82 "hb-ot-shape-complex-khmer-machine.rl"
319         {te = p+1;{ found_syllable (khmer_non_khmer_cluster); }}
320         break;
321         case 10:
322 #line 80 "hb-ot-shape-complex-khmer-machine.rl"
323         {te = p;p--;{ found_syllable (khmer_consonant_syllable); }}
324         break;
325         case 12:
326 #line 81 "hb-ot-shape-complex-khmer-machine.rl"
327         {te = p;p--;{ found_syllable (khmer_broken_cluster); }}
328         break;
329         case 11:
330 #line 82 "hb-ot-shape-complex-khmer-machine.rl"
331         {te = p;p--;{ found_syllable (khmer_non_khmer_cluster); }}
332         break;
333         case 1:
334 #line 80 "hb-ot-shape-complex-khmer-machine.rl"
335         {{p = ((te))-1;}{ found_syllable (khmer_consonant_syllable); }}
336         break;
337         case 5:
338 #line 81 "hb-ot-shape-complex-khmer-machine.rl"
339         {{p = ((te))-1;}{ found_syllable (khmer_broken_cluster); }}
340         break;
341         case 3:
342 #line 1 "NONE"
343         {       switch( act ) {
344         case 2:
345         {{p = ((te))-1;} found_syllable (khmer_broken_cluster); }
346         break;
347         case 3:
348         {{p = ((te))-1;} found_syllable (khmer_non_khmer_cluster); }
349         break;
350         }
351         }
352         break;
353         case 4:
354 #line 1 "NONE"
355         {te = p+1;}
356 #line 81 "hb-ot-shape-complex-khmer-machine.rl"
357         {act = 2;}
358         break;
359         case 9:
360 #line 1 "NONE"
361         {te = p+1;}
362 #line 82 "hb-ot-shape-complex-khmer-machine.rl"
363         {act = 3;}
364         break;
365 #line 366 "hb-ot-shape-complex-khmer-machine.hh"
366         }
367
368 _again:
369         switch ( _khmer_syllable_machine_to_state_actions[cs] ) {
370         case 6:
371 #line 1 "NONE"
372         {ts = 0;}
373         break;
374 #line 375 "hb-ot-shape-complex-khmer-machine.hh"
375         }
376
377         if ( ++p != pe )
378                 goto _resume;
379         _test_eof: {}
380         if ( p == eof )
381         {
382         if ( _khmer_syllable_machine_eof_trans[cs] > 0 ) {
383                 _trans = _khmer_syllable_machine_eof_trans[cs] - 1;
384                 goto _eof_trans;
385         }
386         }
387
388         }
389
390 #line 114 "hb-ot-shape-complex-khmer-machine.rl"
391
392 }
393
394 #undef found_syllable
395
396 #endif /* HB_OT_SHAPE_COMPLEX_KHMER_MACHINE_HH */