VOWEL   [aeiouyAEIOUY]
UUOO    (OO|UU|oo|uu)
HAT     [aeoAEO]
MARKS   ['`?~^]
DOT     "d"
PAR     "u"
SAC     (sac|Sac)
HUY     (huy|Huy)
HOI     (hoi|Hoi)
NGA     (nga|Nga)
NAN     nan

%%
\\{MARKS}"{"{VOWEL}"}"          {printf ("%c%c", *(yytext+3),*(yytext+1));}
\\{DOT}"{"{VOWEL}"}"            {printf ("%c.", *(yytext+3));}
\\{PAR}"{"{VOWEL}"}"            {printf ("%c(", *(yytext+3));}

\\(DD|dd)" "                    {printf ("%c%c", *(yytext+1), *(yytext+1));}
"{"\\{UUOO}"}"                  {printf ("%c%c", *(yytext+2), *(yytext+2));}

\\{SAC}"{"\\{MARKS}"{"{VOWEL}"}}"       {printf ("%c%c'", *(yytext+8), *(yytext+6));}
\\{HUY}"{"\\{MARKS}"{"{VOWEL}"}}"       {printf ("%c%c`", *(yytext+8), *(yytext+6));}
\\{HOI}"{"\\{MARKS}"{"{VOWEL}"}}"       {printf ("%c%c?", *(yytext+8), *(yytext+6));}
\\{NGA}"{"\\{MARKS}"{"{VOWEL}"}}"       {printf ("%c%c~", *(yytext+8), *(yytext+6));}
\\{NAN}"{"\\{MARKS}"{"{VOWEL}"}}"       {printf ("%c%c.", *(yytext+8), *(yytext+6));}

\\{SAC}"{"\\{PAR}"{"{VOWEL}"}}"         {printf ("%c('", *(yytext+8));}
\\{HUY}"{"\\{PAR}"{"{VOWEL}"}}"         {printf ("%c(`", *(yytext+8));}
\\{HOI}"{"\\{PAR}"{"{VOWEL}"}}"         {printf ("%c(?", *(yytext+8));}
\\{NGA}"{"\\{PAR}"{"{VOWEL}"}}"         {printf ("%c(~", *(yytext+8));}
\\{NAN}"{"\\{PAR}"{"{VOWEL}"}}"         {printf ("%c(.", *(yytext+8));}

\\{SAC}"{"\\{UUOO}"}"           {printf ("%c%c'", *(yytext+6), *(yytext+6));}
\\{HUY}"{"\\{UUOO}"}"           {printf ("%c%c`", *(yytext+6), *(yytext+6));}
\\{HOI}"{"\\{UUOO}"}"           {printf ("%c%c?", *(yytext+6), *(yytext+6));}
\\{NGA}"{"\\{UUOO}"}"           {printf ("%c%c~", *(yytext+6), *(yytext+6));}
\\{NAN}"{"\\{UUOO}"}"           {printf ("%c%c.", *(yytext+6), *(yytext+6));}

\n                              {ECHO;}
                               {ECHO;}