moved global variables/routines to common.h
[swftools.git] / lib / as3 / tokenizer.lex
index 9ac9607..012602e 100644 (file)
 #include <stdio.h>
 #include <stdarg.h>
 #include "../utf8.h"
+#include "common.h"
 #include "tokenizer.h"
 #include "files.h"
 
-int as3_pass = 0;
-int as3_verbosity = 1;
 unsigned int as3_tokencount = 0;
 
-void as3_error(const char*format, ...)
-{
-    char buf[1024];
-    int l;
-    va_list arglist;
-    if(as3_verbosity<0)
-        exit(1);
-    va_start(arglist, format);
-    vsprintf(buf, format, arglist);
-    va_end(arglist);
-    fprintf(stderr, "%s:%d:%d: error: %s\n", current_filename_short, current_line, current_column, buf);
-    fflush(stderr);
-    exit(1);
-}
-void as3_warning(const char*format, ...)
-{
-    char buf[1024];
-    int l;
-    va_list arglist;
-    if(as3_verbosity<1)
-        return;
-    va_start(arglist, format);
-    vsprintf(buf, format, arglist);
-    va_end(arglist);
-    fprintf(stderr, "%s:%d:%d: warning: %s\n", current_filename_short, current_line, current_column, buf);
-    fflush(stderr);
-}
-void as3_softwarning(const char*format, ...)
-{
-    char buf[1024];
-    int l;
-    va_list arglist;
-    if(as3_verbosity<2)
-       return;
-    va_start(arglist, format);
-    vsprintf(buf, format, arglist);
-    va_end(arglist);
-    fprintf(stderr, "%s:%d:%d: warning: %s\n", current_filename_short, current_line, current_column, buf);
-    fflush(stderr);
-}
 static void dbg(const char*format, ...)
 {
     char buf[1024];
@@ -295,12 +254,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;
@@ -310,7 +263,6 @@ static void handleString(char*s, int len)
         s++;len-=2;
     }
     else syntaxerror("String incorrectly terminated");
-
     
     a3_lval.str = string_unescape(s, len);
 }
@@ -523,18 +475,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()