[indic/use] Factor common expressions in ragel machine

No machine change.
This commit is contained in:
Behdad Esfahbod 2018-10-02 17:49:06 +02:00
parent 6f457f8370
commit 5101abd42f
4 changed files with 58 additions and 56 deletions

View File

@ -911,7 +911,7 @@ static const int indic_syllable_machine_en_main = 138;
#line 90 "hb-ot-shape-complex-indic-machine.rl"
#line 92 "hb-ot-shape-complex-indic-machine.rl"
#define found_syllable(syllable_type) \
@ -938,7 +938,7 @@ find_syllables (hb_buffer_t *buffer)
act = 0;
}
#line 110 "hb-ot-shape-complex-indic-machine.rl"
#line 112 "hb-ot-shape-complex-indic-machine.rl"
p = 0;
@ -983,71 +983,71 @@ _eof_trans:
{te = p+1;}
break;
case 14:
#line 81 "hb-ot-shape-complex-indic-machine.rl"
#line 83 "hb-ot-shape-complex-indic-machine.rl"
{te = p+1;{ found_syllable (consonant_syllable); }}
break;
case 16:
#line 82 "hb-ot-shape-complex-indic-machine.rl"
#line 84 "hb-ot-shape-complex-indic-machine.rl"
{te = p+1;{ found_syllable (vowel_syllable); }}
break;
case 21:
#line 83 "hb-ot-shape-complex-indic-machine.rl"
#line 85 "hb-ot-shape-complex-indic-machine.rl"
{te = p+1;{ found_syllable (standalone_cluster); }}
break;
case 24:
#line 84 "hb-ot-shape-complex-indic-machine.rl"
#line 86 "hb-ot-shape-complex-indic-machine.rl"
{te = p+1;{ found_syllable (symbol_cluster); }}
break;
case 18:
#line 85 "hb-ot-shape-complex-indic-machine.rl"
#line 87 "hb-ot-shape-complex-indic-machine.rl"
{te = p+1;{ found_syllable (broken_cluster); }}
break;
case 11:
#line 86 "hb-ot-shape-complex-indic-machine.rl"
#line 88 "hb-ot-shape-complex-indic-machine.rl"
{te = p+1;{ found_syllable (non_indic_cluster); }}
break;
case 13:
#line 81 "hb-ot-shape-complex-indic-machine.rl"
#line 83 "hb-ot-shape-complex-indic-machine.rl"
{te = p;p--;{ found_syllable (consonant_syllable); }}
break;
case 15:
#line 82 "hb-ot-shape-complex-indic-machine.rl"
#line 84 "hb-ot-shape-complex-indic-machine.rl"
{te = p;p--;{ found_syllable (vowel_syllable); }}
break;
case 20:
#line 83 "hb-ot-shape-complex-indic-machine.rl"
#line 85 "hb-ot-shape-complex-indic-machine.rl"
{te = p;p--;{ found_syllable (standalone_cluster); }}
break;
case 23:
#line 84 "hb-ot-shape-complex-indic-machine.rl"
#line 86 "hb-ot-shape-complex-indic-machine.rl"
{te = p;p--;{ found_syllable (symbol_cluster); }}
break;
case 17:
#line 85 "hb-ot-shape-complex-indic-machine.rl"
#line 87 "hb-ot-shape-complex-indic-machine.rl"
{te = p;p--;{ found_syllable (broken_cluster); }}
break;
case 19:
#line 86 "hb-ot-shape-complex-indic-machine.rl"
#line 88 "hb-ot-shape-complex-indic-machine.rl"
{te = p;p--;{ found_syllable (non_indic_cluster); }}
break;
case 1:
#line 81 "hb-ot-shape-complex-indic-machine.rl"
#line 83 "hb-ot-shape-complex-indic-machine.rl"
{{p = ((te))-1;}{ found_syllable (consonant_syllable); }}
break;
case 3:
#line 82 "hb-ot-shape-complex-indic-machine.rl"
#line 84 "hb-ot-shape-complex-indic-machine.rl"
{{p = ((te))-1;}{ found_syllable (vowel_syllable); }}
break;
case 7:
#line 83 "hb-ot-shape-complex-indic-machine.rl"
#line 85 "hb-ot-shape-complex-indic-machine.rl"
{{p = ((te))-1;}{ found_syllable (standalone_cluster); }}
break;
case 8:
#line 84 "hb-ot-shape-complex-indic-machine.rl"
#line 86 "hb-ot-shape-complex-indic-machine.rl"
{{p = ((te))-1;}{ found_syllable (symbol_cluster); }}
break;
case 4:
#line 85 "hb-ot-shape-complex-indic-machine.rl"
#line 87 "hb-ot-shape-complex-indic-machine.rl"
{{p = ((te))-1;}{ found_syllable (broken_cluster); }}
break;
case 5:
@ -1068,19 +1068,19 @@ _eof_trans:
case 22:
#line 1 "NONE"
{te = p+1;}
#line 81 "hb-ot-shape-complex-indic-machine.rl"
#line 83 "hb-ot-shape-complex-indic-machine.rl"
{act = 1;}
break;
case 6:
#line 1 "NONE"
{te = p+1;}
#line 85 "hb-ot-shape-complex-indic-machine.rl"
#line 87 "hb-ot-shape-complex-indic-machine.rl"
{act = 5;}
break;
case 12:
#line 1 "NONE"
{te = p+1;}
#line 86 "hb-ot-shape-complex-indic-machine.rl"
#line 88 "hb-ot-shape-complex-indic-machine.rl"
{act = 6;}
break;
#line 1087 "hb-ot-shape-complex-indic-machine.hh"
@ -1108,7 +1108,7 @@ _again:
}
#line 118 "hb-ot-shape-complex-indic-machine.rl"
#line 120 "hb-ot-shape-complex-indic-machine.rl"
}

