| 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 | |
| 35 | #line 36 "hb-ot-shape-complex-khmer-machine.hh" |
| 36 | static const unsigned char _khmer_syllable_machine_trans_keys[] = { |
| 37 | 5u, 26u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, 5u, 21u, |
| 38 | 5u, 26u, 5u, 21u, 5u, 21u, 5u, 26u, 5u, 21u, 1u, 16u, 5u, 21u, 5u, 26u, |
| 39 | 5u, 21u, 5u, 26u, 5u, 21u, 5u, 26u, 1u, 29u, 5u, 29u, 5u, 29u, 5u, 29u, |
| 40 | 22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 26u, 5u, 29u, |
| 41 | 5u, 29u, 22u, 22u, 5u, 22u, 5u, 29u, 5u, 29u, 1u, 16u, 5u, 29u, 5u, 29u, |
| 42 | 0 |
| 43 | }; |
| 44 | |
| 45 | static const char _khmer_syllable_machine_key_spans[] = { |
| 46 | 22, 17, 22, 17, 16, 17, 22, 17, |
| 47 | 22, 17, 17, 22, 17, 16, 17, 22, |
| 48 | 17, 22, 17, 22, 29, 25, 25, 25, |
| 49 | 1, 18, 25, 25, 25, 16, 22, 25, |
| 50 | 25, 1, 18, 25, 25, 16, 25, 25 |
| 51 | }; |
| 52 | |
| 53 | static const short _khmer_syllable_machine_index_offsets[] = { |
| 54 | 0, 23, 41, 64, 82, 99, 117, 140, |
| 55 | 158, 181, 199, 217, 240, 258, 275, 293, |
| 56 | 316, 334, 357, 375, 398, 428, 454, 480, |
| 57 | 506, 508, 527, 553, 579, 605, 622, 645, |
| 58 | 671, 697, 699, 718, 744, 770, 787, 813 |
| 59 | }; |
| 60 | |
| 61 | static const char _khmer_syllable_machine_indicies[] = { |
| 62 | 1, 1, 0, 0, 0, 0, 0, 0, |
| 63 | 0, 0, 0, 0, 0, 0, 0, 2, |
| 64 | 3, 0, 0, 0, 0, 4, 0, 1, |
| 65 | 1, 0, 0, 0, 0, 0, 0, 0, |
| 66 | 0, 0, 0, 0, 0, 0, 0, 3, |
| 67 | 0, 1, 1, 0, 0, 0, 0, 0, |
| 68 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 69 | 0, 3, 0, 0, 0, 0, 4, 0, |
| 70 | 5, 5, 0, 0, 0, 0, 0, 0, |
| 71 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 72 | 4, 0, 6, 6, 0, 0, 0, 0, |
| 73 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 74 | 0, 6, 0, 7, 7, 0, 0, 0, |
| 75 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 76 | 0, 0, 0, 8, 0, 9, 9, 0, |
| 77 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 78 | 0, 0, 0, 0, 0, 10, 0, 0, |
| 79 | 0, 0, 4, 0, 9, 9, 0, 0, |
| 80 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 81 | 0, 0, 0, 0, 10, 0, 11, 11, |
| 82 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 83 | 0, 0, 0, 0, 0, 0, 12, 0, |
| 84 | 0, 0, 0, 4, 0, 11, 11, 0, |
| 85 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 86 | 0, 0, 0, 0, 0, 12, 0, 14, |
| 87 | 14, 13, 13, 13, 13, 13, 13, 13, |
| 88 | 13, 13, 13, 13, 13, 13, 13, 15, |
| 89 | 13, 14, 14, 16, 16, 16, 16, 16, |
| 90 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 91 | 16, 15, 16, 16, 16, 16, 17, 16, |
| 92 | 18, 18, 16, 16, 16, 16, 16, 16, |
| 93 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 94 | 17, 16, 19, 19, 16, 16, 16, 16, |
| 95 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 96 | 16, 19, 16, 20, 20, 16, 16, 16, |
| 97 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 98 | 16, 16, 16, 21, 16, 22, 22, 16, |
| 99 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 100 | 16, 16, 16, 16, 16, 23, 16, 16, |
| 101 | 16, 16, 17, 16, 22, 22, 16, 16, |
| 102 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 103 | 16, 16, 16, 16, 23, 16, 24, 24, |
| 104 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 105 | 16, 16, 16, 16, 16, 16, 25, 16, |
| 106 | 16, 16, 16, 17, 16, 24, 24, 16, |
| 107 | 16, 16, 16, 16, 16, 16, 16, 16, |
| 108 | 16, 16, 16, 16, 16, 25, 16, 14, |
| 109 | 14, 16, 16, 16, 16, 16, 16, 16, |
| 110 | 16, 16, 16, 16, 16, 16, 26, 15, |
| 111 | 16, 16, 16, 16, 17, 16, 28, 28, |
| 112 | 27, 27, 29, 29, 27, 27, 27, 27, |
| 113 | 2, 2, 27, 30, 27, 28, 27, 27, |
| 114 | 27, 27, 15, 19, 27, 27, 27, 17, |
| 115 | 23, 25, 21, 27, 32, 32, 31, 31, |
| 116 | 31, 31, 31, 31, 31, 33, 31, 31, |
| 117 | 31, 31, 31, 2, 3, 6, 31, 31, |
| 118 | 31, 4, 10, 12, 8, 31, 34, 34, |
| 119 | 31, 31, 31, 31, 31, 31, 31, 35, |
| 120 | 31, 31, 31, 31, 31, 31, 3, 6, |
| 121 | 31, 31, 31, 4, 10, 12, 8, 31, |
| 122 | 5, 5, 31, 31, 31, 31, 31, 31, |
| 123 | 31, 35, 31, 31, 31, 31, 31, 31, |
| 124 | 4, 6, 31, 31, 31, 31, 31, 31, |
| 125 | 8, 31, 6, 31, 7, 7, 31, 31, |
| 126 | 31, 31, 31, 31, 31, 35, 31, 31, |
| 127 | 31, 31, 31, 31, 8, 6, 31, 36, |
| 128 | 36, 31, 31, 31, 31, 31, 31, 31, |
| 129 | 35, 31, 31, 31, 31, 31, 31, 10, |
| 130 | 6, 31, 31, 31, 4, 31, 31, 8, |
| 131 | 31, 37, 37, 31, 31, 31, 31, 31, |
| 132 | 31, 31, 35, 31, 31, 31, 31, 31, |
| 133 | 31, 12, 6, 31, 31, 31, 4, 10, |
| 134 | 31, 8, 31, 34, 34, 31, 31, 31, |
| 135 | 31, 31, 31, 31, 33, 31, 31, 31, |
| 136 | 31, 31, 31, 3, 6, 31, 31, 31, |
| 137 | 4, 10, 12, 8, 31, 28, 28, 31, |
| 138 | 31, 31, 31, 31, 31, 31, 31, 31, |
| 139 | 31, 31, 31, 31, 28, 31, 14, 14, |
| 140 | 38, 38, 38, 38, 38, 38, 38, 38, |
| 141 | 38, 38, 38, 38, 38, 38, 15, 38, |
| 142 | 38, 38, 38, 17, 38, 40, 40, 39, |
| 143 | 39, 39, 39, 39, 39, 39, 41, 39, |
| 144 | 39, 39, 39, 39, 39, 15, 19, 39, |
| 145 | 39, 39, 17, 23, 25, 21, 39, 18, |
| 146 | 18, 39, 39, 39, 39, 39, 39, 39, |
| 147 | 41, 39, 39, 39, 39, 39, 39, 17, |
| 148 | 19, 39, 39, 39, 39, 39, 39, 21, |
| 149 | 39, 19, 39, 20, 20, 39, 39, 39, |
| 150 | 39, 39, 39, 39, 41, 39, 39, 39, |
| 151 | 39, 39, 39, 21, 19, 39, 42, 42, |
| 152 | 39, 39, 39, 39, 39, 39, 39, 41, |
| 153 | 39, 39, 39, 39, 39, 39, 23, 19, |
| 154 | 39, 39, 39, 17, 39, 39, 21, 39, |
| 155 | 43, 43, 39, 39, 39, 39, 39, 39, |
| 156 | 39, 41, 39, 39, 39, 39, 39, 39, |
| 157 | 25, 19, 39, 39, 39, 17, 23, 39, |
| 158 | 21, 39, 44, 44, 39, 39, 39, 39, |
| 159 | 39, 39, 39, 39, 39, 39, 39, 39, |
| 160 | 39, 44, 39, 45, 45, 39, 39, 39, |
| 161 | 39, 39, 39, 39, 30, 39, 39, 39, |
| 162 | 39, 39, 26, 15, 19, 39, 39, 39, |
| 163 | 17, 23, 25, 21, 39, 40, 40, 39, |
| 164 | 39, 39, 39, 39, 39, 39, 30, 39, |
| 165 | 39, 39, 39, 39, 39, 15, 19, 39, |
| 166 | 39, 39, 17, 23, 25, 21, 39, 0 |
| 167 | }; |
| 168 | |
| 169 | static const char _khmer_syllable_machine_trans_targs[] = { |
| 170 | 20, 1, 28, 22, 23, 3, 24, 5, |
| 171 | 25, 7, 26, 9, 27, 20, 10, 31, |
| 172 | 20, 32, 12, 33, 14, 34, 16, 35, |
| 173 | 18, 36, 39, 20, 21, 30, 37, 20, |
| 174 | 0, 29, 2, 4, 6, 8, 20, 20, |
| 175 | 11, 13, 15, 17, 38, 19 |
| 176 | }; |
| 177 | |
| 178 | static const char _khmer_syllable_machine_trans_actions[] = { |
| 179 | 1, 0, 2, 2, 2, 0, 0, 0, |
| 180 | 2, 0, 2, 0, 2, 3, 0, 4, |
| 181 | 5, 2, 0, 0, 0, 2, 0, 2, |
| 182 | 0, 2, 4, 8, 2, 9, 0, 10, |
| 183 | 0, 0, 0, 0, 0, 0, 11, 12, |
| 184 | 0, 0, 0, 0, 4, 0 |
| 185 | }; |
| 186 | |
| 187 | static const char _khmer_syllable_machine_to_state_actions[] = { |
| 188 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 189 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 190 | 0, 0, 0, 0, 6, 0, 0, 0, |
| 191 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 192 | 0, 0, 0, 0, 0, 0, 0, 0 |
| 193 | }; |
| 194 | |
| 195 | static const char _khmer_syllable_machine_from_state_actions[] = { |
| 196 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 197 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 198 | 0, 0, 0, 0, 7, 0, 0, 0, |
| 199 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 200 | 0, 0, 0, 0, 0, 0, 0, 0 |
| 201 | }; |
| 202 | |
| 203 | static const unsigned char _khmer_syllable_machine_eof_trans[] = { |
| 204 | 1, 1, 1, 1, 1, 1, 1, 1, |
| 205 | 1, 1, 14, 17, 17, 17, 17, 17, |
| 206 | 17, 17, 17, 17, 0, 32, 32, 32, |
| 207 | 32, 32, 32, 32, 32, 32, 39, 40, |
| 208 | 40, 40, 40, 40, 40, 40, 40, 40 |
| 209 | }; |
| 210 | |
| 211 | static const int khmer_syllable_machine_start = 20; |
| 212 | static const int khmer_syllable_machine_first_final = 20; |
| 213 | static const int khmer_syllable_machine_error = -1; |
| 214 | |
| 215 | static const int khmer_syllable_machine_en_main = 20; |
| 216 | |
| 217 | |
| 218 | #line 36 "hb-ot-shape-complex-khmer-machine.rl" |
| 219 | |
| 220 | |
| 221 | |
| 222 | #line 80 "hb-ot-shape-complex-khmer-machine.rl" |
| 223 | |
| 224 | |
| 225 | #define found_syllable(syllable_type) \ |
| 226 | HB_STMT_START { \ |
| 227 | if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \ |
| 228 | for (unsigned int i = ts; i < te; i++) \ |
| 229 | info[i].syllable() = (syllable_serial << 4) | khmer_##syllable_type; \ |
| 230 | syllable_serial++; \ |
| 231 | if (unlikely (syllable_serial == 16)) syllable_serial = 1; \ |
| 232 | } HB_STMT_END |
| 233 | |
| 234 | static void |
| 235 | find_syllables_khmer (hb_buffer_t *buffer) |
| 236 | { |
| 237 | unsigned int p, pe, eof, ts, te, act HB_UNUSED; |
| 238 | int cs; |
| 239 | hb_glyph_info_t *info = buffer->info; |
| 240 | |
| 241 | #line 242 "hb-ot-shape-complex-khmer-machine.hh" |
| 242 | { |
| 243 | cs = khmer_syllable_machine_start; |
| 244 | ts = 0; |
| 245 | te = 0; |
| 246 | act = 0; |
| 247 | } |
| 248 | |
| 249 | #line 100 "hb-ot-shape-complex-khmer-machine.rl" |
| 250 | |
| 251 | |
| 252 | p = 0; |
| 253 | pe = eof = buffer->len; |
| 254 | |
| 255 | unsigned int syllable_serial = 1; |
| 256 | |
| 257 | #line 258 "hb-ot-shape-complex-khmer-machine.hh" |
| 258 | { |
| 259 | int _slen; |
| 260 | int _trans; |
| 261 | const unsigned char *_keys; |
| 262 | const char *_inds; |
| 263 | if ( p == pe ) |
| 264 | goto _test_eof; |
| 265 | _resume: |
| 266 | switch ( _khmer_syllable_machine_from_state_actions[cs] ) { |
| 267 | case 7: |
| 268 | #line 1 "NONE" |
| 269 | {ts = p;} |
| 270 | break; |
| 271 | #line 272 "hb-ot-shape-complex-khmer-machine.hh" |
| 272 | } |
| 273 | |
| 274 | _keys = _khmer_syllable_machine_trans_keys + (cs<<1); |
| 275 | _inds = _khmer_syllable_machine_indicies + _khmer_syllable_machine_index_offsets[cs]; |
| 276 | |
| 277 | _slen = _khmer_syllable_machine_key_spans[cs]; |
| 278 | _trans = _inds[ _slen > 0 && _keys[0] <=( info[p].khmer_category()) && |
| 279 | ( info[p].khmer_category()) <= _keys[1] ? |
| 280 | ( info[p].khmer_category()) - _keys[0] : _slen ]; |
| 281 | |
| 282 | _eof_trans: |
| 283 | cs = _khmer_syllable_machine_trans_targs[_trans]; |
| 284 | |
| 285 | if ( _khmer_syllable_machine_trans_actions[_trans] == 0 ) |
| 286 | goto _again; |
| 287 | |
| 288 | switch ( _khmer_syllable_machine_trans_actions[_trans] ) { |
| 289 | case 2: |
| 290 | #line 1 "NONE" |
| 291 | {te = p+1;} |
| 292 | break; |
| 293 | case 8: |
| 294 | #line 76 "hb-ot-shape-complex-khmer-machine.rl" |
| 295 | {te = p+1;{ found_syllable (non_khmer_cluster); }} |
| 296 | break; |
| 297 | case 10: |
| 298 | #line 74 "hb-ot-shape-complex-khmer-machine.rl" |
| 299 | {te = p;p--;{ found_syllable (consonant_syllable); }} |
| 300 | break; |
| 301 | case 12: |
| 302 | #line 75 "hb-ot-shape-complex-khmer-machine.rl" |
| 303 | {te = p;p--;{ found_syllable (broken_cluster); }} |
| 304 | break; |
| 305 | case 11: |
| 306 | #line 76 "hb-ot-shape-complex-khmer-machine.rl" |
| 307 | {te = p;p--;{ found_syllable (non_khmer_cluster); }} |
| 308 | break; |
| 309 | case 1: |
| 310 | #line 74 "hb-ot-shape-complex-khmer-machine.rl" |
| 311 | {{p = ((te))-1;}{ found_syllable (consonant_syllable); }} |
| 312 | break; |
| 313 | case 5: |
| 314 | #line 75 "hb-ot-shape-complex-khmer-machine.rl" |
| 315 | {{p = ((te))-1;}{ found_syllable (broken_cluster); }} |
| 316 | break; |
| 317 | case 3: |
| 318 | #line 1 "NONE" |
| 319 | { switch( act ) { |
| 320 | case 2: |
| 321 | {{p = ((te))-1;} found_syllable (broken_cluster); } |
| 322 | break; |
| 323 | case 3: |
| 324 | {{p = ((te))-1;} found_syllable (non_khmer_cluster); } |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | break; |
| 329 | case 4: |
| 330 | #line 1 "NONE" |
| 331 | {te = p+1;} |
| 332 | #line 75 "hb-ot-shape-complex-khmer-machine.rl" |
| 333 | {act = 2;} |
| 334 | break; |
| 335 | case 9: |
| 336 | #line 1 "NONE" |
| 337 | {te = p+1;} |
| 338 | #line 76 "hb-ot-shape-complex-khmer-machine.rl" |
| 339 | {act = 3;} |
| 340 | break; |
| 341 | #line 342 "hb-ot-shape-complex-khmer-machine.hh" |
| 342 | } |
| 343 | |
| 344 | _again: |
| 345 | switch ( _khmer_syllable_machine_to_state_actions[cs] ) { |
| 346 | case 6: |
| 347 | #line 1 "NONE" |
| 348 | {ts = 0;} |
| 349 | break; |
| 350 | #line 351 "hb-ot-shape-complex-khmer-machine.hh" |
| 351 | } |
| 352 | |
| 353 | if ( ++p != pe ) |
| 354 | goto _resume; |
| 355 | _test_eof: {} |
| 356 | if ( p == eof ) |
| 357 | { |
| 358 | if ( _khmer_syllable_machine_eof_trans[cs] > 0 ) { |
| 359 | _trans = _khmer_syllable_machine_eof_trans[cs] - 1; |
| 360 | goto _eof_trans; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | } |
| 365 | |
| 366 | #line 108 "hb-ot-shape-complex-khmer-machine.rl" |
| 367 | |
| 368 | } |
| 369 | |
| 370 | #undef found_syllable |
| 371 | |
| 372 | #endif /* HB_OT_SHAPE_COMPLEX_KHMER_MACHINE_HH */ |
| 373 | |