[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) \ #define found_syllable(syllable_type) \
@ -938,7 +938,7 @@ find_syllables (hb_buffer_t *buffer)
act = 0; act = 0;
} }
#line 110 "hb-ot-shape-complex-indic-machine.rl" #line 112 "hb-ot-shape-complex-indic-machine.rl"
p = 0; p = 0;
@ -983,71 +983,71 @@ _eof_trans:
{te = p+1;} {te = p+1;}
break; break;
case 14: 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); }} {te = p+1;{ found_syllable (consonant_syllable); }}
break; break;
case 16: 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); }} {te = p+1;{ found_syllable (vowel_syllable); }}
break; break;
case 21: 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); }} {te = p+1;{ found_syllable (standalone_cluster); }}
break; break;
case 24: 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); }} {te = p+1;{ found_syllable (symbol_cluster); }}
break; break;
case 18: 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); }} {te = p+1;{ found_syllable (broken_cluster); }}
break; break;
case 11: 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); }} {te = p+1;{ found_syllable (non_indic_cluster); }}
break; break;
case 13: 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); }} {te = p;p--;{ found_syllable (consonant_syllable); }}
break; break;
case 15: 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); }} {te = p;p--;{ found_syllable (vowel_syllable); }}
break; break;
case 20: 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); }} {te = p;p--;{ found_syllable (standalone_cluster); }}
break; break;
case 23: 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); }} {te = p;p--;{ found_syllable (symbol_cluster); }}
break; break;
case 17: 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); }} {te = p;p--;{ found_syllable (broken_cluster); }}
break; break;
case 19: 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); }} {te = p;p--;{ found_syllable (non_indic_cluster); }}
break; break;
case 1: 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); }} {{p = ((te))-1;}{ found_syllable (consonant_syllable); }}
break; break;
case 3: 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); }} {{p = ((te))-1;}{ found_syllable (vowel_syllable); }}
break; break;
case 7: 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); }} {{p = ((te))-1;}{ found_syllable (standalone_cluster); }}
break; break;
case 8: 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); }} {{p = ((te))-1;}{ found_syllable (symbol_cluster); }}
break; break;
case 4: 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); }} {{p = ((te))-1;}{ found_syllable (broken_cluster); }}
break; break;
case 5: case 5:
@ -1068,19 +1068,19 @@ _eof_trans:
case 22: case 22:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 81 "hb-ot-shape-complex-indic-machine.rl" #line 83 "hb-ot-shape-complex-indic-machine.rl"
{act = 1;} {act = 1;}
break; break;
case 6: case 6:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 85 "hb-ot-shape-complex-indic-machine.rl" #line 87 "hb-ot-shape-complex-indic-machine.rl"
{act = 5;} {act = 5;}
break; break;
case 12: case 12:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 86 "hb-ot-shape-complex-indic-machine.rl" #line 88 "hb-ot-shape-complex-indic-machine.rl"
{act = 6;} {act = 6;}
break; break;
#line 1087 "hb-ot-shape-complex-indic-machine.hh" #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; final_halant_group = halant_group | H.ZWNJ;
halant_or_matra_group = (final_halant_group | matra_group{0,4}); 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); consonant_syllable = (Repha|CS)? cn complex_syllable_tail;
standalone_cluster = ((Repha|CS)? PLACEHOLDER | reph? DOTTEDCIRCLE).n? (halant_group.cn){0,4} halant_or_matra_group 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; 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; other = any;
main := |* 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) \ #define found_syllable(syllable_type) \
@ -342,7 +342,7 @@ find_syllables (hb_buffer_t *buffer)
act = 0; act = 0;
} }
#line 161 "hb-ot-shape-complex-use-machine.rl" #line 160 "hb-ot-shape-complex-use-machine.rl"
p = 0; p = 0;
@ -387,59 +387,59 @@ _eof_trans:
{te = p+1;} {te = p+1;}
break; break;
case 12: 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); }} {te = p+1;{ found_syllable (independent_cluster); }}
break; break;
case 14: 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); }} {te = p+1;{ found_syllable (standard_cluster); }}
break; break;
case 9: 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); }} {te = p+1;{ found_syllable (broken_cluster); }}
break; break;
case 8: 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); }} {te = p+1;{ found_syllable (non_cluster); }}
break; break;
case 11: 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); }} {te = p;p--;{ found_syllable (independent_cluster); }}
break; break;
case 15: 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); }} {te = p;p--;{ found_syllable (virama_terminated_cluster); }}
break; break;
case 13: 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); }} {te = p;p--;{ found_syllable (standard_cluster); }}
break; break;
case 17: 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); }} {te = p;p--;{ found_syllable (number_joiner_terminated_cluster); }}
break; break;
case 16: 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); }} {te = p;p--;{ found_syllable (numeral_cluster); }}
break; break;
case 20: 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); }} {te = p;p--;{ found_syllable (symbol_cluster); }}
break; break;
case 18: 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); }} {te = p;p--;{ found_syllable (broken_cluster); }}
break; break;
case 19: 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); }} {te = p;p--;{ found_syllable (non_cluster); }}
break; break;
case 1: 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); }} {{p = ((te))-1;}{ found_syllable (standard_cluster); }}
break; break;
case 4: 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); }} {{p = ((te))-1;}{ found_syllable (broken_cluster); }}
break; break;
case 2: case 2:
@ -457,13 +457,13 @@ _eof_trans:
case 3: case 3:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 136 "hb-ot-shape-complex-use-machine.rl" #line 135 "hb-ot-shape-complex-use-machine.rl"
{act = 7;} {act = 7;}
break; break;
case 10: case 10:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 137 "hb-ot-shape-complex-use-machine.rl" #line 136 "hb-ot-shape-complex-use-machine.rl"
{act = 8;} {act = 8;}
break; break;
#line 470 "hb-ot-shape-complex-use-machine.hh" #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*; vowel_modifiers = VMPre* VMAbv* VMBlw* VMPst*;
final_consonants = FAbv* FBlw* FPst* FM?; final_consonants = FAbv* FBlw* FPst* FM?;
complex_syllable_tail =
consonant_modifiers
medial_consonants
dependent_vowels
vowel_modifiers
final_consonants
;
virama_terminated_cluster = virama_terminated_cluster =
(R|CS)? (B | GB) VS? (R|CS)? (B | GB) VS?
consonant_modifiers consonant_modifiers
@ -104,19 +112,11 @@ virama_terminated_cluster =
; ;
standard_cluster = standard_cluster =
(R|CS)? (B | GB) VS? (R|CS)? (B | GB) VS?
consonant_modifiers complex_syllable_tail
medial_consonants
dependent_vowels
vowel_modifiers
final_consonants
; ;
broken_cluster = broken_cluster =
R? R?
consonant_modifiers complex_syllable_tail
medial_consonants
dependent_vowels
vowel_modifiers
final_consonants
; ;
number_joiner_terminated_cluster = N VS? (HN N VS?)* HN; number_joiner_terminated_cluster = N VS? (HN N VS?)* HN;