X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Ftokenizer.lex;h=4647d3065879a21526a0920bc56b8e96b5eeba5b;hb=34e395874f66f71ed68a3d74ef9d6b9f706eff06;hp=3ed3b6b09a72d801f8ab623e38f15c5dd04a04d0;hpb=9b2965dda762f2cf28b52ca9bad86eefe0836b52;p=swftools.git diff --git a/lib/as3/tokenizer.lex b/lib/as3/tokenizer.lex index 3ed3b6b..4647d30 100644 --- a/lib/as3/tokenizer.lex +++ b/lib/as3/tokenizer.lex @@ -129,16 +129,13 @@ void handleInclude(char*text, int len, char quotes) //BEGIN(INITIAL); keep context } -string_t string_unescape(const char*in, int l) +static int do_unescape(const char*s, const char*end, char*n) { - int len=0; - const char*s = in; - const char*end = &in[l]; - char*n = (char*)malloc(l); char*o = n; + int len=0; while(s256) syntaxerror("octal number out of range (0-255): %d", num); - o[len++] = num; + if(o) o[len] = num;len++; continue; } case 'x': case 'u': { @@ -214,12 +211,12 @@ string_t string_unescape(const char*in, int l) if(unicode) { char*utf8 = getUTF8(num); while(*utf8) { - o[len++] = *utf8++; + if(o) o[len] = *utf8;utf8++;len++; } } else { if(num>256) syntaxerror("byte out of range (0-255): %d", num); - o[len++] = num; + if(o) o[len] = num;len++; } break; } @@ -227,8 +224,19 @@ string_t string_unescape(const char*in, int l) syntaxerror("unknown escape sequence: \"\\%c\"", *s); } } + if(o) o[len]=0; + return len; +} + +static string_t string_unescape(const char*in, int l) +{ + const char*s = in; + const char*end = &in[l]; + + int len = do_unescape(s, end, 0); + char*n = (char*)malloc(len+1); + do_unescape(s, end, n); string_t out = string_new(n, len); - o[len]=0; return out; } @@ -497,6 +505,7 @@ native {c();return m(KW_NATIVE);} static {c();return m(KW_STATIC);} import {c();return m(KW_IMPORT);} typeof {c();return m(KW_TYPEOF);} +throw {c();return m(KW_THROW);} class {c();return m(KW_CLASS);} const {c();return m(KW_CONST);} catch {c();return m(KW_CATCH);} @@ -504,11 +513,13 @@ final {c();return m(KW_FINAL);} false {c();return m(KW_FALSE);} break {c();return m(KW_BREAK);} super {c();return m(KW_SUPER);} +each {c();return m(KW_EACH);} void {c();return m(KW_VOID);} true {c();return m(KW_TRUE);} null {c();return m(KW_NULL);} else {c();return m(KW_ELSE);} case {c();return m(KW_CASE);} +with {c();return m(KW_WITH);} use {c();return m(KW_USE);} new {c();return m(KW_NEW);} get {c();return m(KW_GET);} @@ -516,6 +527,7 @@ set {c();return m(KW_SET);} var {c();return m(KW_VAR);} try {c();return m(KW_TRY);} is {c();return m(KW_IS) ;} +in {c();return m(KW_IN) ;} if {c();return m(KW_IF) ;} as {c();return m(KW_AS);} {NAME} {c();BEGIN(INITIAL);return mkid(T_IDENTIFIER);}