also test for .exe progs on win32
[supertux.git] / tools / miniswig / parser.yy
index e66b58c..1aae8ce 100644 (file)
@@ -3,8 +3,8 @@
 #include <iostream>
 #include <sstream>
 #include <stdexcept>
-#include "tree.h"
-#include "globals.h"
+#include "tree.hpp"
+#include "globals.hpp"
 
 %}
 
@@ -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();
     }
@@ -62,10 +63,11 @@ private:
 %token <str>  T_STRING
 %token <str>  T_ID
 %token <atomic_type> T_ATOMIC_TYPE
-%token <_namespace> T_NAMESPACEREF;
+%token <_namespace> T_NAMESPACEREF
 %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,53 @@ 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 ';'
+        {
+            delete $1;
+            free($2);
+        }
 ;
 
 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
@@ -247,7 +271,7 @@ parameter:
             Parameter parameter;
             parameter.type = *($1);
             delete $1;
-            parameter.name = *($2);
+            parameter.name = $2;
             free($2);
             currentFunction->parameters.push_back(parameter);
         }
@@ -270,9 +294,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: