[ragel] Use ts/te (token-start / token-end) instead of manual tracking

This commit is contained in:
Behdad Esfahbod 2018-10-02 17:04:05 +02:00
parent 9efddb9de8
commit 40d5d19d5b
8 changed files with 52 additions and 68 deletions

View File

@ -916,10 +916,9 @@ static const int indic_syllable_machine_en_main = 138;
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -927,11 +926,11 @@ static const int indic_syllable_machine_en_main = 138;
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te, act;
unsigned int p, pe, eof, ts, te, act;
int cs;
hb_glyph_info_t *info = buffer->info;
#line 935 "hb-ot-shape-complex-indic-machine.hh"
#line 934 "hb-ot-shape-complex-indic-machine.hh"
{
cs = indic_syllable_machine_start;
ts = 0;
@ -939,16 +938,15 @@ find_syllables (hb_buffer_t *buffer)
act = 0;
}
#line 111 "hb-ot-shape-complex-indic-machine.rl"
#line 110 "hb-ot-shape-complex-indic-machine.rl"
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
#line 952 "hb-ot-shape-complex-indic-machine.hh"
#line 950 "hb-ot-shape-complex-indic-machine.hh"
{
int _slen;
int _trans;
@ -962,7 +960,7 @@ _resume:
#line 1 "NONE"
{ts = p;}
break;
#line 966 "hb-ot-shape-complex-indic-machine.hh"
#line 964 "hb-ot-shape-complex-indic-machine.hh"
}
_keys = _indic_syllable_machine_trans_keys + (cs<<1);
@ -1085,7 +1083,7 @@ _eof_trans:
#line 86 "hb-ot-shape-complex-indic-machine.rl"
{act = 6;}
break;
#line 1089 "hb-ot-shape-complex-indic-machine.hh"
#line 1087 "hb-ot-shape-complex-indic-machine.hh"
}
_again:
@ -1094,7 +1092,7 @@ _again:
#line 1 "NONE"
{ts = 0;}
break;
#line 1098 "hb-ot-shape-complex-indic-machine.hh"
#line 1096 "hb-ot-shape-complex-indic-machine.hh"
}
if ( ++p != pe )
@ -1110,7 +1108,7 @@ _again:
}
#line 120 "hb-ot-shape-complex-indic-machine.rl"
#line 118 "hb-ot-shape-complex-indic-machine.rl"
}

View File

@ -91,10 +91,9 @@ main := |*
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -102,7 +101,7 @@ main := |*
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te, act;
unsigned int p, pe, eof, ts, te, act;
int cs;
hb_glyph_info_t *info = buffer->info;
%%{
@ -113,7 +112,6 @@ find_syllables (hb_buffer_t *buffer)
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
%%{
write exec;

View File

@ -232,10 +232,9 @@ static const int khmer_syllable_machine_en_main = 22;
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -243,11 +242,11 @@ static const int khmer_syllable_machine_en_main = 22;
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te, act HB_UNUSED;
unsigned int p, pe, eof, ts, te, act HB_UNUSED;
int cs;
hb_glyph_info_t *info = buffer->info;
#line 251 "hb-ot-shape-complex-khmer-machine.hh"
#line 250 "hb-ot-shape-complex-khmer-machine.hh"
{
cs = khmer_syllable_machine_start;
ts = 0;
@ -255,16 +254,15 @@ find_syllables (hb_buffer_t *buffer)
act = 0;
}
#line 101 "hb-ot-shape-complex-khmer-machine.rl"
#line 100 "hb-ot-shape-complex-khmer-machine.rl"
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
#line 268 "hb-ot-shape-complex-khmer-machine.hh"
#line 266 "hb-ot-shape-complex-khmer-machine.hh"
{
int _slen;
int _trans;
@ -278,7 +276,7 @@ _resume:
#line 1 "NONE"
{ts = p;}
break;
#line 282 "hb-ot-shape-complex-khmer-machine.hh"
#line 280 "hb-ot-shape-complex-khmer-machine.hh"
}
_keys = _khmer_syllable_machine_trans_keys + (cs<<1);
@ -348,7 +346,7 @@ _eof_trans:
#line 76 "hb-ot-shape-complex-khmer-machine.rl"
{act = 3;}
break;
#line 352 "hb-ot-shape-complex-khmer-machine.hh"
#line 350 "hb-ot-shape-complex-khmer-machine.hh"
}
_again:
@ -357,7 +355,7 @@ _again:
#line 1 "NONE"
{ts = 0;}
break;
#line 361 "hb-ot-shape-complex-khmer-machine.hh"
#line 359 "hb-ot-shape-complex-khmer-machine.hh"
}
if ( ++p != pe )
@ -373,7 +371,7 @@ _again:
}
#line 110 "hb-ot-shape-complex-khmer-machine.rl"
#line 108 "hb-ot-shape-complex-khmer-machine.rl"
}

View File

