- Implemented a scripted object that can be placed in a level and whose name is
[supertux.git] / tools / miniswig / lexer.ll
index dc019e8..0e6229c 100644 (file)
 
 %%
 
+#.*                                     /* ignore preprocessor directives */
 [[:space:]]+                            /* eat spaces */
 \/\*.*\*\/                              /* eat comment */
 \/\/[^\n]*\n                            /* eat comment */        
 class                                   { return T_CLASS; }
 struct                                  { return T_STRUCT; }
 static                                  { return T_STATIC; }
+virtual                                 { return T_VIRTUAL; }
 const                                   { return T_CONST; }
 unsigned                                { return T_UNSIGNED; }
 signed                                  { return T_SIGNED; }
@@ -41,10 +43,14 @@ double                                  { return T_DOUBLE; }
 public                                  { return T_PUBLIC; }
 protected                               { return T_PROTECTED; }
 private                                 { return T_PRIVATE; }
+namespace                               { return T_NAMESPACE; }
 [a-zA-Z_][a-zA-Z_0-9]*                  {
+        Namespace* ns = search_namespace;
+        if(ns == 0)
+            ns = current_namespace;          
         // is it a type?
-        for(std::vector<AtomicType*>::iterator i = unit->types.begin();
-                i != unit->types.end(); ++i) {
+        for(std::vector<AtomicType*>::iterator i = ns->types.begin();
+                i != ns->types.end(); ++i) {
             AtomicType* type = *i;
             if(type->name == yytext) {
                 yylval->atomic_type = type;
@@ -52,10 +58,11 @@ private                                 { return T_PRIVATE; }
             }
         }
         // or a namespace? (hack for now...)
-        if(strcmp(yytext, "std") == 0) {
-            yylval->_namespace = unit->namespaces[0];
-            return T_NAMESPACE;
+        yylval->_namespace = ns->_findNamespace(yytext, search_down);
+        if(yylval->_namespace) {
+            return T_NAMESPACEREF;
         }
+        // a new ID
         yylval->str = strdup(yytext);
         return T_ID;
 }