[buffer/serialize] Minor renames in Ragel machines

As per my previous review on:
https://github.com/harfbuzz/harfbuzz/pull/2687
This commit is contained in:
Behdad Esfahbod 2020-10-09 21:06:20 -06:00
parent 540d2cdddb
commit 4a4eebcf86
4 changed files with 86 additions and 58 deletions

View File

@ -338,7 +338,7 @@ static const char _deserialize_json_indicies[] = {
70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70,
1, 71, 1, 1, 1, 1, 1, 1,
1, 71, 72, 1, 1, 1, 1, 1,
1, 1, 1, 1, 72, 72, 1, 72,
72, 72, 72, 72, 72, 72, 72, 72,
72, 1, 1, 1, 1, 1, 1, 1,

View File

@ -76,14 +76,14 @@ action ensure_unicode {
}
}
action parse_glyph {
action parse_glyph_name {
if (!hb_font_glyph_from_string (font,
tok, p - tok,
&info.codepoint))
return false;
}
action parse_gid { if (!parse_uint (tok, p, &info.codepoint)) return false; }
action parse_codepoint { if (!parse_uint (tok, p, &info.codepoint)) return false; }
action parse_cluster { if (!parse_uint (tok, p, &info.cluster )) return false; }
action parse_x_offset { if (!parse_int (tok, p, &pos.x_offset )) return false; }
action parse_y_offset { if (!parse_int (tok, p, &pos.y_offset )) return false; }
@ -96,21 +96,21 @@ num = '-'? unum;
comma = space* ',' space*;
colon = space* ':' space*;
glyph_id = unum;
glyph_name = alpha (alnum|'_'|'.'|'-')*;
codepoint = unum;
glyph_name = alpha (alnum|'_'|'.'|'-'|'#')*;
glyph_string = '"' (glyph_name >tok %parse_glyph) '"';
glyph_number = (glyph_id >tok %parse_gid);
parse_glyph_name = '"' (glyph_name >tok %parse_glyph_name) '"';
parse_codepoint = (codepoint >tok %parse_codepoint);
glyph = "\"g\"" colon (glyph_string | glyph_number) @ensure_glyphs;
codepoint = "\"u\"" colon glyph_number @ensure_unicode;
glyph = "\"g\"" colon (parse_glyph_name | parse_codepoint) @ensure_glyphs;
unicode = "\"u\"" colon parse_codepoint @ensure_unicode;
cluster = "\"cl\"" colon (unum >tok %parse_cluster);
xoffset = "\"dx\"" colon (num >tok %parse_x_offset);
yoffset = "\"dy\"" colon (num >tok %parse_y_offset);
xadvance= "\"ax\"" colon (num >tok %parse_x_advance);
yadvance= "\"ay\"" colon (num >tok %parse_y_advance);
element = glyph | codepoint | cluster | xoffset | yoffset | xadvance | yadvance;
element = glyph | unicode | cluster | xoffset | yoffset | xadvance | yadvance;
item =
( '{' space* element (comma element)* space* '}')
>clear_item

View File

@ -402,24 +402,24 @@ static const char _deserialize_text_trans_targs[] = {
};
static const char _deserialize_text_trans_actions[] = {
0, 0, 0, 0, 0, 1, 2, 0,
2, 2, 3, 3, 3, 0, 2, 2,
2, 0, 0, 2, 2, 2, 0, 0,
2, 2, 2, 2, 2, 0, 0, 4,
2, 2, 2, 0, 0, 5, 0, 6,
5, 5, 0, 0, 0, 7, 7, 7,
0, 8, 9, 9, 9, 8, 8, 0,
0, 10, 11, 12, 11, 11, 13, 13,
13, 7, 14, 14, 7, 15, 16, 15,
15, 0, 10
0, 0, 0, 0, 1, 0, 2, 0,
3, 3, 4, 4, 4, 0, 3, 3,
3, 0, 0, 3, 3, 3, 0, 0,
3, 3, 3, 3, 3, 0, 0, 5,
3, 3, 3, 0, 0, 6, 7, 8,
6, 6, 0, 0, 0, 9, 9, 9,
0, 10, 11, 11, 11, 10, 10, 0,
0, 12, 13, 14, 13, 13, 15, 15,
15, 9, 16, 16, 9, 17, 18, 17,
17, 0, 12
};
static const char _deserialize_text_eof_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 5, 0, 0, 0,
7, 7, 8, 0, 0, 8, 11, 13,
13, 11, 7, 15, 15, 7, 8
0, 0, 0, 0, 6, 0, 0, 0,
9, 9, 10, 0, 0, 10, 13, 15,
15, 13, 9, 17, 17, 9, 10
};
static const int deserialize_text_start = 1;
@ -429,7 +429,7 @@ static const int deserialize_text_error = 0;
static const int deserialize_text_en_main = 1;
#line 124 "hb-buffer-deserialize-text.rl"
#line 132 "hb-buffer-deserialize-text.rl"
static hb_bool_t
@ -482,13 +482,20 @@ _resume:
goto _again;
switch ( _deserialize_text_trans_actions[_trans] ) {
case 2:
case 1:
#line 38 "hb-buffer-deserialize-text.rl"
{
memset (&info, 0, sizeof (info));
memset (&pos , 0, sizeof (pos ));
}
break;
case 3:
#line 51 "hb-buffer-deserialize-text.rl"
{
tok = p;
}
break;
case 10:
case 12:
#line 55 "hb-buffer-deserialize-text.rl"
{
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_GLYPHS))
@ -502,7 +509,21 @@ _resume:
}
}
break;
case 9:
case 7:
#line 67 "hb-buffer-deserialize-text.rl"
{
if (unlikely (buffer->content_type != HB_BUFFER_CONTENT_TYPE_UNICODE))
{
if (buffer->content_type != HB_BUFFER_CONTENT_TYPE_INVALID) {
buffer->clear();
return false;
}
assert (buffer->len == 0);
buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE;
}
}
break;
case 11:
#line 79 "hb-buffer-deserialize-text.rl"
{
if (!hb_font_glyph_from_string (font,
@ -511,31 +532,30 @@ _resume:
return false;
}
break;
case 6:
case 8:
#line 86 "hb-buffer-deserialize-text.rl"
{if (!parse_hex (tok, p, &info.codepoint )) return false; }
break;
case 14:
case 16:
#line 88 "hb-buffer-deserialize-text.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; }
break;
case 4:
case 5:
#line 89 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_offset )) return false; }
break;
case 16:
case 18:
#line 90 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; }
break;
case 12:
case 14:
#line 91 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; }
break;
case 1:
#line 38 "hb-buffer-deserialize-text.rl"
case 2:
#line 51 "hb-buffer-deserialize-text.rl"
{
memset (&info, 0, sizeof (info));
memset (&pos , 0, sizeof (pos ));
tok = p;
}
#line 67 "hb-buffer-deserialize-text.rl"
{
@ -550,7 +570,7 @@ _resume:
}
}
break;
case 8:
case 10:
#line 79 "hb-buffer-deserialize-text.rl"
{
if (!hb_font_glyph_from_string (font,
@ -567,7 +587,7 @@ _resume:
*end_ptr = p;
}
break;
case 5:
case 6:
#line 86 "hb-buffer-deserialize-text.rl"
{if (!parse_hex (tok, p, &info.codepoint )) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -579,7 +599,7 @@ _resume:
*end_ptr = p;
}
break;
case 7:
case 9:
#line 88 "hb-buffer-deserialize-text.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -591,7 +611,7 @@ _resume:
*end_ptr = p;
}
break;
case 15:
case 17:
#line 90 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -603,7 +623,7 @@ _resume:
*end_ptr = p;
}
break;
case 11:
case 13:
#line 91 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -615,7 +635,7 @@ _resume:
*end_ptr = p;
}
break;
case 13:
case 15:
#line 92 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -627,7 +647,7 @@ _resume:
*end_ptr = p;
}
break;
case 3:
case 4:
#line 38 "hb-buffer-deserialize-text.rl"
{
memset (&info, 0, sizeof (info));
@ -650,7 +670,7 @@ _resume:
}
}
break;
#line 654 "hb-buffer-deserialize-text.hh"
#line 674 "hb-buffer-deserialize-text.hh"
}
_again:
@ -662,7 +682,7 @@ _again:
if ( p == eof )
{
switch ( _deserialize_text_eof_actions[cs] ) {
case 8:
case 10:
#line 79 "hb-buffer-deserialize-text.rl"
{
if (!hb_font_glyph_from_string (font,
@ -679,7 +699,7 @@ _again:
*end_ptr = p;
}
break;
case 5:
case 6:
#line 86 "hb-buffer-deserialize-text.rl"
{if (!parse_hex (tok, p, &info.codepoint )) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -691,7 +711,7 @@ _again:
*end_ptr = p;
}
break;
case 7:
case 9:
#line 88 "hb-buffer-deserialize-text.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -703,7 +723,7 @@ _again:
*end_ptr = p;
}
break;
case 15:
case 17:
#line 90 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -715,7 +735,7 @@ _again:
*end_ptr = p;
}
break;
case 11:
case 13:
#line 91 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -727,7 +747,7 @@ _again:
*end_ptr = p;
}
break;
case 13:
case 15:
#line 92 "hb-buffer-deserialize-text.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; }
#line 43 "hb-buffer-deserialize-text.rl"
@ -739,14 +759,14 @@ _again:
*end_ptr = p;
}
break;
#line 743 "hb-buffer-deserialize-text.hh"
#line 763 "hb-buffer-deserialize-text.hh"
}
}
_out: {}
}
#line 148 "hb-buffer-deserialize-text.rl"
#line 156 "hb-buffer-deserialize-text.rl"
*end_ptr = p;

View File

@ -102,10 +102,7 @@ cluster = '=' (unum >tok %parse_cluster);
offsets = '@' (num >tok %parse_x_offset) ',' (num >tok %parse_y_offset );
advances= '+' (num >tok %parse_x_advance) (',' (num >tok %parse_y_advance))?;
codepoint = xdigit+ >tok %parse_hexdigits;
unicode_id = 'U' '+' >clear_item @ensure_unicode codepoint cluster? %add_item;
item =
glyph_item =
(
glyph
cluster?
@ -116,8 +113,19 @@ item =
%add_item
;
glyphs = item (space* '|' space* item)* space* ('|'|']')?;
unicodes = unicode_id (space* '|' space* unicode_id)* space* ('|'|'>')?;
unicode = 'U' '+' xdigit+ >tok @ensure_unicode %parse_hexdigits;
unicode_item =
(
unicode
cluster?
)
>clear_item
%add_item
;
glyphs = glyph_item (space* '|' space* glyph_item)* space* ('|'|']')?;
unicodes = unicode_item (space* '|' space* unicode_item)* space* ('|'|'>')?;
main := space* ( ('[' glyphs) | ('<' unicodes) );