@ -81,10 +81,9 @@ main := |*
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -92,7 +91,7 @@ main := |*
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te, act HB_UNUSED;
unsigned int p, pe, eof, ts, te, act HB_UNUSED;
int cs;
hb_glyph_info_t *info = buffer->info;
%%{
@ -103,7 +102,6 @@ find_syllables (hb_buffer_t *buffer)
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
%%{
write exec;

View File

@ -283,10 +283,9 @@ static const int myanmar_syllable_machine_en_main = 0;
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -294,11 +293,11 @@ static const int myanmar_syllable_machine_en_main = 0;
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
unsigned int p, pe, eof, ts, te, act HB_UNUSED;
int cs;
hb_glyph_info_t *info = buffer->info;
#line 302 "hb-ot-shape-complex-myanmar-machine.hh"
#line 301 "hb-ot-shape-complex-myanmar-machine.hh"
{
cs = myanmar_syllable_machine_start;
ts = 0;
@ -306,16 +305,15 @@ find_syllables (hb_buffer_t *buffer)
act = 0;
}
#line 115 "hb-ot-shape-complex-myanmar-machine.rl"
#line 114 "hb-ot-shape-complex-myanmar-machine.rl"
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
#line 319 "hb-ot-shape-complex-myanmar-machine.hh"
#line 317 "hb-ot-shape-complex-myanmar-machine.hh"
{
int _slen;
int _trans;
@ -329,7 +327,7 @@ _resume:
#line 1 "NONE"
{ts = p;}
break;
#line 333 "hb-ot-shape-complex-myanmar-machine.hh"
#line 331 "hb-ot-shape-complex-myanmar-machine.hh"
}
_keys = _myanmar_syllable_machine_trans_keys + (cs<<1);
@ -379,7 +377,7 @@ _eof_trans:
#line 90 "hb-ot-shape-complex-myanmar-machine.rl"
{te = p;p--;{ found_syllable (non_myanmar_cluster); }}
break;
#line 383 "hb-ot-shape-complex-myanmar-machine.hh"
#line 381 "hb-ot-shape-complex-myanmar-machine.hh"
}
_again:
@ -388,7 +386,7 @@ _again:
#line 1 "NONE"
{ts = 0;}
break;
#line 392 "hb-ot-shape-complex-myanmar-machine.hh"
#line 390 "hb-ot-shape-complex-myanmar-machine.hh"
}
if ( ++p != pe )
@ -404,7 +402,7 @@ _again:
}
#line 124 "hb-ot-shape-complex-myanmar-machine.rl"
#line 122 "hb-ot-shape-complex-myanmar-machine.rl"
}

View File

@ -95,10 +95,9 @@ main := |*
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -106,7 +105,7 @@ main := |*
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te HB_UNUSED, act HB_UNUSED;
unsigned int p, pe, eof, ts, te, act HB_UNUSED;
int cs;
hb_glyph_info_t *info = buffer->info;
%%{
@ -117,7 +116,6 @@ find_syllables (hb_buffer_t *buffer)
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
%%{
write exec;

View File

@ -320,10 +320,9 @@ static const int use_syllable_machine_en_main = 4;
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -331,11 +330,11 @@ static const int use_syllable_machine_en_main = 4;
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te, act;
unsigned int p, pe, eof, ts, te, act;
int cs;
hb_glyph_info_t *info = buffer->info;
#line 339 "hb-ot-shape-complex-use-machine.hh"
#line 338 "hb-ot-shape-complex-use-machine.hh"
{
cs = use_syllable_machine_start;
ts = 0;
@ -343,16 +342,15 @@ find_syllables (hb_buffer_t *buffer)
act = 0;
}
#line 162 "hb-ot-shape-complex-use-machine.rl"
#line 161 "hb-ot-shape-complex-use-machine.rl"
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
#line 356 "hb-ot-shape-complex-use-machine.hh"
#line 354 "hb-ot-shape-complex-use-machine.hh"
{
int _slen;
int _trans;
@ -366,7 +364,7 @@ _resume:
#line 1 "NONE"
{ts = p;}
break;
#line 370 "hb-ot-shape-complex-use-machine.hh"
#line 368 "hb-ot-shape-complex-use-machine.hh"
}
_keys = _use_syllable_machine_trans_keys + (cs<<1);
@ -468,7 +466,7 @@ _eof_trans:
#line 137 "hb-ot-shape-complex-use-machine.rl"
{act = 8;}
break;
#line 472 "hb-ot-shape-complex-use-machine.hh"
#line 470 "hb-ot-shape-complex-use-machine.hh"
}
_again:
@ -477,7 +475,7 @@ _again:
#line 1 "NONE"
{ts = 0;}
break;
#line 481 "hb-ot-shape-complex-use-machine.hh"
#line 479 "hb-ot-shape-complex-use-machine.hh"
}
if ( ++p != pe )
@ -493,7 +491,7 @@ _again:
}
#line 171 "hb-ot-shape-complex-use-machine.rl"
#line 169 "hb-ot-shape-complex-use-machine.rl"
}

View File

@ -142,10 +142,9 @@ main := |*
#define found_syllable(syllable_type) \
HB_STMT_START { \
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #syllable_type); \
for (unsigned int i = last; i < p+1; i++) \
if (0) fprintf (stderr, "syllable %d..%d %s\n", ts, te, #syllable_type); \
for (unsigned int i = ts; i < te; i++) \
info[i].syllable() = (syllable_serial << 4) | syllable_type; \
last = p+1; \
syllable_serial++; \
if (unlikely (syllable_serial == 16)) syllable_serial = 1; \
} HB_STMT_END
@ -153,7 +152,7 @@ main := |*
static void
find_syllables (hb_buffer_t *buffer)
{
unsigned int p, pe, eof, ts HB_UNUSED, te, act;
unsigned int p, pe, eof, ts, te, act;
int cs;
hb_glyph_info_t *info = buffer->info;
%%{
@ -164,7 +163,6 @@ find_syllables (hb_buffer_t *buffer)
p = 0;
pe = eof = buffer->len;
unsigned int last = 0;
unsigned int syllable_serial = 1;
%%{
write exec;