View File

@ -69,12 +69,14 @@ halant_group = (z?.H.(ZWJ.N?)?);
final_halant_group = halant_group | H.ZWNJ;
halant_or_matra_group = (final_halant_group | matra_group{0,4});
complex_syllable_tail = (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
consonant_syllable = (Repha|CS)? cn (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
vowel_syllable = reph? V.n? (ZWJ | (halant_group.cn){0,4} halant_or_matra_group syllable_tail);
standalone_cluster = ((Repha|CS)? PLACEHOLDER | reph? DOTTEDCIRCLE).n? (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
consonant_syllable = (Repha|CS)? cn complex_syllable_tail;
vowel_syllable = reph? V.n? (ZWJ | complex_syllable_tail);
standalone_cluster = ((Repha|CS)? PLACEHOLDER | reph? DOTTEDCIRCLE).n? complex_syllable_tail;
symbol_cluster = symbol syllable_tail;
broken_cluster = reph? n? (halant_group.cn){0,4} halant_or_matra_group syllable_tail;
broken_cluster = reph? n? complex_syllable_tail;
other = any;
main := |*

View File

@ -315,7 +315,7 @@ static const int use_syllable_machine_en_main = 4;
#line 141 "hb-ot-shape-complex-use-machine.rl"
#line 140 "hb-ot-shape-complex-use-machine.rl"
#define found_syllable(syllable_type) \
@ -342,7 +342,7 @@ find_syllables (hb_buffer_t *buffer)
act = 0;
}
#line 161 "hb-ot-shape-complex-use-machine.rl"
#line 160 "hb-ot-shape-complex-use-machine.rl"
p = 0;
@ -387,59 +387,59 @@ _eof_trans:
{te = p+1;}
break;
case 12:
#line 130 "hb-ot-shape-complex-use-machine.rl"
#line 129 "hb-ot-shape-complex-use-machine.rl"
{te = p+1;{ found_syllable (independent_cluster); }}
break;
case 14:
#line 132 "hb-ot-shape-complex-use-machine.rl"
#line 131 "hb-ot-shape-complex-use-machine.rl"
{te = p+1;{ found_syllable (standard_cluster); }}
break;
case 9:
#line 136 "hb-ot-shape-complex-use-machine.rl"
#line 135 "hb-ot-shape-complex-use-machine.rl"
{te = p+1;{ found_syllable (broken_cluster); }}
break;
case 8:
#line 137 "hb-ot-shape-complex-use-machine.rl"
#line 136 "hb-ot-shape-complex-use-machine.rl"
{te = p+1;{ found_syllable (non_cluster); }}
break;
case 11:
#line 130 "hb-ot-shape-complex-use-machine.rl"
#line 129 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (independent_cluster); }}
break;
case 15:
#line 131 "hb-ot-shape-complex-use-machine.rl"
#line 130 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (virama_terminated_cluster); }}
break;
case 13:
#line 132 "hb-ot-shape-complex-use-machine.rl"
#line 131 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (standard_cluster); }}
break;
case 17:
#line 133 "hb-ot-shape-complex-use-machine.rl"
#line 132 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (number_joiner_terminated_cluster); }}
break;
case 16:
#line 134 "hb-ot-shape-complex-use-machine.rl"
#line 133 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (numeral_cluster); }}
break;
case 20:
#line 135 "hb-ot-shape-complex-use-machine.rl"
#line 134 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (symbol_cluster); }}
break;
case 18:
#line 136 "hb-ot-shape-complex-use-machine.rl"
#line 135 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (broken_cluster); }}
break;
case 19:
#line 137 "hb-ot-shape-complex-use-machine.rl"
#line 136 "hb-ot-shape-complex-use-machine.rl"
{te = p;p--;{ found_syllable (non_cluster); }}
break;
case 1:
#line 132 "hb-ot-shape-complex-use-machine.rl"
#line 131 "hb-ot-shape-complex-use-machine.rl"
{{p = ((te))-1;}{ found_syllable (standard_cluster); }}
break;
case 4:
#line 136 "hb-ot-shape-complex-use-machine.rl"
#line 135 "hb-ot-shape-complex-use-machine.rl"
{{p = ((te))-1;}{ found_syllable (broken_cluster); }}
break;
case 2:
@ -457,13 +457,13 @@ _eof_trans:
case 3:
#line 1 "NONE"
{te = p+1;}
#line 136 "hb-ot-shape-complex-use-machine.rl"
#line 135 "hb-ot-shape-complex-use-machine.rl"
{act = 7;}
break;
case 10:
#line 1 "NONE"
{te = p+1;}
#line 137 "hb-ot-shape-complex-use-machine.rl"
#line 136 "hb-ot-shape-complex-use-machine.rl"
{act = 8;}
break;
#line 470 "hb-ot-shape-complex-use-machine.hh"
@ -491,7 +491,7 @@ _again:
}
#line 169 "hb-ot-shape-complex-use-machine.rl"
#line 168 "hb-ot-shape-complex-use-machine.rl"
}

View File

@ -97,6 +97,14 @@ dependent_vowels = VPre* VAbv* VBlw* VPst*;
vowel_modifiers = VMPre* VMAbv* VMBlw* VMPst*;
final_consonants = FAbv* FBlw* FPst* FM?;
complex_syllable_tail =
consonant_modifiers
medial_consonants
dependent_vowels
vowel_modifiers
final_consonants
;
virama_terminated_cluster =
(R|CS)? (B | GB) VS?
consonant_modifiers
@ -104,19 +112,11 @@ virama_terminated_cluster =
;
standard_cluster =
(R|CS)? (B | GB) VS?
consonant_modifiers
medial_consonants
dependent_vowels
vowel_modifiers
final_consonants
complex_syllable_tail
;
broken_cluster =
R?
consonant_modifiers
medial_consonants
dependent_vowels
vowel_modifiers
final_consonants
complex_syllable_tail
;
number_joiner_terminated_cluster = N VS? (HN N VS?)* HN;