added rollbacking functionality to trier (for namespaces)
[swftools.git] / lib / as3 / tokenizer.lex
index 54904aa..732c97f 100644 (file)
@@ -156,7 +156,7 @@ void handleInclude(char*text, int len, char quotes)
         filename = strdup(&text[i1]);
     }
     
-    char*fullfilename = find_file(filename);
+    char*fullfilename = find_file(filename, 1);
     enter_file2(filename, fullfilename, YY_CURRENT_BUFFER);
     yyin = fopen(fullfilename, "rb");
     if (!yyin) {
@@ -259,8 +259,15 @@ static int do_unescape(const char*s, const char*end, char*n)
                 }
                break;
            }
-            default:
-                syntaxerror("unknown escape sequence: \"\\%c\"", *s);
+            default: {
+               if(o) {
+                    o[len+0] = '\\';
+                    o[len+1] = *s;
+                }
+                s++;
+                len+=2;
+                break;
+            }
         }
     }
     if(o) o[len]=0;
@@ -288,12 +295,6 @@ static void handleCData(char*s, int len)
 
 static void handleString(char*s, int len)
 {
-    if(as3_pass < 2) {
-        // don't bother decoding strings in pass 1
-        memset(&a3_lval, 0, sizeof(a3_lval));
-        return;
-    }
-
     if(s[0]=='"') {
         if(s[len-1]!='"') syntaxerror("String doesn't end with '\"'");
         s++;len-=2;
@@ -303,7 +304,6 @@ static void handleString(char*s, int len)
         s++;len-=2;
     }
     else syntaxerror("String incorrectly terminated");
-
     
     a3_lval.str = string_unescape(s, len);
 }
@@ -369,14 +369,14 @@ static inline int handleint()
 
     char*max = l?"1073741824":"2147483647";
     if(yyleng-l>10) {
-        as3_warning("integer overflow: %s (converted to Number)", s);
+        as3_softwarning("integer overflow: %s (converted to Number)", s);
         return handlefloat();
     }
     if(yyleng-l==10) {
         int t;
         for(t=0;t<yyleng-l;t++) {
             if(yytext[l+t]>max[t]) {
-                as3_warning("integer overflow: %s (converted to Number)", s);
+                as3_softwarning("integer overflow: %s (converted to Number)", s);
                 return handlefloat();
             }
             else if(yytext[l+t]<max[t])
@@ -444,12 +444,12 @@ static inline int handlehex()
     }
     if(l && v>1073741824) {
         char*s = nrbuf();
-        as3_warning("signed integer overflow: %s (converted to Number)", s);
+        as3_softwarning("signed integer overflow: %s (converted to Number)", s);
         return setfloat(v);
     }
     if(!l && v>2147483647) {
         char*s = nrbuf();
-        as3_warning("unsigned integer overflow: %s (converted to Number)", s);
+        as3_softwarning("unsigned integer overflow: %s (converted to Number)", s);
         return setfloat(v);
     }
 
@@ -516,14 +516,18 @@ static inline void c() {
     current_column+=yyleng;
 }
 
-static trie_t*namespaces = 0;
-void tokenizer_register_namespace(const char*id)
+trie_t*active_namespaces = 0;
+/*void tokenizer_register_namespace(const char*id)
 {
-    trie_put(&namespaces, id);
+    trie_put(namespaces, id, 0);
 }
+void tokenizer_unregister_namespace(const char*id)
+{
+    trie_remove(namespaces, id);
+}*/
 static inline tokenizer_is_namespace(const char*id)
 {
-    return trie_lookup(namespaces, id);
+    return trie_contains(active_namespaces, id);
 }
 
 static inline int handleIdentifier()
@@ -638,7 +642,7 @@ switch                       {c();BEGIN(INITIAL);a3_lval.id="";return T_SWITCH;}
 \.\.                         {c();BEGIN(REGEXPOK);return m(T_DOTDOT);}
 \.                           {c();BEGIN(REGEXPOK);return m('.');}
 ::                           {c();BEGIN(REGEXPOK);return m(T_COLONCOLON);}
-:                            {c();BEGIN(INITIAL);return m(':');}
+:                            {c();BEGIN(REGEXPOK);return m(':');}
 instanceof                   {c();BEGIN(REGEXPOK);return m(KW_INSTANCEOF);}
 implements                   {c();BEGIN(REGEXPOK);return m(KW_IMPLEMENTS);}
 interface                    {c();BEGIN(INITIAL);return m(KW_INTERFACE);}
@@ -687,7 +691,7 @@ is                           {c();BEGIN(REGEXPOK);return m(KW_IS) ;}
 in                           {c();BEGIN(REGEXPOK);return m(KW_IN) ;}
 if                           {c();BEGIN(INITIAL);return m(KW_IF) ;}
 as                           {c();BEGIN(REGEXPOK);return m(KW_AS);}
-{NAME}                       {c();BEGIN(INITIAL);return handleIdentifier();}
+$?{NAME}                       {c();BEGIN(INITIAL);return handleIdentifier();}
 
 [\]\}*]                       {c();BEGIN(INITIAL);return m(yytext[0]);}
 [+-\/^~@$!%&\(=\[|?:;,<>]   {c();BEGIN(REGEXPOK);return m(yytext[0]);}