summaryrefslogtreecommitdiff
path: root/src/format/mangling/dex/type_tok.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/mangling/dex/type_tok.l')
-rw-r--r--src/format/mangling/dex/type_tok.l115
1 files changed, 112 insertions, 3 deletions
diff --git a/src/format/mangling/dex/type_tok.l b/src/format/mangling/dex/type_tok.l
index 7b8a8d3..9c24085 100644
--- a/src/format/mangling/dex/type_tok.l
+++ b/src/format/mangling/dex/type_tok.l
@@ -10,10 +10,13 @@
%option noyywrap
%option yylineno
%option nounput
-%option noinput
+ /*%option noinput*/
%x string
+ASCII [A-Za-z0-9]
+SIMPLE {ASCII}|"$"|"-"|"_"
+
%%
"V" { return V; }
@@ -28,10 +31,116 @@
"L" { BEGIN(string); return L; }
"["* { type_lval.adeep = strlen(yytext); return ARRAY; }
<string>"/" { return SLASH; }
-<string>"$" { return DOLLAR; }
<string>";" { BEGIN(INITIAL); return SEMICOLON; }
-<string>[A-Za-z0-9_-]* { type_lval.text = yytext; return TEXT; }
+<string>{SIMPLE}* { type_lval.text = yytext; return TEXT; }
+
+<string>. {
+ unsigned char next;
+ char mutf8[4];
+
+ switch ((unsigned char)yytext[0])
+ {
+ /* U+00a1 ... U+1fff */
+ case 0x00 ... 0x1f:
+
+ next = input();
+
+ if (yytext[0] == 0x00 && next < 0xa1)
+ {
+ REJECT;
+ }
+
+ else
+ {
+ mutf8[0] = yytext[0];
+ mutf8[1] = next;
+ mutf8[2] = '\0';
+
+ strcpy(type_lval.text, mutf8); return TEXT;
+
+ }
+
+ break;
+
+ /* U+2010 ... U+2027 / U+2030 ... U+d7ff */
+ case 0x20:
+
+ next = input();
+
+ switch (next)
+ {
+ case 0x10 ... 0x27:
+ case 0x30 ... 0xff:
+
+ mutf8[0] = yytext[0];
+ mutf8[1] = next;
+ mutf8[2] = '\0';
+
+ strcpy(type_lval.text, mutf8); return TEXT;
+ break;
+
+ default:
+ REJECT;
+ break;
+
+ }
+
+ break;
+
+ /* ~ U+2030 ... U+d7ff */
+ case 0x21 ... 0xd7:
+
+ next = input();
+
+ mutf8[0] = yytext[0];
+ mutf8[1] = next;
+ mutf8[2] = '\0';
+
+ strcpy(type_lval.text, mutf8); return TEXT;
+ break;
+
+ /* U+e000 ... U+ffef */
+ case 0xe0 ... 0xff:
+
+ next = input();
+
+ if (yytext[0] == 0xff && next > 0xef)
+ {
+ REJECT;
+ }
+
+ else
+ {
+ mutf8[0] = yytext[0];
+ mutf8[1] = next;
+ mutf8[2] = '\0';
+
+ strcpy(type_lval.text, mutf8); return TEXT;
+
+ }
+
+ break;
+
+ /* U+10000 ... U+10ffff */
+ /*
+ case 0x10:
+
+ mutf8[0] = yytext[0];
+ mutf8[1] = input();
+ mutf8[2] = input();
+ mutf8[3] = '\0';
+
+ strcpy(type_lval.text, mutf8); return TEXT;
+ break;
+ */
+
+ default:
+ REJECT;
+ break;
+
+ }
+ }
%%