- Changed DocBook version to 4.3, 5.0 is not officially released yet and most
[supertux.git] / tools / miniswig / parser.yy
index e66b58c..d405dde 100644 (file)
@@ -40,7 +40,8 @@ public:
     ParseError(const std::string& message) throw()
     {
         std::ostringstream msg;
-        msg << "Parse error in line " << yylineno << ": "
+        msg << "Parse error in '" << current_file
+            << "' line " << getCurrentLine() << ": "
             << message;
         this->message = msg.str();
     }
@@ -66,6 +67,7 @@ private:
 %token T_CLASS
 %token T_STRUCT
 %token T_STATIC
+%token T_VIRTUAL
 %token T_CONST
 %token T_UNSIGNED
 %token T_SIGNED
@@ -140,6 +142,8 @@ class_declaration:
             current_class = new Class();
             current_class->name = $2;
             free($2);
+            current_class->docu_comment = last_docucomment;
+            last_docucomment = "";
             current_visibility = ClassMember::PROTECTED;
         }
     class_body '}' ';'
@@ -186,6 +190,8 @@ constructor_declaration:
         {
             currentFunction = new Function();
             currentFunction->type = Function::CONSTRUCTOR;
+            currentFunction->docu_comment = last_docucomment;
+            last_docucomment = "";
             free($1);
         }
     parameter_list ')' ';'
@@ -195,35 +201,49 @@ constructor_declaration:
 ;
 
 destructor_declaration:
-    '~' T_ID '(' ')' ';'
+    maybe_virtual '~' T_ID '(' ')' abstract_declaration ';'
         {
             currentFunction = new Function();
             currentFunction->type = Function::DESTRUCTOR;
-            free($2);
+            currentFunction->docu_comment = last_docucomment;
+            last_docucomment = "";
+            free($3);
             $$ = currentFunction;
         }
 ;
 
+maybe_virtual:
+    /* empty */
+    | T_VIRTUAL
+;
+
 variable_declaration:
     type T_ID ';'
 ;
 
 function_declaration:
-    type T_ID '(' 
+    maybe_virtual type T_ID '(' 
         {
             currentFunction = new Function();
             currentFunction->type = Function::FUNCTION;
-            currentFunction->return_type = *($1);
-            delete $1;
-            currentFunction->name = $2;
-            free($2);
+            currentFunction->return_type = *($2);
+            delete $2;
+            currentFunction->name = $3;
+            free($3);
+            currentFunction->docu_comment = last_docucomment;
+            last_docucomment = "";
         }                           
-    parameter_list ')' ';'
+    parameter_list ')' abstract_declaration ';'
         {
             $$ = currentFunction;
         }
 ;
 
+abstract_declaration:
+    /* empty */
+    | '=' T_INT
+;
+
 parameter_list:
     /* empty */
     | parameters
@@ -270,9 +290,13 @@ prefix_type_modifiers:
 
 prefix_type_modifier:
     T_UNSIGNED
+        { current_type->_unsigned = true; }
     | T_SIGNED
+        { current_type->_unsigned = false; }
     | T_STATIC
+        { current_type->_static = true; }
     | T_CONST
+        { current_type->_const = true; }
 ;
 
 postfix_type_modifiers: