compiler: (WIP) Fixes for MinGW/GCC 5
[sdk] / compiler / libec / src / grammar.y
index 9918d34..b71106a 100644 (file)
@@ -1,7 +1,9 @@
 %{
 import "ecdefs"
 
+#define YYSIZE_T size_t
 #define YYLTYPE Location
+#include "grammar.h"
 
 #ifndef YYLLOC_DEFAULT
 # define YYLLOC_DEFAULT(Current, Rhs, N)         \
@@ -24,6 +26,9 @@ int defaultMemberAccess = -1;
 
 #define POP_DEFAULT_ACCESS    if(defaultMemberAccess > -1) defaultMemberAccess--;
 
+#define C89_DECL_WARNING            $"eC expects all declarations to precede statements in the block (C89 style)\n"
+#define CASE_LABELED_STMT_WARNING   $"labeled statement directly within a case statement\n"
+
 #define uint _uint
 default:
 
@@ -51,6 +56,9 @@ default:
    External external;
    Context context;
    AsmField asmField;
+   Attrib attrib;
+   ExtDecl extDecl;
+   Attribute attribute;
 
    Instantiation instance;
    MembersInit membersInit;
@@ -65,7 +73,7 @@ default:
    TemplateParameter templateParameter;
    TemplateArgument templateArgument;
    TemplateDatatype templateDatatype;
-   
+
    DBTableEntry dbtableEntry;
    DBIndexItem dbindexItem;
    DBTableDef dbtableDef;
@@ -84,19 +92,19 @@ default:
             exclusive_or_expression inclusive_or_expression logical_and_expression
             logical_or_expression conditional_expression assignment_expression
             constant_expression constant_expression_error
-            anon_instantiation_expression anon_instantiation_expression_error
-
-%type <exp> postfix_expression_error unary_expression_error cast_expression_error
+            anon_instantiation_expression anon_instantiation_expression_error i18n_string
+            postfix_expression_error unary_expression_error cast_expression_error
             multiplicative_expression_error additive_expression_error shift_expression_error
             relational_expression_error equality_expression_error and_expression_error
             exclusive_or_expression_error inclusive_or_expression_error logical_and_expression_error
             logical_or_expression_error conditional_expression_error assignment_expression_error
-            simple_primary_expression 
-            simple_postfix_expression simple_postfix_expression_error
+            simple_primary_expression constant
             common_unary_expression common_unary_expression_error
-            simple_unary_expression simple_unary_expression_error
             database_open dbfield dbindex dbtable
-            
+
+//simple_unary_expression simple_unary_expression_error
+// simple_postfix_expression simple_postfix_expression_error
+
 %type <list> argument_expression_list expression expression_anon_inst expression_anon_inst_error enumerator_list type_qualifier_list
              struct_declarator_list struct_declaration_list
              declaration_specifiers identifier_list identifier_list_error initializer_list init_declarator_list
@@ -112,7 +120,7 @@ default:
              new_specifiers renew_specifiers asm_field_list
              property_watch_list watch_property_list
              dbindex_item_list dbfield_definition_list
-             template_arguments_list template_parameters_list
+             template_arguments_list template_parameters_list attribs_list
 
 %type <asmField> asm_field
 %type <specifier> storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier class_specifier class_specifier_error
@@ -124,12 +132,13 @@ default:
 %type <declarator> declarator direct_declarator direct_abstract_declarator abstract_declarator
                    direct_abstract_declarator_noarray abstract_declarator_noarray
                    struct_declarator direct_declarator_function direct_declarator_function_start declarator_function_error direct_declarator_function_error declarator_function direct_declarator_nofunction
-                   declarator_nofunction
+                   direct_declarator_function_type_ok declarator_nofunction_type_ok direct_declarator_nofunction_type_ok declarator_function_type_ok direct_declarator_function_error_type_ok
+                   direct_declarator_function_start_type_ok direct_declarator_type_ok declarator_type_ok declarator_function_error_type_ok
 %type <pointer> pointer
 %type <initializer> initializer initializer_error initializer_condition initializer_condition_error
 %type <initDeclarator> init_declarator init_declarator_error
 %type <typeName> type_name guess_type_name parameter_declaration parameter_declaration_error
-%type <stmt> statement labeled_statement labeled_statement_error compound_statement compound_statement_error expression_statement 
+%type <stmt> statement labeled_statement labeled_statement_error compound_statement compound_statement_error expression_statement
              selection_statement selection_statement_error iteration_statement jump_statement jump_statement_error compound_inside compound_inside_error
              iteration_statement_error statement_error asm_statement
              stopwatching watch_definition firewatchers
@@ -141,13 +150,16 @@ default:
 %type <instance> instantiation_named instantiation_named_error instantiation_unnamed instantiation_unnamed_error guess_instantiation_named guess_instantiation_named_error external_guess_instantiation_named
                  instantiation_anon instantiation_anon_error
 %type <memberInit> data_member_initialization data_member_initialization_error default_property default_property_error
-%type <classFunction> class_function_definition class_function_definition_error class_function_definition_start 
+%type <classFunction> class_function_definition class_function_definition_error class_function_definition_start
                      class_function_definition_start_error virtual_class_function_definition_start virtual_class_function_definition_start_error
-                     constructor_function_definition_start destructor_function_definition_start 
-%type <classFunction> instance_class_function_definition instance_class_function_definition_error instance_class_function_definition_start instance_class_function_definition_start_error 
+                     constructor_function_definition_start destructor_function_definition_start
+%type <classFunction> instance_class_function_definition instance_class_function_definition_error instance_class_function_definition_start instance_class_function_definition_start_error
 %type <_class> class class_error class_head
 %type <classDef> struct_declaration struct_declaration_error
-%type <string> ext_decl string_literal ext_attrib base_strict_type_name
+%type <string> string_literal base_strict_type_name attribute_word
+%type <extDecl> ext_decl
+%type <attrib> attrib
+%type <attribute> attribute
 %type <prop> property property_start property_body class_property class_property_start class_property_body
 %type <propertyWatch> property_watch self_watch_definition
 
@@ -158,7 +170,7 @@ default:
 %type <dbtableEntry> dbindex_entry dbfield_entry
 %type <dbindexItem> dbindex_item
 %type <dbtableDef> dbtable_definition
-%type <context> compound_start
+%type <context> compound_start class_entry
 
 %token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
@@ -167,7 +179,7 @@ default:
 %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
 
 %token TYPEDEF EXTERN STATIC AUTO REGISTER
-%token CHAR SHORT INT UINT INT64 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
+%token CHAR SHORT INT UINT INT64 INT128 LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID VALIST
 %token STRUCT UNION ENUM ELLIPSIS
 
 %token CASE DEFAULT IF SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
@@ -175,15 +187,19 @@ default:
 %nonassoc IFX
 %nonassoc ELSE
 %token CLASS THISCLASS CLASS_NAME
-%token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL EXT_ATTRIB
+%token PROPERTY SETPROP GETPROP NEWOP RENEW DELETE EXT_DECL EXT_STORAGE IMPORT DEFINE VIRTUAL ATTRIB
 %token PUBLIC PRIVATE
 %token TYPED_OBJECT ANY_OBJECT _INCREF EXTENSION ASM TYPEOF
 %token WATCH STOPWATCHING FIREWATCHERS WATCHABLE CLASS_DESIGNER CLASS_NO_EXPANSION CLASS_FIXED ISPROPSET
 %token CLASS_DEFAULT_PROPERTY PROPERTY_CATEGORY CLASS_DATA CLASS_PROPERTY SUBCLASS NAMESPACE
 %token NEW0OP RENEW0 VAARG
 %token DBTABLE DBFIELD DBINDEX DATABASE_OPEN
+%token ALIGNOF ATTRIB_DEP __ATTRIB
+%token BOOL _BOOL _COMPLEX _IMAGINARY RESTRICT THREAD
+%token WIDE_STRING_LITERAL
+%token BUILTIN_OFFSETOF
 
-%destructor { FreeIdentifier($$); } identifier 
+%destructor { FreeIdentifier($$); } identifier
 %destructor { FreePointer($$); } pointer
 %destructor { FreeExpression($$); } primary_expression primary_expression_error postfix_expression unary_expression cast_expression
                                     multiplicative_expression additive_expression shift_expression
@@ -195,7 +211,7 @@ default:
                                     multiplicative_expression_error additive_expression_error shift_expression_error
                                     relational_expression_error equality_expression_error and_expression_error
                                     exclusive_or_expression_error inclusive_or_expression_error logical_and_expression_error
-                                    logical_or_expression_error conditional_expression_error assignment_expression_error
+                                    logical_or_expression_error conditional_expression_error assignment_expression_error i18n_string
 %destructor { FreeSpecifier($$); }  storage_class_specifier enum_specifier_compound enum_specifier_nocompound type_qualifier type_specifier class_specifier class_specifier_error
                                     struct_or_union_specifier_compound struct_or_union_specifier_nocompound ext_storage type strict_type guess_type enum_class strict_type_specifier struct_class
                                     struct_or_union_specifier_compound_error struct_class_error struct_decl
@@ -205,12 +221,13 @@ default:
 %destructor { FreeDeclarator($$); } declarator direct_declarator direct_abstract_declarator abstract_declarator
                                     direct_abstract_declarator_noarray abstract_declarator_noarray
                                     struct_declarator direct_declarator_function direct_declarator_function_start declarator_function_error direct_declarator_function_error declarator_function direct_declarator_nofunction
-                                    declarator_nofunction
+                                    direct_declarator_function_type_ok declarator_nofunction_type_ok direct_declarator_nofunction_type_ok declarator_function_type_ok direct_declarator_function_error_type_ok
+                                    direct_declarator_function_start_type_ok direct_declarator_type_ok declarator_type_ok declarator_function_error_type_ok
 
 %destructor { FreeInitializer($$); } initializer initializer_error initializer_condition initializer_condition_error
 %destructor { FreeInitDeclarator($$); } init_declarator init_declarator_error
 %destructor { FreeTypeName($$); } type_name guess_type_name parameter_declaration parameter_declaration_error
-%destructor { FreeStatement($$); }  statement labeled_statement labeled_statement_error compound_statement compound_statement_error expression_statement 
+%destructor { FreeStatement($$); }  statement labeled_statement labeled_statement_error compound_statement compound_statement_error expression_statement
                                     selection_statement selection_statement_error iteration_statement jump_statement jump_statement_error compound_inside compound_inside_error
                                     iteration_statement_error statement_error
 
@@ -222,34 +239,42 @@ default:
 
 %destructor { FreeMemberInit($$); } data_member_initialization data_member_initialization_error default_property default_property_error
 
-%destructor { FreeClassFunction($$); } class_function_definition class_function_definition_error class_function_definition_start 
+%destructor { FreeClassFunction($$); } class_function_definition class_function_definition_error class_function_definition_start
                                        class_function_definition_start_error virtual_class_function_definition_start virtual_class_function_definition_start_error
-                                       constructor_function_definition_start destructor_function_definition_start 
-                                       instance_class_function_definition instance_class_function_definition_error instance_class_function_definition_start instance_class_function_definition_start_error 
-%destructor { FreeClass($$); } class class_error 
+                                       constructor_function_definition_start destructor_function_definition_start
+                                       instance_class_function_definition instance_class_function_definition_error instance_class_function_definition_start instance_class_function_definition_start_error
+%destructor { Context ctx = curContext; PopContext(ctx); FreeContext(ctx); delete ctx; } class_entry
+%destructor { Context ctx = curContext; PopContext(ctx); FreeContext(ctx); delete ctx; } class_decl
+%destructor { FreeClass($$); } class class_error class_head
 %destructor { FreeClassDef($$); } struct_declaration struct_declaration_error
-%destructor { delete $$; } ext_decl string_literal
+%destructor { delete $$; } string_literal attribute_word base_strict_type_name
 %destructor { FreeProperty($$); } property
 
-%destructor { FreeList($$, FreeExpression); }  argument_expression_list expression expression_error argument_expression_list_error 
-%destructor { FreeList($$, FreeEnumerator); }  enumerator_list 
+%destructor { FreeList($$, FreeExpression); }  argument_expression_list expression expression_error argument_expression_list_error
+%destructor { FreeList($$, FreeEnumerator); }  enumerator_list
 %destructor { FreeList($$, FreeSpecifier); }   type_qualifier_list specifier_qualifier_list declaration_specifiers inheritance_specifiers _inheritance_specifiers external_guess_declaration_specifiers external_guess_declaration_specifiers_error
                                                guess_declaration_specifiers guess_specifier_qualifier_list
 %destructor { FreeList($$, FreeDeclarator); }  struct_declarator_list
-%destructor { FreeList($$, FreeDeclaration); } declaration_list declaration_list_error 
+%destructor { FreeList($$, FreeDeclaration); } declaration_list declaration_list_error
 %destructor { FreeList($$, FreeInitializer); } initializer_list
-%destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list init_declarator_list_error 
-%destructor { FreeList($$, FreeTypeName); } parameter_list parameter_list_error parameter_type_list parameter_type_list_error identifier_list identifier_list_error 
+%destructor { FreeList($$, FreeInitDeclarator); } init_declarator_list init_declarator_list_error
+%destructor { FreeList($$, FreeTypeName); } parameter_list parameter_list_error parameter_type_list parameter_type_list_error identifier_list identifier_list_error
 %destructor { FreeList($$, FreeStatement); } statement_list statement_list_error
 %destructor { if($$ != ast) FreeList($$, FreeExternal); } translation_unit translation_unit_error
 %destructor { FreeList($$, FreeClassDef); } struct_declaration_list struct_declaration_list_error
 %destructor { FreeList($$, FreeMemberInit); } default_property_list default_property_list_error data_member_initialization_list data_member_initialization_list_coloned data_member_initialization_list_error
-%destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned members_initialization_list_error  
+%destructor { FreeList($$, FreeMembersInit); } members_initialization_list members_initialization_list_coloned members_initialization_list_error
 %destructor { PopContext($$); FreeContext($$); delete $$; } compound_start
 %destructor { FreeTemplateParameter($$); } template_parameter template_type_parameter template_identifier_parameter template_expression_parameter
 %destructor { FreeTemplateArgument($$); } template_argument template_type_argument template_identifier_argument template_expression_argument
 %destructor { FreeTemplateDataType($$); } template_datatype
+%destructor { FreeList($$, FreeTemplateParameter); } template_parameters_list
+%destructor { FreeList($$, FreeTemplateArgument); } template_arguments_list
 %destructor { } declaration_mode
+%destructor { FreeAttrib($$); } attrib
+%destructor { FreeExtDecl($$); } ext_decl
+%destructor { FreeAttribute($$); } attribute
+%destructor { FreeList($$, FreeAttribute); }  attribs_list
 
 %start thefile
 
@@ -258,57 +283,39 @@ default:
 guess_type:
    identifier '*'
    {
-      // if($1._class && !$1._class.name)
-      if($1._class)
-      {
-         char name[1024];
-         strcpy(name,  $1._class.name ? $1._class.name : "");
-         strcat(name, "::");
-         strcat(name, $1.string);
-         _DeclClass(0, name);
-      }
-      else
-         _DeclClass(0, $1.string);
+      $$ = null;
+      _DeclClass($1._class, $1.string);
 
       FreeIdentifier($1);
 
-      fileInput.Seek(@1.start.pos, start); 
+      fileInput.Seek(@1.start.pos, start);
       resetScannerPos(&@1.start);
       yyclearin;
 
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
       goto yysetstate;
    }
    | identifier '<'
    {
+      $$ = null;
    #ifdef PRECOMPILER
-      // if($1._class && !$1._class.name)
-      if($1._class)
-      {
-         char name[1024];
-         strcpy(name,  $1._class.name ? $1._class.name : "");
-         strcat(name, "::");
-         strcat(name, $1.string);
-         _DeclClass(0, name);
-      }
-      else
-         _DeclClass(0, $1.string);
+      _DeclClass($1._class, $1.string);
 
       FreeIdentifier($1);
 
-      fileInput.Seek(@1.start.pos, start); 
+      fileInput.Seek(@1.start.pos, start);
       resetScannerPos(&@1.start);
       yyclearin;
 
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
       goto yysetstate;
@@ -316,25 +323,15 @@ guess_type:
    }
 /*   | identifier '*' '<' template_arguments_list '>'
    {
-      //if($1._class && !$1._class.name)
-      if($1._class)
-      {
-         char name[1024];
-         strcpy(name,  $1._class.name ? $1._class.name : "");
-         strcat(name, "::");
-         strcat(name, $1.string);
-         _DeclClass(0, name);
-      }
-      else
-         _DeclClass(0, $1.string);
-      fileInput.Seek(@1.start.pos, start); 
+      _DeclClass($1._class, $1.string);
+      fileInput.Seek(@1.start.pos, start);
       resetScannerPos(&@1.start);
       yyclearin;
 
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
       goto yysetstate;
@@ -346,60 +343,50 @@ type:
    | identifier identifier
    {
    #ifdef PRECOMPILER
-      // if($1._class && !$1._class.name)
-      if($1._class)
+      if(!$1.string[0])
       {
-         char name[1024];
-         strcpy(name,  $1._class.name ? $1._class.name : "");
-         strcat(name, "::");
-         strcat(name, $1.string);
-         _DeclClass(0, name);
+         $$ = MkSpecifierName($1.string);
+         FreeIdentifier($1);
+         FreeIdentifier($2);
       }
       else
-         _DeclClass(0, $1.string);
-      FreeIdentifier($1);
-      FreeIdentifier($2);
+      {
+         _DeclClass($1._class, $1.string);
 
-      fileInput.Seek(@1.start.pos, start); 
-      resetScannerPos(&@1.start);
-      yyclearin;
+         FreeIdentifier($1);
+         FreeIdentifier($2);
 
-      YYPOPSTACK;
-      yystate = *yyssp;
-      YY_STACK_PRINT (yyss, yyssp);
-      YYPOPSTACK;
-      yystate = *yyssp;
-      YY_STACK_PRINT (yyss, yyssp);
-      goto yysetstate;
+         fileInput.Seek(@1.start.pos, start);
+         resetScannerPos(&@1.start);
+         yyclearin;
+
+         YYPOPSTACK(1);
+         yystate = *yyssp;
+         YY_STACK_PRINT (yyss, yyssp);
+         YYPOPSTACK(1);
+         yystate = *yyssp;
+         YY_STACK_PRINT (yyss, yyssp);
+         goto yysetstate;
    #else
-      Location tmpLoc = yylloc; $$ = $2; yylloc = @1; 
-      Compiler_Error("Not a type: %s\n", $1.string);      
-      yylloc = tmpLoc; $2.badID = $1;
+         Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
+         Compiler_Error($"Not a type: %s\n", $1.string);
+         yylloc = tmpLoc; $2.badID = $1;
    #endif
+      }
    }
    /*
    | identifier '<'
    {
    #ifdef PRECOMPILER
-      //if($1._class && !$1._class.name)
-      if($1._class)
-      {
-         char name[1024];
-         strcpy(name,  $1._class.name ? $1._class.name : "");
-         strcat(name, "::");
-         strcat(name, $1.string);
-         _DeclClass(0, name);
-      }
-      else
-         _DeclClass(0, $1.string);
-      fileInput.Seek(@1.start.pos, start); 
+      _DeclClass($1._class, $1.string);
+      fileInput.Seek(@1.start.pos, start);
       resetScannerPos(&@1.start);
       yyclearin;
 
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
       goto yysetstate;
@@ -409,34 +396,24 @@ type:
    | identifier identifier '<' template_arguments_list '>'
    {
    #ifdef PRECOMPILER
-      // if($1._class && !$1._class.name)
-      if($1._class)
-      {
-         char name[1024];
-         strcpy(name,  $1._class.name ? $1._class.name : "");
-         strcat(name, "::");
-         strcat(name, $1.string);
-         _DeclClass(0, name);
-      }
-      else
-         _DeclClass(0, $1.string);
+      _DeclClass($1._class, $1.string);
       FreeIdentifier($1);
       FreeIdentifier($2);
 
-      fileInput.Seek(@1.start.pos, start); 
+      fileInput.Seek(@1.start.pos, start);
       resetScannerPos(&@1.start);
       yyclearin;
 
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
-      YYPOPSTACK;
+      YYPOPSTACK(1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
       goto yysetstate;
    #else
-      Location tmpLoc = yylloc; $$ = $2; yylloc = @1; 
-      Compiler_Error("Not a type: %s\n", $1.string);      
+      Location tmpLoc = yylloc; $$ = $2; yylloc = @1;
+      Compiler_Error($"Not a type: %s\n", $1.string);
       yylloc = tmpLoc; $2.badID = $1;
    #endif
    }*/
@@ -452,46 +429,36 @@ base_strict_type_name:
 strict_type:
      base_strict_type
     | base_strict_type '<' template_arguments_list '>' { $$ = $1; SetClassTemplateArgs($$, $3); $$.loc = @$; }
-    | base_strict_type '<' template_arguments_list RIGHT_OP 
+    | base_strict_type '<' template_arguments_list RIGHT_OP
     {
       $$ = $1;
       SetClassTemplateArgs($$, $3);
       $$.loc = @$;
 
       @4.end.pos--;
-      fileInput.Seek(@4.end.pos, start); 
+      fileInput.Seek(@4.end.pos, start);
       resetScannerPos(&@4.end);
       yyclearin;
     }
-    
+
 /*    | identifier '<' template_arguments_list '>' */
       /*| identifier '<' error
-      { 
-         // if($1._class && !$1._class.name)
-         if($1._class)
-         {
-            char name[1024];
-            strcpy(name,  $1._class.name ? $1._class.name : "");
-            strcat(name, "::");
-            strcat(name, $1.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $1.string);
+      {
+         _DeclClass($1._class, $1.string);
 
          yyerrok;
-         
-         fileInput.Seek(@1.start.pos, start); 
+
+         fileInput.Seek(@1.start.pos, start);
          resetScannerPos(&@1.start);
          yyclearin;
 
-         YYPOPSTACK;
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
-         YYPOPSTACK;
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
-         YYPOPSTACK;
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
          goto yysetstate;
@@ -501,41 +468,41 @@ strict_type:
    ;
 
 class_function_definition_start:
-   guess_declaration_specifiers declarator_function
-      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; $$.id = ++globalContext.nextID; }
+   guess_declaration_specifiers declarator_function_type_ok
+      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
    | declarator_function
-      { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; $$.id = ++globalContext.nextID; }
+      { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
    ;
 
 constructor_function_definition_start:
    guess_declaration_specifiers '(' ')'
-      { $$ = MkClassFunction(null, null, null, null); $$.isConstructor = true; $$.loc = @$; $$.id = ++globalContext.nextID; FreeList($1, FreeSpecifier); }
+      { $$ = MkClassFunction($1, null, null, null); $$.isConstructor = true; $$.loc = @$; }
    ;
 
 destructor_function_definition_start:
    '~' guess_declaration_specifiers '(' ')'
-      { $$ = MkClassFunction(null, null, null, null); $$.isDestructor = true; $$.loc = @$; $$.id = ++globalContext.nextID; FreeList($2, FreeSpecifier) }
+      { $$ = MkClassFunction($2, null, null, null); $$.isDestructor = true; $$.loc = @$; }
    ;
 
 virtual_class_function_definition_start:
-     VIRTUAL guess_declaration_specifiers declarator_function
-      { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; $$.id = ++globalContext.nextID; }
+     VIRTUAL guess_declaration_specifiers declarator_function_type_ok
+      { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
    | VIRTUAL declarator_function
-      { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; $$.id = ++globalContext.nextID; }
+      { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
       ;
 
 class_function_definition_start_error:
-     guess_declaration_specifiers declarator_function_error
-      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; $$.id = ++globalContext.nextID; }
+     guess_declaration_specifiers declarator_function_error_type_ok
+      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
    | declarator_function_error
-      { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; $$.id = ++globalContext.nextID; }
+      { $$ = MkClassFunction(null, null, $1, null); $$.loc = @$; }
    ;
 
 virtual_class_function_definition_start_error:
-     VIRTUAL guess_declaration_specifiers declarator_function_error
-      { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; $$.id = ++globalContext.nextID; }
+     VIRTUAL guess_declaration_specifiers declarator_function_error_type_ok
+      { $$ = MkClassFunction($2, null, $3, null); $$.isVirtual = true; $$.loc = @$; }
    | VIRTUAL declarator_function_error
-      { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; $$.id = ++globalContext.nextID; }
+      { $$ = MkClassFunction(null, null, $2, null); $$.isVirtual = true; $$.loc = @$; }
       ;
 
 class_function_definition:
@@ -550,9 +517,21 @@ class_function_definition:
        | destructor_function_definition_start compound_statement
       { ProcessClassFunctionBody($1, $2); $$.loc = @$; }
 
-   // TESTING TIHS
+   // TESTING THIS
    | class_function_definition_start ';'
       { ProcessClassFunctionBody($1, null); $$.loc = @$; }
+
+   // Added this to fix attrib not working after function pointer declarations
+   | class_function_definition_start attrib ';'
+      {
+         if($1.declarator)
+         {
+            $1.declarator = MkStructDeclarator($1.declarator, null);
+            $1.declarator.structDecl.attrib = $2;
+         }
+         ProcessClassFunctionBody($1, null);
+         $$.loc = @$;
+      }
        ;
 
 class_function_definition_error:
@@ -570,15 +549,15 @@ class_function_definition_error:
 
 // In Instances, return type is required to distinguish from calling the function
 instance_class_function_definition_start:
-   declaration_specifiers declarator_function
-      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; $$.id = ++globalContext.nextID; }
-   |  declaration_specifiers declarator_nofunction
-      { $$ = MkClassFunction($1, null, MkDeclaratorFunction($2, null), null); $$.loc = @$; $$.id = ++globalContext.nextID; }
-      ; 
+   declaration_specifiers declarator_function_type_ok
+      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
+   |  declaration_specifiers declarator_nofunction_type_ok
+      { $$ = MkClassFunction($1, null, MkDeclaratorFunction($2, null), null); $$.loc = @$; }
+      ;
 
 instance_class_function_definition_start_error:
-   declaration_specifiers declarator_function_error
-      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; $$.id = ++globalContext.nextID; }
+   declaration_specifiers declarator_function_error_type_ok
+      { $$ = MkClassFunction($1, null, $2, null); $$.loc = @$; }
       ;
 
 instance_class_function_definition:
@@ -602,95 +581,109 @@ data_member_initialization:
 
 data_member_initialization_error:
      postfix_expression '=' initializer_condition_error { $$ = MkMemberInitExp($1, $3); $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = @2.end;}
-   | postfix_expression '=' error 
-      { 
+   | postfix_expression '=' error
+      {
          $$ = MkMemberInitExp($1, MkInitializerAssignment(MkExpDummy()));
-         $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = $$.initializer.loc.end = @2.end; 
+         $$.loc = @$; $$.realLoc = @$; $$.initializer.loc.start = $$.initializer.loc.end = @2.end;
 
-         fileInput.Seek(@2.end.pos, start); 
+         fileInput.Seek(@2.end.pos, start);
          yyclearin;
          resetScannerPos(&@2.end);
          @$.start = @1.start;
          @$.end = @2.end;
-      } 
+      }
    | initializer_condition_error { $$ = MkMemberInit(null, $1); $$.loc = @$; $$.realLoc = @$;}
    ;
 
 data_member_initialization_list:
    data_member_initialization { $$ = MkList(); ListAdd($$, $1); }
    | data_member_initialization_list ',' data_member_initialization
-      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
+      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
    | data_member_initialization_list_error ',' data_member_initialization
-      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
+      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
    ;
 
 data_member_initialization_list_error:
    data_member_initialization_error { $$ = MkList(); ListAdd($$, $1); }
    | data_member_initialization_list ',' data_member_initialization_error
-      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
+      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
    | data_member_initialization_list_error ',' data_member_initialization_error
-      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
+      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
 
    | data_member_initialization_list ',' error
-      { ((MemberInit)$1->last).loc.end = @2.end; 
-         { 
-            Initializer dummy = MkInitializerAssignment(MkExpDummy()); 
-            MemberInit memberInit = MkMemberInit(null, dummy); 
-            memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @2.end; 
-            memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @2.end; 
-            ListAdd($1, memberInit); 
-          } 
+      { ((MemberInit)$1->last).loc.end = @2.end;
+         {
+            Initializer dummy = MkInitializerAssignment(MkExpDummy());
+            MemberInit memberInit = MkMemberInit(null, dummy);
+            memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @2.end;
+            memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @2.end;
+            ListAdd($1, memberInit);
+          }
+          $$ = $1;
        }
    |
    data_member_initialization_list_error ',' error
-      { ((MemberInit)$1->last).loc.end = @2.end; 
-         { 
-            Initializer dummy = MkInitializerAssignment(MkExpDummy()); 
-            MemberInit memberInit = MkMemberInit(null, dummy); 
-            memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @2.end; 
-            memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @2.end; 
-            ListAdd($1, memberInit); 
-          } 
+      { ((MemberInit)$1->last).loc.end = @2.end;
+         {
+            Initializer dummy = MkInitializerAssignment(MkExpDummy());
+            MemberInit memberInit = MkMemberInit(null, dummy);
+            memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @2.end;
+            memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @2.end;
+            ListAdd($1, memberInit);
+          }
+          $$ = $1;
        }
        |   ','
       {
          Initializer dummy = MkInitializerAssignment(MkExpDummy());
-         MemberInit memberInit = MkMemberInit(null, dummy); 
-         memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @1.start; 
-         memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @1.start; 
+         MemberInit memberInit = MkMemberInit(null, dummy);
+         memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @1.start;
+         memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @1.start;
 
          $$ = MkList();
-         ListAdd($$, memberInit); 
+         ListAdd($$, memberInit);
 
-         dummy = MkInitializerAssignment(MkExpDummy()); 
-         memberInit = MkMemberInit(null, dummy); 
-         memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @1.end; 
-         memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @1.end; 
-         ListAdd($$, memberInit); 
+         dummy = MkInitializerAssignment(MkExpDummy());
+         memberInit = MkMemberInit(null, dummy);
+         memberInit.realLoc.start = memberInit.loc.start = dummy.loc.start = @1.end;
+         memberInit.realLoc.end = memberInit.loc.end = dummy.loc.end = @1.end;
+         ListAdd($$, memberInit);
       }
    ;
 
 data_member_initialization_list_coloned:
    data_member_initialization_list ';'
-      { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; }
+      { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
    | data_member_initialization_list_error ';'
-      { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; }
+      { if($1->last) ((MemberInit)$1->last).loc.end = @2.end; $$ = $1; }
    ;
 
 members_initialization_list_coloned:
      data_member_initialization_list_coloned                                        { MembersInit members = MkMembersInitList($1); $$ = MkList(); ListAdd($$, members); members.loc = @1; }
    | instance_class_function_definition                                             { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
-   | members_initialization_list_error data_member_initialization_list_coloned      { MembersInit members = MkMembersInitList($2); ListAdd($$, members);  members.loc = @2;  }
-   | members_initialization_list_error    instance_class_function_definition        { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; }
-   | members_initialization_list_coloned  data_member_initialization_list_coloned   { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2;  }
-   | members_initialization_list_coloned  instance_class_function_definition        { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; }
-   | ';'                                                                            { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1;  }
+   | members_initialization_list_error data_member_initialization_list_coloned      { MembersInit members = MkMembersInitList($2); ListAdd($$, members);  members.loc = @2; $$ = $1; }
+   | members_initialization_list_error    instance_class_function_definition        { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
+   | members_initialization_list_coloned  data_member_initialization_list_coloned   { MembersInit members = MkMembersInitList($2); ListAdd($$, members); members.loc = @2; $$ = $1; }
+   | members_initialization_list_coloned  instance_class_function_definition        { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
    | members_initialization_list_error ';'
-   | members_initialization_list_coloned ';'       { MembersInit members = MkMembersInitList(MkList()); ListAdd($$, members); members.loc = @2;  }
+   | members_initialization_list_coloned ';'
+   {
+      MembersInit members = (MembersInit)$$->last;
+      if(members.type == dataMembersInit)
+         members.loc.end = @$.end;
+      else
+      {
+         MembersInit members = MkMembersInitList(MkList());
+         ListAdd($$, members);
+         members.loc = @2;
+      }
+      $$ = $1;
+   }
+   | ';'                                                                            { MembersInit members = MkMembersInitList(MkList()); $$ = MkList(); ListAdd($$, members); members.loc = @1;  }
    ;
 
 members_initialization_list:
-     members_initialization_list_coloned 
+     members_initialization_list_coloned
    | data_member_initialization_list                                       { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
    | members_initialization_list_coloned data_member_initialization_list   { ListAdd($1, MkMembersInitList($2));   ((MembersInit)$$->last).loc = @2; }
    | members_initialization_list_error data_member_initialization_list     { ListAdd($1, MkMembersInitList($2));   ((MembersInit)$$->last).loc = @2; }
@@ -698,19 +691,19 @@ members_initialization_list:
 
 members_initialization_list_error:
      instance_class_function_definition_error                                 { $$ = MkList(); ListAdd($$, MkMembersInitMethod($1)); ((MembersInit)$$->last).loc = @1; }
-     | members_initialization_list instance_class_function_definition_error  { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; }
-     | members_initialization_list_error instance_class_function_definition_error  { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; }
-     | members_initialization_list_coloned instance_class_function_definition_error  { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; }
-     | members_initialization_list_coloned data_member_initialization_list_error  { ListAdd($$, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; }
+     | members_initialization_list instance_class_function_definition_error  { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
+     | members_initialization_list_error instance_class_function_definition_error  { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
+     | members_initialization_list_coloned instance_class_function_definition_error  { ListAdd($$, MkMembersInitMethod($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
+     | members_initialization_list_coloned data_member_initialization_list_error  { ListAdd($$, MkMembersInitList($2)); ((MembersInit)$$->last).loc = @2; $$ = $1; }
      | data_member_initialization_list_error                                  { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @1; }
      | data_member_initialization_list error                                  { $$ = MkList(); ListAdd($$, MkMembersInitList($1)); ((MembersInit)$$->last).loc = @2; }
    ;
 
 instantiation_named:
      instantiation_named_error '}'
-      { $$.loc = @$; $$.insideLoc.end = @2.start; }
+      { $$.loc = @$; $$.insideLoc.end = @2.start; $$ = $1; }
     | instantiation_named_error error '}'
-      { $$.loc = @$; $$.insideLoc.end = @2.start; }
+      { $$.loc = @$; $$.insideLoc.end = @2.start; $$ = $1; }
    ;
 
 instantiation_named_error:
@@ -718,9 +711,9 @@ instantiation_named_error:
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   declaration_specifiers identifier '{' members_initialization_list error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   declaration_specifiers identifier '{' members_initialization_list 
+|   declaration_specifiers identifier '{' members_initialization_list
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   declaration_specifiers identifier '{' 
+|   declaration_specifiers identifier '{'
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   declaration_specifiers identifier '{' error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -741,9 +734,9 @@ instantiation_named_error:
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   declaration_specifiers identifier '{' members_initialization_list error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   declaration_specifiers identifier '{' members_initialization_list 
+|   declaration_specifiers identifier '{' members_initialization_list
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   declaration_specifiers identifier '{' 
+|   declaration_specifiers identifier '{'
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   declaration_specifiers identifier '{' error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -763,9 +756,9 @@ guess_instantiation_named_error:
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   guess_declaration_specifiers identifier '{' members_initialization_list error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   guess_declaration_specifiers identifier '{' members_initialization_list 
+|   guess_declaration_specifiers identifier '{' members_initialization_list
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   guess_declaration_specifiers identifier '{' 
+|   guess_declaration_specifiers identifier '{'
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   guess_declaration_specifiers identifier '{' error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -786,9 +779,9 @@ guess_instantiation_named_error:
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   guess_declaration_specifiers identifier '{' members_initialization_list error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4); $$.exp.loc = @2; $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   guess_declaration_specifiers identifier '{' members_initialization_list 
+|   guess_declaration_specifiers identifier '{' members_initialization_list
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), $4);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @4.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|   guess_declaration_specifiers identifier '{' 
+|   guess_declaration_specifiers identifier '{'
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |   guess_declaration_specifiers identifier '{' error
       { $$ = MkInstantiationNamed($1, MkExpIdentifier($2), null);$$.exp.loc = @2;  $$.loc = @$; $$.nameLoc = @2; $$.insideLoc.start = @3.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -806,21 +799,21 @@ external_guess_instantiation_named:
 
 instantiation_unnamed:
      instantiation_unnamed_error '}'
-      { $$.loc = @$; $$.insideLoc.end = @2.start; }
+      { $$.loc = @$; $$.insideLoc.end = @2.start; $$ = $1; }
     | instantiation_unnamed_error error '}'
-      { $$.loc = @$; $$.insideLoc.end = @2.start; }
+      { $$.loc = @$; $$.insideLoc.end = @2.start; $$ = $1; }
    ;
 
 instantiation_unnamed_error:
      strict_type '{' members_initialization_list
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
 |    identifier '{' members_initialization_list
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end; FreeIdentifier($1); }
 
 |    strict_type '{' members_initialization_list_error
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|    strict_type '{' 
+|    strict_type '{'
       { $$ = MkInstantiation($1, null, null);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
 |    strict_type '{' members_initialization_list error
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -830,47 +823,47 @@ instantiation_unnamed_error:
    // Undeclared class
 
 |    identifier '{' members_initialization_list_error
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
-|    identifier '{' 
-      { Location tmpLoc = yylloc; yylloc = @1; 
+|    identifier '{'
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, null);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
 |    identifier '{' members_initialization_list error
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
 |    identifier '{' error
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, null);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @2.end; $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
    ;
 
 /*
 instantiation_unnamed:
-     strict_type '{' members_initialization_list '}' 
+     strict_type '{' members_initialization_list '}'
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
-   | strict_type '{' members_initialization_list error '}' 
+   | strict_type '{' members_initialization_list error '}'
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @5.start; }
-   | strict_type '{' members_initialization_list_error '}' 
+   | strict_type '{' members_initialization_list_error '}'
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; }
-   | strict_type '{' '}' 
+   | strict_type '{' '}'
       { $$ = MkInstantiation($1, null, MkList());  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start;}
    | strict_type '{' error '}'
       { $$ = MkInstantiation($1, null, MkList());  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start;}
 
    // Undeclared class
-   | identifier '{' members_initialization_list '}' 
-      { Location tmpLoc = yylloc; yylloc = @1; 
+   | identifier '{' members_initialization_list '}'
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
-   | identifier '{' members_initialization_list_error '}' 
-      { Location tmpLoc = yylloc; yylloc = @1; 
+   | identifier '{' members_initialization_list_error '}'
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
-   | identifier '{' members_initialization_list error '}' 
-      { yyloc = @1; 
+   | identifier '{' members_initialization_list error '}'
+      { yyloc = @1;
       $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @5.start; FreeIdentifier($1); }
-   | identifier '{' '}' 
-      { Location tmpLoc = yylloc; yylloc = @1; 
+   | identifier '{' '}'
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList());  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.start; FreeIdentifier($1);}
    | identifier '{' error '}'
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, MkList());  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @4.start; FreeIdentifier($1); }
    ;
 
@@ -878,7 +871,7 @@ instantiation_unnamed:
 instantiation_unnamed_error:
      strict_type '{' members_initialization_list_error
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|    strict_type '{' 
+|    strict_type '{'
       { $$ = MkInstantiation($1, null, null);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
 |    strict_type '{' members_initialization_list error
       { $$ = MkInstantiation($1, null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -888,16 +881,16 @@ instantiation_unnamed_error:
    // Undeclared class
 
 |    identifier '{' members_initialization_list_error
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
-|    identifier '{' 
-      { Location tmpLoc = yylloc; yylloc = @1; 
+|    identifier '{'
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, null);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
 |    identifier '{' members_initialization_list error
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, $3);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @3.end;  $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
 |    identifier '{' error
-      { Location tmpLoc = yylloc; yylloc = @1; 
+      { Location tmpLoc = yylloc; yylloc = @1;
       yylloc = tmpLoc;  $$ = MkInstantiation(MkSpecifierName($1.string), null, null);  $$.loc = @$; $$.insideLoc.start = @2.end; $$.insideLoc.end = @2.end; $$.loc.end.charPos++; $$.loc.end.pos++; FreeIdentifier($1); }
    ;
 */
@@ -916,7 +909,7 @@ instantiation_anon_error:
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
 |    '{' error
       { $$ = MkInstantiation(null, null, null);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @1.end; $$.loc.end.charPos++; $$.loc.end.pos++;  }
-|    '{' 
+|    '{'
       { $$ = MkInstantiation(null, null, null);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @1.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
 |    '{' members_initialization_list
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.end; $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -924,13 +917,13 @@ instantiation_anon_error:
 
 /*
 instantiation_anon:
-     '{' members_initialization_list '}' 
+     '{' members_initialization_list '}'
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
-   | '{' members_initialization_list error '}' 
+   | '{' members_initialization_list error '}'
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @4.start; }
-   | '{' members_initialization_list_error '}' 
+   | '{' members_initialization_list_error '}'
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start; }
-   | '{' '}' 
+   | '{' '}'
       { $$ = MkInstantiation(null, null, MkList());  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.start;}
    | '{' error '}'
       { $$ = MkInstantiation(null, null, MkList());  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @3.start;}
@@ -939,7 +932,7 @@ instantiation_anon:
 instantiation_anon_error:
      '{' members_initialization_list_error
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
-|    '{' 
+|    '{'
       { $$ = MkInstantiation(null, null, null);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @1.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
 |    '{' members_initialization_list error
       { $$ = MkInstantiation(null, null, $2);  $$.loc = @$; $$.insideLoc.start = @1.end; $$.insideLoc.end = @2.end;  $$.loc.end.charPos++; $$.loc.end.pos++; }
@@ -960,20 +953,20 @@ default_property_error:
 
 default_property_list:
      default_property        { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
-   | default_property_list ',' default_property      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
-   | default_property_list_error ',' default_property      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
+   | default_property_list ',' default_property      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
+   | default_property_list_error ',' default_property      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
    ;
 
 default_property_list_error:
       default_property_error      { $$ = MkList(); ListAdd($$, $1); ((MemberInit)$$->last).loc = @$; }
-   | default_property_list ',' default_property_error      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); }
-   | default_property_list_error ',' default_property_error      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); 
-   | default_property_list error   
+   | default_property_list ',' default_property_error      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
+   | default_property_list_error ',' default_property_error      { ((MemberInit)$1->last).loc.end = @3.start; ListAdd($1, $3); $$ = $1; }
+   | default_property_list error
    ;
 
 property_start:
      PROPERTY property_specifiers identifier '{'
-      { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; } 
+      { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
 
    | PROPERTY property_specifiers abstract_declarator identifier '{'
       { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
@@ -992,23 +985,23 @@ property_body:
      property_start
    | property_body SETPROP compound_statement
       { $1.setStmt = $3; }
-   | property_body GETPROP compound_statement  
+   | property_body GETPROP compound_statement
       { $1.getStmt = $3; }
-   | property_body ISPROPSET compound_statement        
+   | property_body ISPROPSET compound_statement
       { $1.issetStmt = $3; }
    | property_body WATCHABLE
       { $1.isWatchable = true; }
-   | property_body PROPERTY_CATEGORY string_literal
+   | property_body PROPERTY_CATEGORY i18n_string
       { $1.category = $3; }
        ;
 
 property:
-   property_body '}' { $1.loc.end = @2.end; }
+   property_body '}' { $1.loc.end = @2.end; $$ = $1; }
    ;
 
 class_property_start:
      CLASS_PROPERTY property_specifiers identifier '{'
-      { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; } 
+      { $$ = MkProperty($2, null, $3, null, null); $$.loc = @$; }
 
    | CLASS_PROPERTY property_specifiers abstract_declarator identifier '{'
       { $$ = MkProperty($2, $3, $4, null, null); $$.loc = @$; }
@@ -1027,7 +1020,7 @@ class_property_body:
      class_property_start
    | class_property_body SETPROP compound_statement
       { $1.setStmt = $3; }
-   | class_property_body GETPROP compound_statement    
+   | class_property_body GETPROP compound_statement
       { $1.getStmt = $3; }
        ;
 
@@ -1091,30 +1084,16 @@ firewatchers:
        ;
 
 struct_declaration:
-         guess_declaration_specifiers struct_declarator_list ';'         { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-   | guess_declaration_specifiers ';'                                { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-   | instantiation_unnamed ';'                                       { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-   | guess_instantiation_named ';'                                   { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+     struct_declaration_error ';' { $$ = $1; $$.loc.end = @2.end; }
+   | default_property_list ';'     { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
    | class_function_definition                                       { $$ = MkClassDefFunction($1); $$.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-   | property                       { $$ = MkClassDefProperty($1); $$.loc = @$; globalContext.nextID++; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-
-       | member_access guess_declaration_specifiers struct_declarator_list ';'         { $$ = MkClassDefDeclaration(MkStructDeclaration($2, $3, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = $1; }
-   | member_access guess_declaration_specifiers ';'                                { $$ = MkClassDefDeclaration(MkStructDeclaration($2, null, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = $1; }
-   | member_access instantiation_unnamed ';'                                       { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = $1; }
-   | member_access guess_instantiation_named ';'                                   { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = $1; }
+   | property                       { $$ = MkClassDefProperty($1); $$.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
    | member_access class_function_definition                                       { $$ = MkClassDefFunction($2); $$.loc = @$; $$.memberAccess = $1; }
-   | member_access property                       { $$ = MkClassDefProperty($2); $$.loc = @$; globalContext.nextID++; $$.memberAccess = $1; }
-
-   | default_property_list ';'      { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @2.start; $$.loc = @$; }
-   | CLASS_DATA guess_declaration_specifiers struct_declarator_list ';' { $$ = MkClassDefClassData(MkStructDeclaration($2, $3, null)); $$.decl.loc = @$; $$.loc = @$; }
-   | class_property                 { $$ = MkClassDefClassProperty($1); $$.loc = @$; globalContext.nextID++; }
-   | self_watch_definition ';'      { $$ = MkClassDefPropertyWatch($1); $$.loc = @$; globalContext.nextID++; }
+   | member_access property                       { $$ = MkClassDefProperty($2); $$.loc = @$; $$.memberAccess = $1; }
+   | class_property                 { $$ = MkClassDefClassProperty($1); $$.loc = @$; }
    | WATCHABLE { $$ = null; deleteWatchable = true; }
-   | CLASS_DESIGNER identifier ';' { $$ = MkClassDefDesigner($2.string); FreeIdentifier($2); }
-   | CLASS_DESIGNER strict_type ';' { $$ = MkClassDefDesigner($2.name); FreeSpecifier($2); }
    | CLASS_NO_EXPANSION             { $$ = MkClassDefNoExpansion(); }
    | CLASS_FIXED                    { $$ = MkClassDefFixed(); }
-   | CLASS_DEFAULT_PROPERTY identifier ';' { $$ = MkClassDefDesignerDefaultProperty($2); }
    | CLASS_PROPERTY '(' identifier ')' '=' initializer_condition ';' { $$ = MkClassDefClassPropertyValue($3, $6); $$.loc = @$; }
 
    | ';' { $$ = null; }
@@ -1125,42 +1104,67 @@ struct_declaration:
 
 struct_declaration_error:
      class_function_definition_error { $$ = MkClassDefFunction($1); $$.loc = $1.loc;  $$.loc.end.charPos++; $$.loc.end.pos++; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+
+// Moved all these in here without the ';'
+   | guess_declaration_specifiers                                { $$ = MkClassDefDeclaration(MkStructDeclaration($1, null, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+       | guess_declaration_specifiers struct_declarator_list          { $$ = MkClassDefDeclaration(MkStructDeclaration($1, $2, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+       | member_access guess_declaration_specifiers struct_declarator_list         { $$ = MkClassDefDeclaration(MkStructDeclaration($2, $3, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = $1; }
+   | member_access guess_declaration_specifiers                                { $$ = MkClassDefDeclaration(MkStructDeclaration($2, null, null)); $$.decl.loc = @$; $$.loc = @$; $$.memberAccess = $1; }
+   | member_access instantiation_unnamed                                       { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = $1; }
+   | member_access guess_instantiation_named                                   { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = $1; }
+   | CLASS_DATA guess_declaration_specifiers struct_declarator_list { $$ = MkClassDefClassData(MkStructDeclaration($2, $3, null)); $$.decl.loc = @$; $$.loc = @$; }
+   | self_watch_definition      { $$ = MkClassDefPropertyWatch($1); $$.loc = @$; }
+   | CLASS_DESIGNER identifier { $$ = MkClassDefDesigner($2.string); FreeIdentifier($2); }
+   | CLASS_DESIGNER strict_type { $$ = MkClassDefDesigner($2.name); FreeSpecifier($2); }
+   | CLASS_DEFAULT_PROPERTY identifier { $$ = MkClassDefDesignerDefaultProperty($2); }
+   | instantiation_unnamed                                       { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+   | guess_instantiation_named                                   { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = @$; $$.decl.loc = @$; $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+   | default_property_list     { $$ = MkClassDefDefaultProperty($1); if($1->last) ((MemberInit)$1->last).loc.end = @1.end; $$.loc = @$; }
+
    | guess_instantiation_named_error error { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = $1.loc; $$.decl.loc = $$.loc;  $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
    | instantiation_unnamed_error error { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = $1.loc; $$.decl.loc = $$.loc;  $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-   | guess_instantiation_named { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = $1.loc; $$.decl.loc = $$.loc;  $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
-   | instantiation_unnamed { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = $1.loc; $$.decl.loc = $$.loc;  $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+//   | guess_instantiation_named { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = $1.loc; $$.decl.loc = $$.loc;  $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
+//   | instantiation_unnamed { $$ = MkClassDefDeclaration(MkDeclarationClassInst($1)); $$.loc = $1.loc; $$.decl.loc = $$.loc;  $$.memberAccess = memberAccessStack[defaultMemberAccess]; }
 
    | member_access class_function_definition_error { $$ = MkClassDefFunction($2); $$.loc = @$;  $$.loc.end.charPos++; $$.loc.end.pos++; $$.memberAccess = $1; }
    | member_access guess_instantiation_named_error error { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = $$.loc; $$.memberAccess = $1; }
    | member_access instantiation_unnamed_error error { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = $$.loc; $$.memberAccess = $1; }
-   | member_access guess_instantiation_named { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = $$.loc; $$.memberAccess = $1; }
-   | member_access instantiation_unnamed { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = $$.loc; $$.memberAccess = $1; }
+//   | member_access guess_instantiation_named { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = $$.loc; $$.memberAccess = $1; }
+//   | member_access instantiation_unnamed { $$ = MkClassDefDeclaration(MkDeclarationClassInst($2)); $$.loc = @$; $$.decl.loc = $$.loc; $$.memberAccess = $1; }
 
    | default_property_list_error { $$ = MkClassDefDefaultProperty($1); $$.loc = @$;  $$.loc.end.charPos++; $$.loc.end.pos++; }
    ;
 
 struct_declaration_list:
          struct_declaration { $$ = MkList(); ListAdd($$, $1); }
-       | struct_declaration_list struct_declaration   { ListAdd($1, $2); }
-   | struct_declaration_list_error struct_declaration   { ListAdd($1, $2); }
+       | struct_declaration_list struct_declaration   { $$ = $1; ListAdd($1, $2); }
+   | struct_declaration_list_error struct_declaration   { $$ = $1; ListAdd($1, $2); }
        ;
 
 struct_declaration_list_error:
-     struct_declaration_error { $$ = MkList(); ListAdd($$, $1); }
+     struct_declaration_error { yyerror(); $$ = MkList(); ListAdd($$, $1); }
    | struct_declaration_list error
    | struct_declaration_list_error error
-   | struct_declaration_list struct_declaration_error { ListAdd($$, $2); }
-   | struct_declaration_list_error struct_declaration_error { ListAdd($$, $2); }
+   | struct_declaration_list struct_declaration_error { yyerror(); $$ = $1; ListAdd($$, $2); }
+   | struct_declaration_list_error struct_declaration_error { $$ = $1; ListAdd($$, $2); }
        ;
 
 template_datatype:
-     declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
-   | declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
-   | identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }
+     guess_declaration_specifiers { $$ = MkTemplateDatatype($1, null); }
+   | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateDatatype($1, $2); }
+//   | identifier { $$ = MkTemplateDatatype(MkListOne(MkSpecifierName($1.string)), null); FreeIdentifier($1); }
    ;
 
 template_type_argument:
-     template_datatype { $$ = MkTemplateTypeArgument($1); }
+//     template_datatype { $$ = MkTemplateTypeArgument($1); }
+
+//    Explicitly copied the rules here to handle:
+//      ast.ec:  Map<List<Location>> intlStrings { };
+//          vs
+//      LinkList.ec:   class LinkList<bool circ = false>
+
+     guess_declaration_specifiers { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, null)); }
+   | guess_declaration_specifiers abstract_declarator { $$ = MkTemplateTypeArgument(MkTemplateDatatype($1, $2)); }
    ;
 
 template_type_parameter:
@@ -1184,12 +1188,16 @@ template_identifier_parameter:
    ;
 
 template_expression_argument:
-     constant_expression { $$ = MkTemplateExpressionArgument($1); }
+     shift_expression /*constant_expression*/ { $$ = MkTemplateExpressionArgument($1); }
    ;
 
 template_expression_parameter:
+/*
      template_datatype identifier     { $$ = MkExpressionTemplateParameter($2, $1, null); }
    | template_datatype identifier '=' template_expression_argument    { $$ = MkExpressionTemplateParameter($2, $1, $4); }
+*/
+     guess_declaration_specifiers identifier '=' template_expression_argument    { $$ = MkExpressionTemplateParameter($2, MkTemplateDatatype($1, null), $4); }
+   | guess_declaration_specifiers abstract_declarator identifier '=' template_expression_argument    { $$ = MkExpressionTemplateParameter($3, MkTemplateDatatype($1, $2), $5); }
    ;
 
 template_parameter:
@@ -1200,7 +1208,7 @@ template_parameter:
 
 template_parameters_list:
      template_parameter                               { $$ = MkList(); ListAdd($$, $1); }
-   | template_parameters_list ',' template_parameter  { ListAdd($1, $3); }
+   | template_parameters_list ',' template_parameter  { $$ = $1; ListAdd($1, $3); }
    ;
 
 template_argument:
@@ -1210,9 +1218,9 @@ template_argument:
    | identifier '=' template_expression_argument   { $$ = $3; $$.name = $1; $$.loc = @$; }
    | identifier '=' template_identifier_argument   { $$ = $3; $$.name = $1; $$.loc = @$; }
    | identifier '=' template_type_argument         { $$ = $3; $$.name = $1; $$.loc = @$; }
-   | template_datatype '=' template_expression_argument 
+   /*| template_datatype '=' template_expression_argument
    {
-      $$ = $3; 
+      $$ = $3;
       if($1.specifiers && $1.specifiers->first)
       {
          Specifier spec = $1.specifiers->first;
@@ -1224,7 +1232,7 @@ template_argument:
    }
    | template_datatype '=' template_identifier_argument
    {
-      $$ = $3; 
+      $$ = $3;
       if($1.specifiers && $1.specifiers->first)
       {
          Specifier spec = $1.specifiers->first;
@@ -1236,7 +1244,7 @@ template_argument:
    }
    | template_datatype '=' template_type_argument
    {
-      $$ = $3; 
+      $$ = $3;
       if($1.specifiers && $1.specifiers->first)
       {
          Specifier spec = $1.specifiers->first;
@@ -1245,83 +1253,86 @@ template_argument:
       }
       FreeTemplateDataType($1);
       $$.loc = @$;
-   }
+   }*/
    ;
 
 template_arguments_list:
      template_argument                                { $$ = MkList(); ListAdd($$, $1); }
-   | template_arguments_list ',' template_argument    { ListAdd($1, $3); }
+   | template_arguments_list ',' template_argument    { $$ = $1; ListAdd($1, $3); }
    ;
 
 class_entry:
    CLASS
    {
-      PushContext();
+      if(curContext != globalContext)
+         PopContext(curContext);
+      $$ = PushContext();
    };
 
 class_decl:
-     class_entry identifier { $$ = DeclClassAddNameSpace(globalContext.nextID++, $2.string); FreeIdentifier($2); $$.nameLoc = @2; memberAccessStack[++defaultMemberAccess] = privateAccess; }
-   | class_entry base_strict_type 
-   { 
-      $$ = DeclClass(globalContext.nextID++, $2.name); 
-      $$.nameLoc = @2; 
-      FreeSpecifier($2); 
+     class_entry identifier { (void)$1; $$ = DeclClassAddNameSpace($2._class, $2.string); FreeIdentifier($2); $$.nameLoc = @2; memberAccessStack[++defaultMemberAccess] = privateAccess; }
+   | class_entry base_strict_type
+   {
+      (void)$1; $$ = DeclClass($2.nsSpec, $2.name);
+      $$.nameLoc = @2;
+      FreeSpecifier($2);
       ++defaultMemberAccess;
       memberAccessStack[defaultMemberAccess] = privateAccess;
    }
-   | identifier class_entry identifier { $$ = DeclClassAddNameSpace(globalContext.nextID++, $3.string); FreeIdentifier($1); FreeIdentifier($3); $$.nameLoc = @3; $$.isRemote = true; memberAccessStack[++defaultMemberAccess] = privateAccess; }
-   | identifier class_entry base_strict_type { $$ = DeclClass(globalContext.nextID++, $3.name); FreeIdentifier($1); $$.nameLoc = @3; $$.isRemote = true; FreeSpecifier($3); memberAccessStack[++defaultMemberAccess] = privateAccess; }
-
-   | class_entry identifier '<' template_parameters_list '>' { $$ = DeclClassAddNameSpace(globalContext.nextID++, $2.string); $$.templateParams = $4; FreeIdentifier($2); $$.nameLoc = @2; memberAccessStack[++defaultMemberAccess] = privateAccess; }
-   | class_entry base_strict_type '<' template_parameters_list '>' 
-   { 
-      $$ = DeclClass(globalContext.nextID++, $2.name);
-      $$.templateParams = $4; 
-      $$.nameLoc = @2; 
-      FreeSpecifier($2); 
+   | identifier class_entry identifier { (void)$2; $$ = DeclClassAddNameSpace($3._class, $3.string); FreeIdentifier($1); FreeIdentifier($3); $$.nameLoc = @3; $$.isRemote = true; memberAccessStack[++defaultMemberAccess] = privateAccess; }
+   | identifier class_entry base_strict_type { (void)$2; $$ = DeclClass($3.nsSpec, $3.name); FreeIdentifier($1); $$.nameLoc = @3; $$.isRemote = true; FreeSpecifier($3); memberAccessStack[++defaultMemberAccess] = privateAccess; }
+
+   | class_entry identifier '<' template_parameters_list '>' { (void)$1; $$ = DeclClassAddNameSpace($2._class, $2.string); $$.templateParams = $4; FreeIdentifier($2); $$.nameLoc = @2; memberAccessStack[++defaultMemberAccess] = privateAccess; }
+   | class_entry base_strict_type '<' template_parameters_list '>'
+   {
+      (void)$1; $$ = DeclClass($2.nsSpec, $2.name);
+      $$.templateParams = $4;
+      $$.nameLoc = @2;
+      FreeSpecifier($2);
       ++defaultMemberAccess;
       memberAccessStack[defaultMemberAccess] = privateAccess;
    }
-   | identifier class_entry identifier '<' template_parameters_list '>' { $$ = DeclClassAddNameSpace(globalContext.nextID++, $3.string); $$.templateParams = $5; FreeIdentifier($1); FreeIdentifier($3); $$.nameLoc = @3; $$.isRemote = true; memberAccessStack[++defaultMemberAccess] = privateAccess; }
-   | identifier class_entry base_strict_type '<' template_parameters_list '>' { $$ = DeclClass(globalContext.nextID++, $3.name); $$.templateParams = $5; FreeIdentifier($1); $$.nameLoc = @3; $$.isRemote = true; FreeSpecifier($3); memberAccessStack[++defaultMemberAccess] = privateAccess; }
+   | identifier class_entry identifier '<' template_parameters_list '>' { (void)$2; $$ = DeclClassAddNameSpace($3._class, $3.string); $$.templateParams = $5; FreeIdentifier($1); FreeIdentifier($3); $$.nameLoc = @3; $$.isRemote = true; memberAccessStack[++defaultMemberAccess] = privateAccess; }
+   | identifier class_entry base_strict_type '<' template_parameters_list '>' { (void)$2; $$ = DeclClass($3.nsSpec, $3.name); $$.templateParams = $5; FreeIdentifier($1); $$.nameLoc = @3; $$.isRemote = true; FreeSpecifier($3); memberAccessStack[++defaultMemberAccess] = privateAccess; }
    ;
 
 class:
      class_error '}'
       {
          $$.loc = @$;
+         $$ = $1;
       }
 
    // Added this for unit classes...
        | class_head ';'
       {
-         $$ = $1; $$.definitions = MkList(); $$.blockStart = @2;  $$.loc = @$; $$.endid = globalContext.nextID++;
+         $$ = $1; $$.definitions = MkList(); $$.blockStart = @2;  $$.loc = @$;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
 
        | class_decl '{' '}'
       {
-         $$ = MkClass($1, null, MkList()); $$.blockStart = @2;  $$.loc = @$; $$.endid = globalContext.nextID++;
+         $$ = MkClass($1, null, MkList()); $$.blockStart = @2;  $$.loc = @$;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
        | class_head '{' '}'
       {
-         $$ = $1; $$.definitions = MkList(); $$.blockStart = @2;  $$.loc = @$; $$.endid = globalContext.nextID++;
+         $$ = $1; $$.definitions = MkList(); $$.blockStart = @2;  $$.loc = @$;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
 
        | class_entry identifier ';'
       {
-         $$ = MkClass(DeclClassAddNameSpace(0, $2.string), null, null); FreeIdentifier($2);
+         (void)$1; $$ = MkClass(DeclClassAddNameSpace($2._class, $2.string), null, null); FreeIdentifier($2);
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
        | class_entry type ';'
       {
-         $$ = MkClass(DeclClass(0, $2.name), null, null); FreeSpecifier($2);
+         (void)$1; $$ = MkClass(DeclClass($2.nsSpec, $2.name), null, null); FreeSpecifier($2);
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
@@ -1335,39 +1346,39 @@ class_head:
    ;
 
 class_error:
-        class_decl '{' struct_declaration_list_error 
+        class_decl '{' struct_declaration_list_error
       {
-         $$ = MkClass($1, null, $3); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2; $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; $$.endid = globalContext.nextID++;
+         $$ = MkClass($1, null, $3); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2; $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
-       | class_head '{' struct_declaration_list_error 
+       | class_head '{' struct_declaration_list_error
       {
-         $$ = $1; $$.definitions = $3; $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; $$.endid = globalContext.nextID++;
+         $$ = $1; $$.definitions = $3; $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
        | class_decl '{' struct_declaration_list
       {
-         $$ = MkClass($1, null, $3); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2; $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; $$.endid = globalContext.nextID++;
+         $$ = MkClass($1, null, $3); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2; $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
        | class_head '{' struct_declaration_list
       {
-         $$ = $1; $$.definitions = $3; $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; $$.endid = globalContext.nextID++;
+         $$ = $1; $$.definitions = $3; $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
        | class_decl '{' error
       {
-         $$ = MkClass($1, null, MkList()); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; $$.endid = globalContext.nextID++;
+         $$ = MkClass($1, null, MkList()); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
        | class_head '{' error
       {
-         $$ = $1; $$.definitions = MkList(); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; $$.endid = globalContext.nextID++;
+         $$ = $1; $$.definitions = MkList(); $$.deleteWatchable = deleteWatchable; deleteWatchable = false; $$.blockStart = @2;  $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++;
          POP_DEFAULT_ACCESS
          PopContext(curContext);
       }
@@ -1386,6 +1397,16 @@ primary_expression:
       { $$ = MkExpBrackets($2); $$.loc = @$; }
    ;
 
+i18n_string:
+         string_literal     { $$ = MkExpString($1); delete $1; $$.loc = @$; }
+   | '$' string_literal     { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
+   | '$' string_literal '.' string_literal     { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
+   ;
+
+constant:
+   CONSTANT { $$ = MkExpConstant(yytext); $$.loc = @$; }
+   ;
+
 simple_primary_expression:
          identifier         { $$ = MkExpIdentifier($1); $$.loc = @$; }
    | instantiation_unnamed      { $$ = MkExpInstance($1); $$.loc = @$; }
@@ -1393,10 +1414,22 @@ simple_primary_expression:
    | EXTENSION '(' expression ')'    { $$ = MkExpExtensionExpression($3); $$.loc = @$; }
    | EXTENSION '(' type_name ')' initializer     { $$ = MkExpExtensionInitializer($3, $5); $$.loc = @$; }
    | EXTENSION '(' type_name ')' '(' type_name ')' initializer     { $$ = MkExpExtensionInitializer($3, MkInitializerAssignment(MkExpExtensionInitializer($6, $8))); $$.loc = @$; }
-       | CONSTANT           { $$ = MkExpConstant(yytext); $$.loc = @$; }
-       | string_literal     { $$ = MkExpString($1); delete $1; $$.loc = @$; }
-   | '$' string_literal     { $$ = MkExpIntlString($2, null); delete $2; $$.loc = @$; }
-   | '$' string_literal '.' string_literal     { $$ = MkExpIntlString($4, $2); delete $2; delete $4; $$.loc = @$; }
+   | constant identifier
+   {
+      char * constant = $1.constant;
+      int len = strlen(constant);
+      if(constant[len-1] == '.')
+      {
+         constant[len-1] = 0;
+         $$ = MkExpMember($1, $2);
+         $$.loc = @$;
+      }
+      else
+         yyerror();
+   }
+       | constant { $$ = $1; }
+   | i18n_string
+   | WIDE_STRING_LITERAL { $$ = MkExpWideString(yytext); $$.loc = @$; }
    | '(' ')' { Expression exp = MkExpDummy(); exp.loc.start = @1.end; exp.loc.end = @2.start; $$ = MkExpBrackets(MkListOne(exp)); $$.loc = @$; yyerror(); }
    | NEWOP new_specifiers abstract_declarator_noarray '[' constant_expression ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
    | NEWOP new_specifiers abstract_declarator_noarray '[' constant_expression_error ']' { $$ = MkExpNew(MkTypeName($2,$3), $5); $$.loc = @$; }
@@ -1418,7 +1451,7 @@ simple_primary_expression:
    | CLASS '(' declaration_specifiers abstract_declarator ')' { $$ = MkExpClass($3, $4); $$.loc = @$; }
    | CLASS '(' identifier ')' { $$ = MkExpClass(MkListOne(MkSpecifierName($3.string)), null); FreeIdentifier($3); $$.loc = @$; }
    | VAARG '(' assignment_expression ',' type_name ')' { $$ = MkExpVaArg($3, $5); $$.loc = @$; }
-   
+
    | CLASS_DATA '(' identifier ')' { $$ = MkExpClassData($3); $$.loc = @$; }
    | database_open
    | dbfield
@@ -1426,6 +1459,7 @@ simple_primary_expression:
    | dbtable
 
    | '[' argument_expression_list /*expression*/ ']' { $$ = MkExpArray($2); $$.loc = @$; }
+   | '[' ']' { $$ = MkExpArray(null); $$.loc = @$; }
    ;
 
 anon_instantiation_expression:
@@ -1437,7 +1471,7 @@ anon_instantiation_expression_error:
    ;
 
 primary_expression_error:
-         '(' expression  { $$ = MkExpBrackets($2); $$.loc = @$; }
+         '(' expression  { yyerror(); $$ = MkExpBrackets($2); $$.loc = @$; }
    | '(' expression_error { $$ = MkExpBrackets($2); $$.loc = @$; }
    ;
 
@@ -1464,7 +1498,7 @@ postfix_expression:
        | postfix_expression_error DEC_OP                           { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
 ;
 
-simple_postfix_expression:
+/*simple_postfix_expression:
          simple_primary_expression
 
    | simple_postfix_expression '[' expression ']'               { $$ = MkExpIndex($1, $3); $$.loc = @$; }
@@ -1485,21 +1519,21 @@ simple_postfix_expression:
        | simple_postfix_expression_error PTR_OP identifier                { $$ = MkExpPointer($1, $3); $$.loc = @$; }
        | simple_postfix_expression_error INC_OP                           { $$ = MkExpOp($1, INC_OP, null); $$.loc = @$; }
        | simple_postfix_expression_error DEC_OP                           { $$ = MkExpOp($1, DEC_OP, null); $$.loc = @$; }
-;
+;*/
 
 argument_expression_list:
          assignment_expression          { $$ = MkList(); ListAdd($$, $1); }
    | anon_instantiation_expression  { $$ = MkList(); ListAdd($$, $1); }
-       | argument_expression_list ',' assignment_expression   { ListAdd($1, $3);  }
-   | argument_expression_list ',' anon_instantiation_expression   { ListAdd($1, $3);  }
+       | argument_expression_list ',' assignment_expression   { $$ = $1; ListAdd($1, $3);  }
+   | argument_expression_list ',' anon_instantiation_expression   { $$ = $1; ListAdd($1, $3);  }
        ;
 
 argument_expression_list_error:
      assignment_expression_error    { $$ = MkList(); ListAdd($$, $1); }
    | anon_instantiation_expression_error    { $$ = MkList(); ListAdd($$, $1); }
-   | argument_expression_list ',' assignment_expression_error  { ListAdd($1, $3);  }
-   | argument_expression_list ',' anon_instantiation_expression_error  { ListAdd($1, $3);  }
-   | argument_expression_list ',' { Expression exp = MkExpDummy(); exp.loc.start = @2.end; exp.loc.end = @2.end; ListAdd($1, exp); }
+   | argument_expression_list ',' assignment_expression_error  { $$ = $1; ListAdd($1, $3);  }
+   | argument_expression_list ',' anon_instantiation_expression_error  { $$ = $1; ListAdd($1, $3);  }
+   | argument_expression_list ',' { Expression exp = MkExpDummy(); yyerror(); exp.loc.start = @2.end; exp.loc.end = @2.end; $$ = $1; ListAdd($1, exp); }
        ;
 
 common_unary_expression:
@@ -1507,23 +1541,29 @@ common_unary_expression:
        | DEC_OP unary_expression           { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
        | unary_operator cast_expression    { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
    | unary_operator anon_instantiation_expression    { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
-       | SIZEOF '(' unary_expression ')'         { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
-   | SIZEOF simple_unary_expression           { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
+       //| SIZEOF '(' unary_expression ')'         { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
+   | SIZEOF unary_expression           { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
    | SIZEOF '(' guess_type_name ')'          { $$ = MkExpTypeSize($3); $$.loc = @$; }
    | SIZEOF '(' CLASS type ')'          { $$ = MkExpClassSize($4); $$.loc = @$; }
    | SIZEOF '(' CLASS guess_type ')'          { $$ = MkExpClassSize($4); $$.loc = @$; }
+
+       //| ALIGNOF '(' unary_expression ')'         { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
+   | ALIGNOF unary_expression           { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
+   | ALIGNOF '(' guess_type_name ')'          { $$ = MkExpTypeAlign($3); $$.loc = @$; }
+
+   | BUILTIN_OFFSETOF '(' guess_type_name ',' identifier ')'      { $$ = MkExpOffsetOf($3, $5); $$.loc = @$; }
        ;
 
 unary_expression:
        common_unary_expression
          | postfix_expression
        ;
-
-simple_unary_expression:
+/*
+?:
      common_unary_expression
        | simple_postfix_expression
        ;
-
+*/
 unary_operator:
          '&'     { $$ = '&'; }
        | '*'     { $$ = '*'; }
@@ -1665,8 +1705,8 @@ assignment_expression:
          conditional_expression
        | unary_expression assignment_operator assignment_expression   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
    | unary_expression_error assignment_operator assignment_expression   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
-       | conditional_expression assignment_operator assignment_expression   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }           // TODO: Generate error here:
-   | conditional_expression_error assignment_operator assignment_expression   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }     // TODO: Generate error here:
+       | conditional_expression assignment_operator assignment_expression   { Compiler_Error($"l-value expected\n"); $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
+   | conditional_expression_error assignment_operator assignment_expression   { Compiler_Error($"l-value expected\n"); $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
 
        | unary_expression assignment_operator anon_instantiation_expression   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
    | unary_expression_error assignment_operator anon_instantiation_expression   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
@@ -1688,17 +1728,17 @@ assignment_operator:
        | OR_ASSIGN             { $$ = OR_ASSIGN; }
        ;
 
-expression: 
+expression:
    assignment_expression                 { $$ = MkList(); ListAdd($$, $1); }
-       | expression ',' assignment_expression  { ListAdd($1, $3); }
-   | expression_error ',' assignment_expression  { ListAdd($1, $3); }
+       | expression ',' assignment_expression  { $$ = $1; ListAdd($1, $3); }
+   | expression_error ',' assignment_expression  { $$ = $1; ListAdd($1, $3); }
    | expression_error  ')'
        ;
 
-expression_anon_inst: 
+expression_anon_inst:
      anon_instantiation_expression                 { $$ = MkList(); ListAdd($$, $1); }
-   | expression ',' anon_instantiation_expression  { ListAdd($1, $3); }
-       | expression_error ',' anon_instantiation_expression  { ListAdd($1, $3); }
+   | expression ',' anon_instantiation_expression  { $$ = $1; ListAdd($1, $3); }
+       | expression_error ',' anon_instantiation_expression  { $$ = $1; ListAdd($1, $3); }
    ;
 
 postfix_expression_error:
@@ -1710,19 +1750,23 @@ postfix_expression_error:
    | postfix_expression PTR_OP error                { $$ = MkExpPointer($1, null); $$.loc = @$; }
    | postfix_expression_error PTR_OP error                { $$ = MkExpPointer($1, null); $$.loc = @$; }
 
-   | postfix_expression '(' argument_expression_list { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;} 
-       | postfix_expression '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;} 
+   | postfix_expression '(' argument_expression_list { yyerror(); $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;}
+       | postfix_expression '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;}
+   /* Useless rules due to conflicts
    | postfix_expression '(' argument_expression_list ',' error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end;$$.loc = @$; $$.call.argLoc.end.charPos++;}
-   | postfix_expression '(' error { $$ = MkExpCall($1, MkList() ); @$.end = yylloc.start; $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = yylloc.start; /*@2.end; $$.call.argLoc.end.charPos++;*/ }
+   | postfix_expression '(' error { $$ = MkExpCall($1, MkList() ); @$.end = yylloc.start; $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = yylloc.start; }
+   */
    | postfix_expression '.' error                   { $$ = MkExpMember($1, null); $$.loc = @$; }
 
-       | postfix_expression_error '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.call.argLoc.end.charPos++;} 
+       | postfix_expression_error '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.call.argLoc.end.charPos++;}
+   /* Useless rules due to conflicts
    | postfix_expression_error '(' argument_expression_list ',' error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.call.argLoc.end.charPos++;}
    | postfix_expression_error '(' error { $$ = MkExpCall($1, MkList() ); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @2.end; $$.call.argLoc.end.charPos++;}
+   */
    | postfix_expression_error '.' error                   { $$ = MkExpMember($1, null); $$.loc = @$; }
        ;
 
-simple_postfix_expression_error:
+/*simple_postfix_expression_error:
       error { $$ = MkExpDummy(); $$.loc = @$; }
    | simple_postfix_expression error
    | instantiation_unnamed_error error { $$ = MkExpInstance($1); $$.loc = @$; }
@@ -1730,28 +1774,35 @@ simple_postfix_expression_error:
    | simple_postfix_expression PTR_OP error                { $$ = MkExpPointer($1, null); $$.loc = @$; }
    | simple_postfix_expression_error PTR_OP error                { $$ = MkExpPointer($1, null); $$.loc = @$; }
 
-   | simple_postfix_expression '(' argument_expression_list { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;} 
-       | simple_postfix_expression '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;} 
-   | simple_postfix_expression '(' argument_expression_list ',' error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end;$$.loc = @$; $$.call.argLoc.end.charPos++;}
-   | simple_postfix_expression '(' error { $$ = MkExpCall($1, MkList() ); @$.end = yylloc.start; $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = yylloc.start; /*@2.end; $$.call.argLoc.end.charPos++;*/ }
+   | simple_postfix_expression '(' argument_expression_list { yyerror(); $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;}
+       | simple_postfix_expression '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.loc = @$; $$.call.argLoc.end.charPos++;}
+   // Useless rules due to conflicts
+   //| simple_postfix_expression '(' argument_expression_list ',' error { $$ = MkExpCall($1, $3); $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end;$$.loc = @$; $$.call.argLoc.end.charPos++;}
+   //| simple_postfix_expression '(' error { $$ = MkExpCall($1, MkList() ); @$.end = yylloc.start; $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = yylloc.start; }
+
    | simple_postfix_expression '.' error                   { $$ = MkExpMember($1, null); $$.loc = @$; }
 
-       | simple_postfix_expression_error '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.call.argLoc.end.charPos++;} 
-   | simple_postfix_expression_error '(' argument_expression_list ',' error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.call.argLoc.end.charPos++;}
-   | simple_postfix_expression_error '(' error { $$ = MkExpCall($1, MkList() ); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @2.end; $$.call.argLoc.end.charPos++;}
+       | simple_postfix_expression_error '(' argument_expression_list_error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @3.end; $$.call.argLoc.end.charPos++;}
+   // Useless rules due to conflicts
+   //| simple_postfix_expression_error '(' argument_expression_list ',' error { $$ = MkExpCall($1, $3); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @4.end; $$.call.argLoc.end.charPos++;}
+   //| simple_postfix_expression_error '(' error { $$ = MkExpCall($1, MkList() ); $$.loc = @$; $$.call.argLoc.start = @2.start; $$.call.argLoc.end = @2.end; $$.call.argLoc.end.charPos++;}
    | simple_postfix_expression_error '.' error                   { $$ = MkExpMember($1, null); $$.loc = @$; }
        ;
+*/
 
 common_unary_expression_error:
           INC_OP unary_expression_error           { $$ = MkExpOp(null, INC_OP, $2); $$.loc = @$; }
         | DEC_OP unary_expression_error           { $$ = MkExpOp(null, DEC_OP, $2); $$.loc = @$; }
         | unary_operator cast_expression_error    { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
     | unary_operator anon_instantiation_expression_error    { $$ = MkExpOp(null, $1, $2); $$.loc = @$; }
-    | SIZEOF '(' unary_expression_error           { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
-        | SIZEOF simple_unary_expression_error           { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
+    //| SIZEOF '(' unary_expression_error           { $$ = MkExpOp(null, SIZEOF, $3); $$.loc = @$; }
+        | SIZEOF unary_expression_error           { $$ = MkExpOp(null, SIZEOF, $2); $$.loc = @$; }
         | SIZEOF '(' guess_type_name ')' error          { $$ = MkExpTypeSize($3); $$.loc = @$; }
     | SIZEOF '(' CLASS type ')' error   { $$ = MkExpClassSize($4); $$.loc = @$; }
     | SIZEOF '(' CLASS guess_type ')' error   { $$ = MkExpClassSize($4); $$.loc = @$; }
+    //| ALIGNOF '(' unary_expression_error           { $$ = MkExpOp(null, ALIGNOF, $3); $$.loc = @$; }
+        | ALIGNOF unary_expression_error           { $$ = MkExpOp(null, ALIGNOF, $2); $$.loc = @$; }
+        | ALIGNOF '(' guess_type_name ')' error          { $$ = MkExpTypeAlign($3); $$.loc = @$; }
        ;
 
 unary_expression_error:
@@ -1759,18 +1810,17 @@ unary_expression_error:
        | postfix_expression_error
    ;
 
-simple_unary_expression_error:
+/*simple_unary_expression_error:
      common_unary_expression_error
        | simple_postfix_expression_error
-   ;
-
+   ;*/
 
 cast_expression_error:
      unary_expression_error
        | '(' type_name ')' cast_expression_error    { $$ = MkExpCast($2, $4); $$.loc = @$; }
        ;
 
-multiplicative_expression_error: 
+multiplicative_expression_error:
      cast_expression_error
        | multiplicative_expression '*' cast_expression_error { $$ = MkExpOp($1, '*', $3); $$.loc = @$; }
        | multiplicative_expression '/' cast_expression_error { $$ = MkExpOp($1, '/', $3); $$.loc = @$; }
@@ -1783,13 +1833,21 @@ multiplicative_expression_error:
 additive_expression_error:
     multiplicative_expression_error
        | additive_expression '+' multiplicative_expression_error  { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
+   /* Useless rules due to conflicts
        | additive_expression '+' error { $$ = MkExpOp($1, '+', null); $$.loc = @$; }
+   */
        | additive_expression '-' multiplicative_expression_error  { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
+   /* Useless rules due to conflicts
    | additive_expression '-' error { $$ = MkExpOp($1, '-', null); $$.loc = @$; }
+   */
        | additive_expression_error '+' multiplicative_expression_error  { $$ = MkExpOp($1, '+', $3); $$.loc = @$; }
+   /* Useless rules due to conflicts
        | additive_expression_error '+' error { $$ = MkExpOp($1, '+', null); $$.loc = @$; }
+   */
        | additive_expression_error '-' multiplicative_expression_error  { $$ = MkExpOp($1, '-', $3); $$.loc = @$; }
+   /* Useless rules due to conflicts
    | additive_expression_error '-' error { $$ = MkExpOp($1, '-', null); $$.loc = @$; }
+   */
        ;
 
 shift_expression_error:
@@ -1806,38 +1864,31 @@ relational_expression_error:
    {
       if($1.type == identifierExp)
       {
-         if($1.identifier._class && !$1.identifier._class.name)
-         {
-            char name[1024];
-            strcpy(name, "::");
-            strcat(name, $1.identifier.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $1.identifier.string);
+         _DeclClass($1.identifier._class, $1.identifier.string);
 
          // printf("Declaring Class %s\n", $1.identifier.string);
          skipErrors = false;
 
          FreeExpression($1);
-         
-         fileInput.Seek(@1.start.pos, start); 
+         FreeExpression($2);
+
+         fileInput.Seek(@1.start.pos, start);
          resetScannerPos(&@1.start);
          yyclearin;
 
-         YYPOPSTACK;
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
 
-         YYPOPSTACK;
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
-/*         
-         YYPOPSTACK;
+/*
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
 
-         YYPOPSTACK;
+         YYPOPSTACK(1);
          yystate = *yyssp;
          YY_STACK_PRINT (yyss, yyssp);
 */
@@ -1849,7 +1900,7 @@ relational_expression_error:
       {
          $$ = MkExpOp($1, '<', $2);
          $$.loc = @$;
-      } 
+      }
       skipErrors = false;
    }
        | relational_expression '>' shift_expression_error    { $$ = MkExpOp($1, '>', $3); $$.loc = @$; }
@@ -1867,12 +1918,12 @@ equality_expression_error:
          | equality_expression NE_OP relational_expression_error  { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
      | equality_expression_error EQ_OP relational_expression_error  { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
          | equality_expression_error NE_OP relational_expression_error  { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
-
+     /* Useless rules due to conflicts
      | equality_expression EQ_OP error        { $$ = MkExpOp($1, EQ_OP, MkExpDummy()); $$.loc = @$; }
          | equality_expression NE_OP error        { $$ = MkExpOp($1, NE_OP, MkExpDummy()); $$.loc = @$; }
      | equality_expression_error EQ_OP error  { $$ = MkExpOp($1, EQ_OP, MkExpDummy()); $$.loc = @$; }
          | equality_expression_error NE_OP error  { $$ = MkExpOp($1, NE_OP, MkExpDummy()); $$.loc = @$; }
-
+     */
      | equality_expression EQ_OP anon_instantiation_expression_error  { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
          | equality_expression NE_OP anon_instantiation_expression_error  { $$ = MkExpOp($1, NE_OP, $3); $$.loc = @$; }
      | equality_expression_error EQ_OP anon_instantiation_expression_error  { $$ = MkExpOp($1, EQ_OP, $3); $$.loc = @$; }
@@ -1948,12 +1999,13 @@ conditional_expression_error:
        | logical_or_expression_error '?' expression_anon_inst ':' anon_instantiation_expression_error { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
    | logical_or_expression_error '?' expression_anon_inst_error ':' anon_instantiation_expression_error { $$ = MkExpCondition($1, $3, $5); $$.loc = @$; }
 
-       | logical_or_expression '?' ':' 
-      { 
-         $$ = MkExpCondition($1, MkListOne(MkExpDummy()), MkExpDummy()); 
-         $$.loc = @$; 
-         ((Expression)$$.cond.exp->last).loc = @2; 
-         $$.cond.elseExp.loc = @3; 
+       | logical_or_expression '?' ':'
+      {
+         yyerror();
+         $$ = MkExpCondition($1, MkListOne(MkExpDummy()), MkExpDummy());
+         $$.loc = @$;
+         ((Expression)$$.cond.exp->last).loc = @2;
+         $$.cond.elseExp.loc = @3;
       }
    | logical_or_expression_error '?' ':'
       {
@@ -1961,6 +2013,7 @@ conditional_expression_error:
       }
    | logical_or_expression '?'
       {
+         yyerror();
          $$ = MkExpCondition($1, MkListOne(MkExpDummy()), MkExpDummy()); $$.loc = @$; ((Expression)$$.cond.exp->last).loc = @2; $$.cond.elseExp.loc = @2;
       }
    | logical_or_expression_error '?'
@@ -1972,32 +2025,38 @@ conditional_expression_error:
 assignment_expression_error:
      conditional_expression_error
    | unary_expression assignment_operator assignment_expression_error   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
+   /* Useless rules due to conflicts
    | unary_expression assignment_operator error   { $$ = MkExpOp($1, $2, MkExpDummy()); $$.loc = @$; $$.op.exp2.loc = @2; }
+   */
    | unary_expression_error assignment_operator assignment_expression_error   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
+   /* Useless rules due to conflicts
    | unary_expression_error assignment_operator error   { $$ = MkExpOp($1, $2, MkExpDummy()); $$.loc = @$; $$.op.exp2.loc = @2; }
+   */
 
    | unary_expression assignment_operator anon_instantiation_expression_error   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
    | unary_expression_error assignment_operator anon_instantiation_expression_error   { $$ = MkExpOp($1, $2, $3); $$.loc = @$; }
        ;
 
-expression_error: 
+expression_error:
      assignment_expression_error                 { $$ = MkList(); ListAdd($$, $1); }
    | assignment_expression error                 { $$ = MkList(); ListAdd($$, $1); }
-   | expression ',' assignment_expression_error  { ListAdd($1, $3); }
-       | expression_error ',' assignment_expression_error  { ListAdd($1, $3); }
-   | expression ',' error 
-   | expression_error ',' error 
+   | expression ',' assignment_expression_error  { $$ = $1; ListAdd($1, $3); }
+       | expression_error ',' assignment_expression_error  { $$ = $1; ListAdd($1, $3); }
+   /* Useless rules due to conflicts
+   | expression ',' error
+   | expression_error ',' error
    | expression error
-   | expression expression                      { FreeList($2, FreeExpression); }
-   | expression_error expression                { FreeList($2, FreeExpression); }
-   | expression expression_error                { FreeList($2, FreeExpression); }
+   */
+   | expression expression                      { yyerror(); $$ = $1; FreeList($2, FreeExpression); }
+   | expression_error expression                { $$ = $1; FreeList($2, FreeExpression); }
+   | expression expression_error                { $$ = $1; FreeList($2, FreeExpression); }
    ;
 
-expression_anon_inst_error: 
+expression_anon_inst_error:
      anon_instantiation_expression_error                 { $$ = MkList(); ListAdd($$, $1); }
    | anon_instantiation_expression error                 { $$ = MkList(); ListAdd($$, $1); }
-   | expression ',' anon_instantiation_expression_error  { ListAdd($1, $3); }
-       | expression_error ',' anon_instantiation_expression_error  { ListAdd($1, $3); }
+   | expression ',' anon_instantiation_expression_error  { $$ = $1; ListAdd($1, $3); }
+       | expression_error ',' anon_instantiation_expression_error  { $$ = $1; ListAdd($1, $3); }
    ;
 
 
@@ -2010,16 +2069,20 @@ storage_class_specifier:
          TYPEDEF       { $$ = MkSpecifier(TYPEDEF); }
        | EXTERN        { $$ = MkSpecifier(EXTERN); }
        | STATIC        { $$ = MkSpecifier(STATIC); }
+       | THREAD        { $$ = MkSpecifier(THREAD); }
        | AUTO          { $$ = MkSpecifier(AUTO); }
        | REGISTER      { $$ = MkSpecifier(REGISTER); }
+   | RESTRICT      { $$ = MkSpecifier(RESTRICT); }
        ;
 
 external_storage_class_specifier:
-         TYPEDEF       { $$ = MkSpecifier(TYPEDEF); declMode = defaultAccess; }
+         TYPEDEF       { $$ = MkSpecifier(TYPEDEF); structDeclMode = declMode = defaultAccess; }
        | EXTERN        { $$ = MkSpecifier(EXTERN); }
-       | STATIC        { $$ = MkSpecifier(STATIC); declMode = staticAccess; }
+       | STATIC        { $$ = MkSpecifier(STATIC); structDeclMode = declMode = staticAccess; }
+   | THREAD        { $$ = MkSpecifier(THREAD); }
        | AUTO          { $$ = MkSpecifier(AUTO); }
        | REGISTER      { $$ = MkSpecifier(REGISTER); }
+   | RESTRICT      { $$ = MkSpecifier(RESTRICT); }
        ;
 
 enumerator:
@@ -2030,7 +2093,7 @@ enumerator:
 
 enumerator_list:
          enumerator                        { $$ = MkList(); ListAdd($$, $1); }
-       | enumerator_list ',' enumerator    { ListAdd($1, $3); }
+       | enumerator_list ',' enumerator    { $$ = $1; ListAdd($1, $3); }
    | enumerator_list ','
        ;
 
@@ -2044,7 +2107,7 @@ enum_specifier_nocompound:
    ;
 
 enum_specifier_compound:
-         enum_specifier_compound_error '}' { $$.loc = @$; POP_DEFAULT_ACCESS }
+         enum_specifier_compound_error '}' { $$.loc = @$; POP_DEFAULT_ACCESS $$ = $1; }
        | enum_specifier identifier '{' '}'    { $$ = MkEnum($2, null); $$.loc = @$; POP_DEFAULT_ACCESS }
    | enum_specifier strict_type '{' '}'          { $$ = MkEnum(MkIdentifier($2.name), null); FreeSpecifier($2); $$.loc = @$; POP_DEFAULT_ACCESS }
        ;
@@ -2064,15 +2127,18 @@ enum_specifier_compound_error:
    | enum_specifier strict_type '{' error                          { $$ = MkEnum(MkIdentifier($2.name), null); $$.loc = @$; FreeSpecifier($2); POP_DEFAULT_ACCESS }
        | enum_specifier strict_type '{' enumerator_list ';' struct_declaration_list           { $$ = MkEnum(MkIdentifier($2.name), $4); $$.loc = @$; $$.definitions = $6; FreeSpecifier($2); POP_DEFAULT_ACCESS }
        | enum_specifier strict_type '{' enumerator_list ';' struct_declaration_list_error           { $$ = MkEnum(MkIdentifier($2.name), $4); $$.loc = @$; $$.definitions = $6; FreeSpecifier($2); POP_DEFAULT_ACCESS }
+
+   | enum_specifier identifier '{' enumerator_list ';'      { $$ = MkEnum($2, $4); $$.loc = @$; POP_DEFAULT_ACCESS }
+       | enum_specifier strict_type '{' enumerator_list ';'            { $$ = MkEnum(MkIdentifier($2.name), $4); $$.loc = @$; FreeSpecifier($2); POP_DEFAULT_ACCESS }
        ;
 
 enum_decl:
-     enum_specifier identifier  { $$ = $2; if(declMode) DeclClassAddNameSpace(globalContext.nextID++, $2.string); }
-   | enum_specifier strict_type { $$ = MkIdentifier($2.name); if(declMode) DeclClass(globalContext.nextID++, $2.name); FreeSpecifier($2); }
+     enum_specifier identifier  { $$ = $2; if(declMode) DeclClassAddNameSpace($2._class, $2.string); }
+   | enum_specifier strict_type { $$ = MkIdentifier($2.name); if(declMode) DeclClass($2.nsSpec, $2.name); FreeSpecifier($2); }
    ;
 
 enum_class:
-     enum_class_error '}'  { $$.loc = @$; }
+     enum_class_error '}'  { $$ = $1; $$.loc = @$; }
    | enum_decl ':' inheritance_specifiers '{' '}' { $$ = MkEnum($1, null); $$.baseSpecs = $3; $$.loc = @$; POP_DEFAULT_ACCESS }
    | enum_decl '{' '}'    { $$ = MkEnum($1, null); POP_DEFAULT_ACCESS }
    ;
@@ -2096,6 +2162,11 @@ enum_class_error:
    | enum_decl '{' error    { $$ = MkEnum($1, null); $$.loc = @$; POP_DEFAULT_ACCESS }
    | enum_decl '{' enumerator_list ';' struct_declaration_list     { $$ = MkEnum($1, $3); $$.definitions = $5; $$.loc = @$; POP_DEFAULT_ACCESS }
    | enum_decl '{' enumerator_list ';' struct_declaration_list_error     { $$ = MkEnum($1, $3); $$.definitions = $5; $$.loc = @$; POP_DEFAULT_ACCESS }
+
+   | enum_decl ':' inheritance_specifiers '{' enumerator_list ';'            { $$ = MkEnum($1, $5); $$.baseSpecs = $3; $$.loc = @$; POP_DEFAULT_ACCESS }
+   | enum_decl ':' inheritance_specifiers '{' enumerator_list error ';'            { $$ = MkEnum($1, $5); $$.baseSpecs = $3;  $$.loc = @$; POP_DEFAULT_ACCESS }
+   | enum_decl ':' inheritance_specifiers '{' error ';'            { $$ = MkEnum($1, null); $$.baseSpecs = $3; $$.loc = @$; POP_DEFAULT_ACCESS }
+   | enum_decl '{' enumerator_list ';'      { $$ = MkEnum($1, $3);  $$.loc = @$; POP_DEFAULT_ACCESS }
    ;
 
 class_specifier:
@@ -2109,8 +2180,7 @@ class_specifier_error:
    ;
 
 ext_storage:
-     EXT_STORAGE  { $$ = MkSpecifierExtended(yytext); }
-   | ext_decl   { $$ = MkSpecifierExtended($1); delete $1; }
+   ext_decl   { $$ = MkSpecifierExtended($1); }
    ;
 
 type_qualifier:
@@ -2122,16 +2192,17 @@ type_qualifier:
 
 type_qualifier_list:
          type_qualifier                          { $$ = MkList(); ListAdd($$, $1); }
-       | type_qualifier_list type_qualifier      { ListAdd($1, $2);  }
+       | type_qualifier_list type_qualifier      { $$ = $1; ListAdd($1, $2);  }
        ;
 
 type_specifier:
-         VOID            { $$ = MkSpecifier(VOID); }  
+         VOID            { $$ = MkSpecifier(VOID); }
        | CHAR            { $$ = MkSpecifier(CHAR); }
        | SHORT           { $$ = MkSpecifier(SHORT); }
        | INT             { $$ = MkSpecifier(INT); }
    | UINT            { $$ = MkSpecifier(UINT); }
    | INT64           { $$ = MkSpecifier(INT64); }
+   | INT128          { $$ = MkSpecifier(INT128); }
    | VALIST          { $$ = MkSpecifier(VALIST); }
        | LONG            { $$ = MkSpecifier(LONG); }
        | FLOAT           { $$ = MkSpecifier(FLOAT); }
@@ -2144,19 +2215,24 @@ type_specifier:
        | type
    | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
    | SUBCLASS '(' type ')'                { $$ = MkSpecifierSubClass($3); }
-   | SUBCLASS '(' identifier ')'          { _DeclClass(0, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
+   | SUBCLASS '(' identifier ')'          { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
    | THISCLASS       { $$ = MkSpecifier(THISCLASS); }
    | TYPED_OBJECT    { $$ = MkSpecifier(TYPED_OBJECT); }
    | ANY_OBJECT      { $$ = MkSpecifier(ANY_OBJECT); }
+   | _BOOL           { $$ = MkSpecifier(_BOOL); }
+   | BOOL            { $$ = MkSpecifier(BOOL); }
+   | _COMPLEX        { $$ = MkSpecifier(_COMPLEX); }
+   | _IMAGINARY      { $$ = MkSpecifier(_IMAGINARY); }
        ;
 
 strict_type_specifier:
-         VOID            { $$ = MkSpecifier(VOID); }  
+         VOID            { $$ = MkSpecifier(VOID); }
        | CHAR            { $$ = MkSpecifier(CHAR); }
        | SHORT           { $$ = MkSpecifier(SHORT); }
        | INT             { $$ = MkSpecifier(INT); }
    | UINT            { $$ = MkSpecifier(UINT); }
    | INT64           { $$ = MkSpecifier(INT64); }
+   | INT128          { $$ = MkSpecifier(INT128); }
    | VALIST          { $$ = MkSpecifier(VALIST); }
        | LONG            { $$ = MkSpecifier(LONG); }
        | FLOAT           { $$ = MkSpecifier(FLOAT); }
@@ -2167,44 +2243,48 @@ strict_type_specifier:
        | struct_or_union_specifier_nocompound
        | enum_specifier_nocompound
        | strict_type
+   | _BOOL           { $$ = MkSpecifier(_BOOL); }
+   | BOOL            { $$ = MkSpecifier(BOOL); }
+   | _COMPLEX        { $$ = MkSpecifier(_COMPLEX); }
+   | _IMAGINARY      { $$ = MkSpecifier(_IMAGINARY); }
    | TYPEOF '(' assignment_expression ')' { $$ = MkSpecifierTypeOf($3); }
    | SUBCLASS '(' type ')'                { $$ = MkSpecifierSubClass($3); }
-   | SUBCLASS '(' identifier ')'          { _DeclClass(0, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
+   | SUBCLASS '(' identifier ')'          { _DeclClass($3._class, $3.string); $$ = MkSpecifierSubClass(MkSpecifierName($3.string)); FreeIdentifier($3); }
    | THISCLASS       { $$ = MkSpecifier(THISCLASS); }
        ;
 
 // TESTING declarator_nofunction here... For function declarations
 
 struct_declarator:
-         declarator_nofunction
+         declarator_nofunction_type_ok
       { $$ = MkStructDeclarator($1, null); $$.loc = @$; }
-       | declarator_nofunction ext_attrib
-      { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }  
+       | declarator_nofunction_type_ok attrib
+      { $$ = MkStructDeclarator($1, null); $$.structDecl.attrib = $2; $$.loc = @$; }
        | ':' constant_expression
       { $$ = MkStructDeclarator(null, $2);  $$.loc = @$; }
-       | declarator_nofunction ':' constant_expression
+       | declarator_nofunction_type_ok ':' constant_expression
       { $$ = MkStructDeclarator($1, $3);  $$.loc = @$; }
-   | declarator_nofunction ':' constant_expression ':' constant_expression
+   | declarator_nofunction_type_ok ':' constant_expression ':' constant_expression
       { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
        | ':' constant_expression_error
       { $$ = MkStructDeclarator(null, $2);  $$.loc = @$; }
-       | declarator_nofunction ':' constant_expression_error
+       | declarator_nofunction_type_ok ':' constant_expression_error
       { $$ = MkStructDeclarator($1, $3);  $$.loc = @$; }
-   | declarator_nofunction ':' constant_expression ':' constant_expression_error
+   | declarator_nofunction_type_ok ':' constant_expression ':' constant_expression_error
       { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
-   | declarator_nofunction ':' constant_expression_error ':' constant_expression_error
+   | declarator_nofunction_type_ok ':' constant_expression_error ':' constant_expression_error
       { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
-   | declarator_nofunction ':' constant_expression_error ':' constant_expression
+   | declarator_nofunction_type_ok ':' constant_expression_error ':' constant_expression
       { $$ = MkStructDeclarator($1, $3); $$.structDecl.posExp = $5; $$.loc = @$; }
    ;
 
 struct_declarator_list:
          struct_declarator                                { $$ = MkList(); ListAdd($$, $1); }
-       | struct_declarator_list ',' struct_declarator     { ListAdd($1, $3); }
+       | struct_declarator_list ',' struct_declarator     { $$ = $1; ListAdd($1, $3); }
        ;
 
 struct_entry:
-     struct_or_union identifier 
+     struct_or_union identifier
       {
          $$ = MkStructOrUnion($1, $2, null);
          $$.addNameSpace = true;
@@ -2216,12 +2296,27 @@ struct_entry:
          $$.ctx = PushContext();
          FreeSpecifier($2);
       }
+   | struct_or_union ext_decl identifier
+      {
+         $$ = MkStructOrUnion($1, $3, null);
+         $$.extDeclStruct = $2;
+         $$.addNameSpace = true;
+         $$.ctx = PushContext();
+      }
+   | struct_or_union ext_decl base_strict_type
+      {
+         $$ = MkStructOrUnion($1, MkIdentifier($3.name), null);
+         $$.extDeclStruct = $2;
+         $$.ctx = PushContext();
+         FreeSpecifier($3);
+      }
    ;
 
 struct_or_union_specifier_compound:
-     struct_or_union_specifier_compound_error '}' { $$.loc = @$; }
+     struct_or_union_specifier_compound_error '}' { $$ = $1; $$.loc = @$; }
    | struct_entry '{' '}'                 { $$ = $1; $$.loc = @$; POP_DEFAULT_ACCESS PopContext(curContext); }
    | struct_or_union '{' '}'              { $$ = MkStructOrUnion($1, null, null); $$.loc = @$; POP_DEFAULT_ACCESS }
+   | struct_or_union ext_decl '{' '}'              { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; $$.loc = @$; POP_DEFAULT_ACCESS }
        ;
 
 struct_or_union_specifier_compound_error:
@@ -2232,6 +2327,10 @@ struct_or_union_specifier_compound_error:
        | struct_or_union '{' struct_declaration_list               { $$ = MkStructOrUnion($1, null, $3); POP_DEFAULT_ACCESS }
    | struct_or_union '{' struct_declaration_list_error               { $$ = MkStructOrUnion($1, null, $3); POP_DEFAULT_ACCESS }
    | struct_or_union '{' error              { $$ = MkStructOrUnion($1, null, null); POP_DEFAULT_ACCESS }
+
+       | struct_or_union ext_decl '{' struct_declaration_list               { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; POP_DEFAULT_ACCESS }
+   | struct_or_union ext_decl '{' struct_declaration_list_error               { $$ = MkStructOrUnion($1, null, $4); $$.extDeclStruct = $2; POP_DEFAULT_ACCESS }
+   | struct_or_union ext_decl '{' error              { $$ = MkStructOrUnion($1, null, null); $$.extDeclStruct = $2; POP_DEFAULT_ACCESS }
        ;
 
 struct_or_union_specifier_nocompound:
@@ -2244,12 +2343,12 @@ struct_decl:
         $$ = $1;
         if(declMode)
         {
-           ($1.addNameSpace ? DeclClassAddNameSpace : DeclClass)(globalContext.nextID++, $1.id.string);
+           ($1.addNameSpace ? DeclClassAddNameSpace : DeclClass)($1.id._class, $1.id.string);
         }
      }
-   | struct_entry '<' template_parameters_list '>' 
+   | struct_entry '<' template_parameters_list '>'
    {
-      Symbol symbol = ($1.addNameSpace ? DeclClassAddNameSpace : DeclClass)(globalContext.nextID++, $1.id.string);
+      Symbol symbol = ($1.addNameSpace ? DeclClassAddNameSpace : DeclClass)($1.id._class, $1.id.string);
       $$ = $1;
       symbol.templateParams = $3;
    }
@@ -2265,10 +2364,10 @@ struct_head:
    ;
 
 struct_class:
-     struct_class_error '}' { $$.loc = @$; }
+     struct_class_error '}' { $$ = $1; $$.loc = @$; }
    | struct_head '{' '}'
       { $$ = $1; POP_DEFAULT_ACCESS PopContext(curContext); }
-   | struct_decl '{' '}'   { POP_DEFAULT_ACCESS PopContext(curContext); }
+   | struct_decl '{' '}'   { $$ = $1; POP_DEFAULT_ACCESS PopContext(curContext); }
    | struct_or_union '{' '}' { $$ = MkStructOrUnion($1, null, null); POP_DEFAULT_ACCESS }
    ;
 
@@ -2318,7 +2417,7 @@ struct_class_error:
         POP_DEFAULT_ACCESS
      }
    | struct_decl '{' error
-      { POP_DEFAULT_ACCESS PopContext(curContext); }
+      { $$ = $1; POP_DEFAULT_ACCESS PopContext(curContext); }
 
        | struct_or_union '{' struct_declaration_list
       { $$ = MkStructOrUnion($1, null, $3); POP_DEFAULT_ACCESS  }
@@ -2335,100 +2434,90 @@ struct_or_union:
 
 specifier_qualifier_list:
      type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | specifier_qualifier_list  type_qualifier            { ListAdd($1, $2); }
+   | specifier_qualifier_list  type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | specifier_qualifier_list  type_specifier            { ListAdd($1, $2); }
+   | specifier_qualifier_list  type_specifier            { $$ = $1; ListAdd($1, $2); }
    | enum_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | specifier_qualifier_list enum_specifier_compound          { ListAdd($1, $2); }
+       | specifier_qualifier_list enum_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | struct_or_union_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | specifier_qualifier_list struct_or_union_specifier_compound          { ListAdd($1, $2); }
+       | specifier_qualifier_list struct_or_union_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    ;
 
 guess_specifier_qualifier_list:
      type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | guess_specifier_qualifier_list  type_qualifier            { ListAdd($1, $2); }
+   | guess_specifier_qualifier_list  type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | guess_specifier_qualifier_list  type_specifier            { ListAdd($1, $2); }
+   | guess_specifier_qualifier_list  type_specifier            { $$ = $1; ListAdd($1, $2); }
    | guess_type                                       { $$ = MkList(); ListAdd($$, $1); }
-   | guess_specifier_qualifier_list  guess_type            { ListAdd($1, $2); }
+   | guess_specifier_qualifier_list  guess_type            { $$ = $1; ListAdd($1, $2); }
    | enum_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | guess_specifier_qualifier_list enum_specifier_compound          { ListAdd($1, $2); }
+       | guess_specifier_qualifier_list enum_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | struct_or_union_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | guess_specifier_qualifier_list struct_or_union_specifier_compound          { ListAdd($1, $2); }
+       | guess_specifier_qualifier_list struct_or_union_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    ;
 
 declaration_specifiers:
      storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | declaration_specifiers storage_class_specifier    { ListAdd($1, $2); }
+   | declaration_specifiers storage_class_specifier    { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | declaration_specifiers  type_qualifier            { ListAdd($1, $2); }
+   | declaration_specifiers  type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | strict_type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | declaration_specifiers  strict_type_specifier            { ListAdd($1, $2); }
+   | declaration_specifiers  strict_type_specifier            { $$ = $1; ListAdd($1, $2); }
    | enum_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | declaration_specifiers enum_specifier_compound          { ListAdd($1, $2); }
+       | declaration_specifiers enum_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | struct_or_union_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | declaration_specifiers struct_or_union_specifier_compound          { ListAdd($1, $2); }
+       | declaration_specifiers struct_or_union_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    ;
 
 guess_declaration_specifiers:
      storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | guess_declaration_specifiers storage_class_specifier    { ListAdd($1, $2); }
+   | guess_declaration_specifiers storage_class_specifier    { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | guess_declaration_specifiers  type_qualifier            { ListAdd($1, $2); }
+   | guess_declaration_specifiers  type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | guess_declaration_specifiers  type_specifier            { ListAdd($1, $2); }
+   | guess_declaration_specifiers  type_specifier            { $$ = $1; ListAdd($1, $2); }
    | guess_type                                       { $$ = MkList(); ListAdd($$, $1); }
-       | guess_declaration_specifiers guess_type          { ListAdd($1, $2); }
+       | guess_declaration_specifiers guess_type          { $$ = $1; ListAdd($1, $2); }
    | struct_or_union_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | guess_declaration_specifiers struct_or_union_specifier_compound          { ListAdd($1, $2); }
+       | guess_declaration_specifiers struct_or_union_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | enum_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | guess_declaration_specifiers enum_specifier_compound          { ListAdd($1, $2); }
+       | guess_declaration_specifiers enum_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    ;
 
 external_guess_declaration_specifiers:
      external_storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | external_guess_declaration_specifiers external_storage_class_specifier    { ListAdd($1, $2); }
+   | external_guess_declaration_specifiers external_storage_class_specifier    { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | external_guess_declaration_specifiers  type_qualifier            { ListAdd($1, $2); }
+   | external_guess_declaration_specifiers  type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | external_guess_declaration_specifiers  type_specifier            { ListAdd($1, $2); }
+   | external_guess_declaration_specifiers  type_specifier            { $$ = $1; ListAdd($1, $2); }
    | guess_type                                       { $$ = MkList(); ListAdd($$, $1); }
-       | external_guess_declaration_specifiers guess_type          { ListAdd($1, $2); }
+       | external_guess_declaration_specifiers guess_type          { $$ = $1; ListAdd($1, $2); }
    | class_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | external_guess_declaration_specifiers class_specifier            { ListAdd($1, $2); }
+   | external_guess_declaration_specifiers class_specifier            { $$ = $1; ListAdd($1, $2); }
    ;
 
 external_guess_declaration_specifiers_error:
      class_specifier_error                             { $$ = MkList(); ListAdd($$, $1); }
-   | external_guess_declaration_specifiers class_specifier_error      { ListAdd($1, $2); }
+   | external_guess_declaration_specifiers class_specifier_error      { $$ = $1; ListAdd($1, $2); }
    ;
 
 _inheritance_specifiers:
      PRIVATE                                          { $$ = MkList(); ListAdd($$, MkSpecifier(PRIVATE)); }
    | PUBLIC                                           { $$ = MkList(); ListAdd($$, MkSpecifier(PUBLIC)); }
    | storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | _inheritance_specifiers storage_class_specifier   { ListAdd($1, $2); }
+   | _inheritance_specifiers storage_class_specifier   { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | _inheritance_specifiers type_qualifier            { ListAdd($1, $2); }
+   | _inheritance_specifiers type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | strict_type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | _inheritance_specifiers strict_type_specifier            { ListAdd($1, $2); }
-   | identifier                                       
-      { _DeclClass(0, $1.string); $$ = MkListOne(MkSpecifierName($1.string)); FreeIdentifier($1); }
-       | _inheritance_specifiers identifier                { _DeclClass(0, $2.string); ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
+   | _inheritance_specifiers strict_type_specifier            { $$ = $1; ListAdd($1, $2); }
+   | identifier
+      { _DeclClass($1._class, $1.string); $$ = MkListOne(MkSpecifierName($1.string)); FreeIdentifier($1); }
+       | _inheritance_specifiers identifier                { $$ = $1; _DeclClass($2._class, $2.string); ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2); }
 
    | identifier '<' template_arguments_list '>'
       {
-         // if($1._class && !$1._class.name)
-         if($1._class)
-         {
-            char name[1024];
-            strcpy(name,  $1._class.name ? $1._class.name : "");
-            strcat(name, "::");
-            strcat(name, $1.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $1.string);
+         _DeclClass($1._class, $1.string);
 
          $$ = MkList();
          ListAdd($$, MkSpecifierNameArgs($1.string, $3));
@@ -2436,15 +2525,8 @@ _inheritance_specifiers:
       }
    | _inheritance_specifiers identifier '<' template_arguments_list '>'
       {
-         if($2._class && !$2._class.name)
-         {
-            char name[1024];
-            strcpy(name, "::");
-            strcat(name, $2.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $2.string);
+         $$ = $1;
+         _DeclClass($2._class, $2.string);
          ListAdd($1, MkSpecifierNameArgs($2.string, $4));
          FreeIdentifier($2);
       }
@@ -2457,26 +2539,16 @@ inheritance_specifiers:
 
 property_specifiers:
      storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | property_specifiers storage_class_specifier     { ListAdd($1, $2); }
+   | property_specifiers storage_class_specifier     { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | property_specifiers type_qualifier            { ListAdd($1, $2); }
+   | property_specifiers type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | strict_type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | property_specifiers strict_type_specifier            { ListAdd($1, $2); }
+   | property_specifiers strict_type_specifier            { $$ = $1; ListAdd($1, $2); }
    | identifier                        { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1)}
-   | property_specifiers identifier          { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
+   | property_specifiers identifier          { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
    | identifier '<' template_arguments_list '>'
       {
-         // if($1._class && !$1._class.name)
-         if($1._class)
-         {
-            char name[1024];
-            strcpy(name,  $1._class.name ? $1._class.name : "");
-            strcat(name, "::");
-            strcat(name, $1.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $1.string);
+         _DeclClass($1._class, $1.string);
 
          $$ = MkList();
          ListAdd($$, MkSpecifierNameArgs($1.string, $3));
@@ -2484,15 +2556,7 @@ property_specifiers:
       }
    | property_specifiers identifier '<' template_arguments_list '>'
       {
-         if($2._class && !$2._class.name)
-         {
-            char name[1024];
-            strcpy(name, "::");
-            strcat(name, $2.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $2.string);
+         _DeclClass($2._class, $2.string);
          ListAdd($1, MkSpecifierNameArgs($2.string, $4));
          FreeIdentifier($2);
       }
@@ -2500,30 +2564,20 @@ property_specifiers:
 
 renew_specifiers:
      storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | renew_specifiers storage_class_specifier    { ListAdd($1, $2); }
+   | renew_specifiers storage_class_specifier    { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | renew_specifiers type_qualifier            { ListAdd($1, $2); }
+   | renew_specifiers type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | strict_type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | renew_specifiers strict_type_specifier            { ListAdd($1, $2); }
+   | renew_specifiers strict_type_specifier            { $$ = $1; ListAdd($1, $2); }
    | struct_or_union_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | renew_specifiers struct_or_union_specifier_compound          { ListAdd($1, $2); }
+       | renew_specifiers struct_or_union_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | enum_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | renew_specifiers enum_specifier_compound          { ListAdd($1, $2); }
+       | renew_specifiers enum_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | identifier                        { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1)}
-   | renew_specifiers identifier          { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
+   | renew_specifiers identifier          { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
    | identifier '<' template_arguments_list '>'
       {
-         // if($1._class && !$1._class.name)
-         if($1._class)
-         {
-            char name[1024];
-            strcpy(name,  $1._class.name ? $1._class.name : "");
-            strcat(name, "::");
-            strcat(name, $1.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $1.string);
+         _DeclClass($1._class, $1.string);
 
          $$ = MkList();
          ListAdd($$, MkSpecifierNameArgs($1.string, $3));
@@ -2531,15 +2585,7 @@ renew_specifiers:
       }
    | renew_specifiers identifier '<' template_arguments_list '>'
       {
-         if($2._class && !$2._class.name)
-         {
-            char name[1024];
-            strcpy(name, "::");
-            strcat(name, $2.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $2.string);
+         _DeclClass($2._class, $2.string);
          ListAdd($1, MkSpecifierNameArgs($2.string, $4));
          FreeIdentifier($2);
       }
@@ -2547,30 +2593,20 @@ renew_specifiers:
 
 new_specifiers:
      storage_class_specifier                          { $$ = MkList(); ListAdd($$, $1); }
-   | new_specifiers storage_class_specifier    { ListAdd($1, $2); }
+   | new_specifiers storage_class_specifier    { $$ = $1; ListAdd($1, $2); }
    | type_qualifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | new_specifiers  type_qualifier            { ListAdd($1, $2); }
+   | new_specifiers  type_qualifier            { $$ = $1; ListAdd($1, $2); }
    | strict_type_specifier                                   { $$ = MkList(); ListAdd($$, $1); }
-   | new_specifiers strict_type_specifier            { ListAdd($1, $2); }
+   | new_specifiers strict_type_specifier            { $$ = $1; ListAdd($1, $2); }
    | struct_or_union_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | new_specifiers struct_or_union_specifier_compound          { ListAdd($1, $2); }
+       | new_specifiers struct_or_union_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | enum_specifier_compound              { $$ = MkList(); ListAdd($$, $1); }
-       | new_specifiers enum_specifier_compound          { ListAdd($1, $2); }
+       | new_specifiers enum_specifier_compound          { $$ = $1; ListAdd($1, $2); }
    | identifier                        { $$ = MkList(); ListAdd($$, MkSpecifierName($1.string)); FreeIdentifier($1)}
-   | new_specifiers identifier          { ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
+   | new_specifiers identifier          { $$ = $1; ListAdd($1, MkSpecifierName($2.string)); FreeIdentifier($2)}
    | identifier '<' template_arguments_list '>'
       {
-         // if($1._class && !$1._class.name)
-         if($1._class)
-         {
-            char name[1024];
-            strcpy(name,  $1._class.name ? $1._class.name : "");
-            strcat(name, "::");
-            strcat(name, $1.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $1.string);
+         _DeclClass($1._class, $1.string);
 
          $$ = MkList();
          ListAdd($$, MkSpecifierNameArgs($1.string, $3));
@@ -2578,36 +2614,84 @@ new_specifiers:
       }
    | new_specifiers identifier '<' template_arguments_list '>'
       {
-         if($2._class && !$2._class.name)
-         {
-            char name[1024];
-            strcpy(name, "::");
-            strcat(name, $2.string);
-            _DeclClass(0, name);
-         }
-         else
-            _DeclClass(0, $2.string);
+         _DeclClass($2._class, $2.string);
          ListAdd($1, MkSpecifierNameArgs($2.string, $4));
          FreeIdentifier($2);
       }
    ;
 
 identifier_list_error:
-     identifier_list ',' error         { ListAdd($1, null); }
-   | identifier_list_error ',' error         { ListAdd($1, null); }
+     identifier_list ',' error         { $$ = $1; ListAdd($1, null); }
+   | identifier_list_error ',' error         { $$ = $1; ListAdd($1, null); }
    ;
 
 identifier_list:
          identifier                        { $$ = MkList(); ListAdd($$, MkTypeName(null, MkDeclaratorIdentifier($1))); }
-       | identifier_list ',' identifier    { ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
-   | identifier_list_error ',' identifier    { ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
-       | parameter_list ',' identifier    { ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
-   | parameter_list_error ',' identifier    { ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
+       | identifier_list ',' identifier    { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
+   | identifier_list_error ',' identifier    { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
+       | parameter_list ',' identifier    { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
+   | parameter_list_error ',' identifier    { $$ = $1; ListAdd($1, MkTypeName(null, MkDeclaratorIdentifier($3))); }
        ;
 
+direct_declarator_nofunction_type_ok:
+     direct_declarator_nofunction
+   | base_strict_type
+   {
+      char * colon = RSearchString($1.name, "::", strlen($1.name), true, false);
+      String s = colon ? colon + 2 : $1.name;
+      $$ = MkDeclaratorIdentifier(MkIdentifier(s));
+      FreeSpecifier($1);
+   }
+   | UINT { $$ = MkDeclaratorIdentifier(MkIdentifier("uint")); }
+   // These rules need to be reviewed in lights of prototypes with types only...
+       | base_strict_type '[' constant_expression ']'
+      {
+         Declarator decl;
+         char * colon = RSearchString($1.name, "::", strlen($1.name), true, false);
+         String s = colon ? colon + 2 : $1.name;
+         decl = MkDeclaratorIdentifier(MkIdentifier(s));
+         FreeSpecifier($1);
+         $$ = MkDeclaratorArray(decl, $3);
+      }
+   | base_strict_type '[' constant_expression_error ']'
+      {
+         Declarator decl;
+         char * colon = RSearchString($1.name, "::", strlen($1.name), true, false);
+         String s = colon ? colon + 2 : $1.name;
+         decl = MkDeclaratorIdentifier(MkIdentifier(s));
+         FreeSpecifier($1);
+         $$ = MkDeclaratorArray(decl, $3);
+      }
+       | base_strict_type '[' type ']'
+      {
+         Declarator decl;
+         char * colon = RSearchString($1.name, "::", strlen($1.name), true, false);
+         String s = colon ? colon + 2 : $1.name;
+         decl = MkDeclaratorIdentifier(MkIdentifier(s));
+         FreeSpecifier($1);
+         $$ = MkDeclaratorEnumArray(decl, $3);
+      }
+       | base_strict_type '[' ']'
+      {
+         Declarator decl;
+         char * colon = RSearchString($1.name, "::", strlen($1.name), true, false);
+         String s = colon ? colon + 2 : $1.name;
+         decl = MkDeclaratorIdentifier(MkIdentifier(s));
+         FreeSpecifier($1);
+         $$ = MkDeclaratorEnumArray(decl, null);
+      }
+       | direct_declarator_nofunction_type_ok '[' constant_expression ']' { $$ = MkDeclaratorArray($1, $3); }
+   | direct_declarator_nofunction_type_ok '[' constant_expression_error ']' { $$ = MkDeclaratorArray($1, $3); }
+       | direct_declarator_nofunction_type_ok '[' type ']' { $$ = MkDeclaratorEnumArray($1, $3); }
+       | direct_declarator_nofunction_type_ok '[' ']'                     { $$ = MkDeclaratorArray($1, null); }
+       ;
+
 direct_declarator_nofunction:
          identifier                                                   { $$ = MkDeclaratorIdentifier($1); }
        | '(' declarator ')'                            { $$ = MkDeclaratorBrackets($2); }
+   | '(' ext_decl declarator ')'                            { $$ = MkDeclaratorBrackets(MkDeclaratorExtended($2, $3)); }
+       | '(' declarator_type_ok ')'                            { $$ = MkDeclaratorBrackets($2); }
+   | '(' ext_decl declarator_type_ok ')'                            { $$ = MkDeclaratorBrackets(MkDeclaratorExtended($2, $3)); }
        | direct_declarator_nofunction '[' constant_expression ']' { $$ = MkDeclaratorArray($1, $3); }
    | direct_declarator_nofunction '[' constant_expression_error ']' { $$ = MkDeclaratorArray($1, $3); }
        | direct_declarator_nofunction '[' type ']' { $$ = MkDeclaratorEnumArray($1, $3); }
@@ -2628,41 +2712,42 @@ direct_declarator_function:
 
 // Tricky stuff here for overriding...
 direct_declarator_function_error:
-   direct_declarator_function_start identifier_list_error     
-      { 
-         $$ = MkDeclaratorFunction($1, null); 
-         fileInput.Seek(@1.end.pos, start); 
+   direct_declarator_function_start identifier_list_error
+      {
+         $$ = MkDeclaratorFunction($1, $2);
+         fileInput.Seek(@1.end.pos, start);
          yyclearin;
          resetScannerPos(&@1.end);
          @$.start = @1.start;
          @$.end = @1.end;
       }
    | direct_declarator_function_start error
-      { 
-         $$ = MkDeclaratorFunction($1, null); 
-         fileInput.Seek(@1.end.pos, start); 
+      {
+         $$ = MkDeclaratorFunction($1, null);
+         fileInput.Seek(@1.end.pos, start);
          yyclearin;
          resetScannerPos(&@1.end);
          @$.start = @1.start;
          @$.end = @1.end;
       }
    | direct_declarator_function_start parameter_list '('
-      { 
-         $$ = MkDeclaratorFunction($1, null); 
-         fileInput.Seek(@1.end.pos, start); 
+      {
+         $$ = MkDeclaratorFunction($1, $2);
+         fileInput.Seek(@1.end.pos, start);
          yyclearin;
          resetScannerPos(&@1.end);
          @$.start = @1.start;
          @$.end = @1.end;
       }
    | direct_declarator_function_start guess_declaration_specifiers identifier '('
-      { 
-         $$ = MkDeclaratorFunction($1, null); 
-         fileInput.Seek(@1.end.pos, start); 
+      {
+         $$ = MkDeclaratorFunction($1, null);
+         fileInput.Seek(@1.end.pos, start);
          yyclearin;
          resetScannerPos(&@1.end);
          @$.start = @1.start;
          @$.end = @1.end;
+         FreeList($2, FreeSpecifier);
          FreeIdentifier($3);
       }
        ;
@@ -2670,12 +2755,73 @@ direct_declarator_function_error:
 direct_declarator:
      direct_declarator_function
    | direct_declarator_nofunction
-   | ext_decl direct_declarator_function
+   ;
+
+
+direct_declarator_function_start_type_ok:
+     direct_declarator_nofunction_type_ok '('
+   ;
+
+direct_declarator_function_type_ok:
+         direct_declarator_function_start_type_ok parameter_type_list ')' { $$ = MkDeclaratorFunction($1, $2); }
+   | direct_declarator_function_start_type_ok parameter_type_list_error ')' { $$ = MkDeclaratorFunction($1, $2); }
+       | direct_declarator_function_start_type_ok identifier_list ')'     { $$ = MkDeclaratorFunction($1, $2); }
+   | direct_declarator_function_start_type_ok identifier_list_error ')'     { $$ = MkDeclaratorFunction($1, $2); }
+       | direct_declarator_function_start_type_ok ')'                     { $$ = MkDeclaratorFunction($1, null); }
+       ;
+
+// Tricky stuff here for overriding...
+direct_declarator_function_error_type_ok:
+   direct_declarator_function_start_type_ok identifier_list_error
+      {
+         $$ = MkDeclaratorFunction($1, $2);
+         fileInput.Seek(@1.end.pos, start);
+         yyclearin;
+         resetScannerPos(&@1.end);
+         @$.start = @1.start;
+         @$.end = @1.end;
+      }
+   | direct_declarator_function_start_type_ok error
+      {
+         $$ = MkDeclaratorFunction($1, null);
+         fileInput.Seek(@1.end.pos, start);
+         yyclearin;
+         resetScannerPos(&@1.end);
+         @$.start = @1.start;
+         @$.end = @1.end;
+      }
+   | direct_declarator_function_start_type_ok parameter_list '('
+      {
+         $$ = MkDeclaratorFunction($1, $2);
+         fileInput.Seek(@1.end.pos, start);
+         yyclearin;
+         resetScannerPos(&@1.end);
+         @$.start = @1.start;
+         @$.end = @1.end;
+      }
+   | direct_declarator_function_start_type_ok guess_declaration_specifiers identifier '('
+      {
+         $$ = MkDeclaratorFunction($1, null);
+         fileInput.Seek(@1.end.pos, start);
+         yyclearin;
+         resetScannerPos(&@1.end);
+         @$.start = @1.start;
+         @$.end = @1.end;
+         FreeList($2, FreeSpecifier);
+         FreeIdentifier($3);
+      }
+       ;
+
+direct_declarator_type_ok:
+     direct_declarator_function_type_ok
+   | direct_declarator_nofunction_type_ok
+/*
+   | ext_decl direct_declarator_function_type_ok
       { $$ = MkDeclaratorExtended($1, $2); }
-   | ext_decl direct_declarator_nofunction
+   | ext_decl direct_declarator_nofunction_type_ok
       { $$ = MkDeclaratorExtended($1, $2); }
+*/
    ;
-
 /*
 asm_start:
     ASM '(' STRING_LITERAL { $<string>$ = CopyString(yytext); } STRING_LITERAL { $<string>$ = CopyString(yytext); }
@@ -2688,19 +2834,19 @@ asm_start:
          delete $<string>4;
          delete $<string>6;
          $<string>$ = CopyString(temp);
-      } 
-   ;  
+      }
+   ;
 
 ext_decl:
-     EXT_DECL { $$ = CopyString(yytext); }
-   | ext_attrib
+     EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
+   | attrib { $$ = MkExtDeclAttrib($1);
    | asm_start ')'
       {
          char temp[1024];
          strcpy(temp, $<string>1);
          strcat(temp, ")");
          delete $<string>1;
-         $$ = CopyString(temp);
+         $$ = MkExtDeclString(CopyString(temp));
       }
    | asm_start STRING_LITERAL { $$ = CopyString(yytext); } ')'
       {
@@ -2711,78 +2857,85 @@ ext_decl:
          strcat(temp, ")");
          delete $<string>1;
          delete $<string>3;
-         $$ = CopyString(temp);
+         $$ = MkExtDeclString(CopyString(temp));
       }
    ;
 */
 
 ext_decl:
-     EXT_DECL { $$ = CopyString(yytext); }
-   | ext_attrib
+     EXT_DECL { $$ = MkExtDeclString(CopyString(yytext)); }
+   | EXT_STORAGE  { $$ = MkExtDeclString(CopyString(yytext)); }
+   | attrib { $$ = MkExtDeclAttrib($1); }
    | ASM '(' string_literal ')'
       {
          char temp[1024];
          strcpy(temp, "__asm__(");
          strcat(temp, $3);
          strcat(temp, ")");
-         $$ = CopyString(temp);
+         $$ = MkExtDeclString(CopyString(temp));
          delete $3;
       }
    ;
 
-ext_attrib:
-   EXT_ATTRIB  { $$ = CopyString(yytext); }
+_attrib:
+   ATTRIB      { $<i>$ = ATTRIB; }
+ | ATTRIB_DEP  { $<i>$ = ATTRIB_DEP; }
+ | __ATTRIB    { $<i>$ = __ATTRIB; }
+ ;
+
+
+attribute_word:
+     IDENTIFIER   { $$  = CopyString(yytext); }
+   | TYPE_NAME    { $$  = CopyString(yytext); }
+   | EXT_STORAGE  { $$  = CopyString(yytext); }
+   | EXT_DECL     { $$  = CopyString(yytext); }
+   | CONST        { $$  = CopyString(yytext); }
+   ;
+
+attribute:
+     attribute_word  { $$ = MkAttribute($1, null); $$.loc = @$; }
+   | attribute_word '(' expression ')'  { $$ = MkAttribute($1, MkExpBrackets($3)); $$.loc = @$; }
+   ;
+
+attribs_list:
+     attribute { $$ = MkListOne($1); }
+   | attribs_list attribute { ListAdd($1, $2); $$ = $1; }
+   | attribs_list ',' attribute { ListAdd($1, $3); $$ = $1; }
+   ;
+
+attrib:
+     _attrib '(' '(' attribs_list ')' ')' { $$ = MkAttrib($<i>1, $4); $$.loc = @$; }
+   | _attrib '(' '('              ')' ')'  { $$ = MkAttrib($<i>1, null); $$.loc = @$; }
    ;
-   
 
 direct_abstract_declarator:
-         '(' abstract_declarator ')'
-                                 { $$ = MkDeclaratorBrackets($2); }
-       | '[' ']'
-                                 { $$ = MkDeclaratorArray(null, null); }
-   | '[' constant_expression ']'
-                                 { $$ = MkDeclaratorArray(null, $2); }
-       | '[' constant_expression_error ']'
-                                 { $$ = MkDeclaratorArray(null, $2); }
-   | '[' type ']'
-                                 { $$ = MkDeclaratorEnumArray(null, $2); }
-       | direct_abstract_declarator '[' ']'
-                                 { $$ = MkDeclaratorArray($1, null); }
-       | direct_abstract_declarator '[' constant_expression ']'
-                                 { $$ = MkDeclaratorArray($1, $3); }
-       | direct_abstract_declarator '[' type']'
-                                 { $$ = MkDeclaratorEnumArray($1, $3); }
-       | direct_abstract_declarator '[' constant_expression_error ']'
-                                 { $$ = MkDeclaratorArray($1, $3); }
-       | '(' ')'
-                                 { $$ = MkDeclaratorFunction(null, null); }
-       | '(' parameter_type_list ')'
-                                 { $$ = MkDeclaratorFunction(null, $2); }
-       | '(' parameter_type_list_error ')'
-                                 { $$ = MkDeclaratorFunction(null, $2); }
-       | direct_abstract_declarator '(' ')'
-                                 { $$ = MkDeclaratorFunction($1, null); }
-       | direct_abstract_declarator '(' parameter_type_list ')'
-                                 { $$ = MkDeclaratorFunction($1, $3); }
-       | direct_abstract_declarator '(' parameter_type_list_error ')'
-                                 { $$ = MkDeclaratorFunction($1, $3); }
+         '(' abstract_declarator ')'               { $$ = MkDeclaratorBrackets($2); }
+       | '(' ext_decl abstract_declarator ')'               { $$ = MkDeclaratorBrackets(MkDeclaratorExtended($2, $3)); }
+       | '[' ']'                                   { $$ = MkDeclaratorArray(null, null); }
+   | '[' constant_expression ']'               { $$ = MkDeclaratorArray(null, $2); }
+       | '[' constant_expression_error ']'         { $$ = MkDeclaratorArray(null, $2); }
+   | '[' type ']'                              { $$ = MkDeclaratorEnumArray(null, $2); }
+       | direct_abstract_declarator '[' ']'        { $$ = MkDeclaratorArray($1, null); }
+       | direct_abstract_declarator '[' constant_expression ']'        { $$ = MkDeclaratorArray($1, $3); }
+       | direct_abstract_declarator '[' type']'                        { $$ = MkDeclaratorEnumArray($1, $3); }
+       | direct_abstract_declarator '[' constant_expression_error ']'  { $$ = MkDeclaratorArray($1, $3); }
+       | '(' ')'                                   { $$ = MkDeclaratorFunction(null, null); }
+       | '(' parameter_type_list ')'               { $$ = MkDeclaratorFunction(null, $2); }
+       | '(' parameter_type_list_error ')'         { $$ = MkDeclaratorFunction(null, $2); }
+       | direct_abstract_declarator '(' ')'        { $$ = MkDeclaratorFunction($1, null); }
+       | direct_abstract_declarator '(' parameter_type_list ')'         { $$ = MkDeclaratorFunction($1, $3); }
+       | direct_abstract_declarator '(' parameter_type_list_error ')'   { $$ = MkDeclaratorFunction($1, $3); }
        ;
 
 direct_abstract_declarator_noarray:
-         '(' abstract_declarator_noarray ')'
-                                 { $$ = MkDeclaratorBrackets($2); }
-       | '(' ')'
-                                 { $$ = MkDeclaratorFunction(null, null); }
-       | '(' parameter_type_list ')'
-                                 { $$ = MkDeclaratorFunction(null, $2); }
-       | '(' parameter_type_list_error ')'
-                                 { $$ = MkDeclaratorFunction(null, $2); }
-       | direct_abstract_declarator_noarray '(' ')'
-                                 { $$ = MkDeclaratorFunction($1, null); }
-       | direct_abstract_declarator_noarray '(' parameter_type_list ')'
-                                 { $$ = MkDeclaratorFunction($1, $3); }
-       | direct_abstract_declarator_noarray '(' parameter_type_list_error ')'
-                                 { $$ = MkDeclaratorFunction($1, $3); }
+         '(' abstract_declarator_noarray ')'          { $$ = MkDeclaratorBrackets($2); }
+       | '(' ext_decl abstract_declarator_noarray ')' { $$ = MkDeclaratorBrackets(MkDeclaratorExtended($2, $3)); }
+       | '(' ')'                                      { $$ = MkDeclaratorFunction(null, null); }
+       | '(' parameter_type_list ')'                  { $$ = MkDeclaratorFunction(null, $2); }
+       | '(' parameter_type_list_error ')'         { $$ = MkDeclaratorFunction(null, $2); }
+       | direct_abstract_declarator_noarray '(' ')'   { $$ = MkDeclaratorFunction($1, null); }
+       | direct_abstract_declarator_noarray '(' parameter_type_list ')'       { $$ = MkDeclaratorFunction($1, $3); }
+       | direct_abstract_declarator_noarray '(' parameter_type_list_error ')' { $$ = MkDeclaratorFunction($1, $3); }
        ;
 
 pointer:
@@ -2797,7 +2950,6 @@ abstract_declarator:
        | direct_abstract_declarator
        | pointer direct_abstract_declarator   { $$ = MkDeclaratorPointer($1, $2); }
    | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
-   | ext_decl direct_abstract_declarator { $$ = MkDeclaratorExtended($1, $2); }
        | ext_decl pointer direct_abstract_declarator { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
        ;
 
@@ -2806,8 +2958,7 @@ abstract_declarator_noarray:
        | direct_abstract_declarator_noarray
        | pointer direct_abstract_declarator_noarray   { $$ = MkDeclaratorPointer($1, $2); }
    | ext_decl pointer { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, null)); }
-   | ext_decl direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, $2); }
-       | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
+   | ext_decl pointer direct_abstract_declarator_noarray { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
        ;
 
 declarator:
@@ -2817,13 +2968,24 @@ declarator:
    | ext_decl pointer direct_declarator
       { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
    | declarator ext_decl
-      { $$ = MkDeclaratorExtendedEnd($2, $1); }  
+      { $$ = MkDeclaratorExtendedEnd($2, $1); }
+   | declarator_nofunction_type_ok ext_decl
+      { $$ = MkDeclaratorExtendedEnd($2, $1); }
+   ;
+
+declarator_type_ok:
+         direct_declarator_type_ok
+       | pointer direct_declarator_type_ok
+      { $$ = MkDeclaratorPointer($1, $2); }
+  | ext_decl pointer direct_declarator_type_ok
+      { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
+   | declarator_type_ok ext_decl
+      { $$ = MkDeclaratorExtendedEnd($2, $1); }
    ;
 
 declarator_function:
      direct_declarator_function
        | pointer direct_declarator_function      { $$ = MkDeclaratorPointer($1, $2); }
-   | ext_decl direct_declarator_function { $$ = MkDeclaratorExtended($1, $2); }
        | ext_decl pointer direct_declarator_function { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
        | pointer ext_decl direct_declarator_function { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
    ;
@@ -2831,33 +2993,46 @@ declarator_function:
 declarator_function_error:
          direct_declarator_function_error
        | pointer direct_declarator_function_error      { $$ = MkDeclaratorPointer($1, $2); }
-   | ext_decl direct_declarator_function_error { $$ = MkDeclaratorExtended($1, $2); }
        | ext_decl pointer direct_declarator_function_error { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
        | pointer ext_decl direct_declarator_function_error { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
    ;
 
-declarator_nofunction:
-         direct_declarator_nofunction
-       | pointer direct_declarator_nofunction      { $$ = MkDeclaratorPointer($1, $2); }
-   | ext_decl direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, $2); }
-       | ext_decl pointer direct_declarator_nofunction { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
-       | pointer ext_decl direct_declarator_nofunction { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
+declarator_function_type_ok:
+     direct_declarator_function_type_ok
+       | pointer direct_declarator_function_type_ok      { $$ = MkDeclaratorPointer($1, $2); }
+       | ext_decl pointer direct_declarator_function_type_ok { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
+       | pointer ext_decl direct_declarator_function_type_ok { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
+   ;
+
+declarator_function_error_type_ok:
+         direct_declarator_function_error_type_ok
+       | pointer direct_declarator_function_error_type_ok      { $$ = MkDeclaratorPointer($1, $2); }
+       | ext_decl pointer direct_declarator_function_error_type_ok { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
+       | pointer ext_decl direct_declarator_function_error_type_ok { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
+   ;
+
+declarator_nofunction_type_ok:
+         direct_declarator_nofunction_type_ok
+       | pointer direct_declarator_nofunction_type_ok      { $$ = MkDeclaratorPointer($1, $2); }
+       | ext_decl pointer direct_declarator_nofunction_type_ok { $$ = MkDeclaratorExtended($1, MkDeclaratorPointer($2, $3)); }
+       | pointer ext_decl direct_declarator_nofunction_type_ok { $$ = MkDeclaratorPointer($1, MkDeclaratorExtended($2, $3)); }
    ;
 
 initializer:
          assignment_expression          { $$ = MkInitializerAssignment($1); $$.loc = @$; }
        | '{' initializer_list '}'       { $$ = MkInitializerList($2); $$.loc = @$; }
-       | '{' initializer_list ',' '}'   
-      { 
-         $$ = MkInitializerList($2); 
-         $$.loc = @$; 
+       | '{' initializer_list ',' '}'
+      {
+         Compiler_Warning($"extra comma\n");
+         $$ = MkInitializerList($2);
+         $$.loc = @$;
 
          {
             Expression exp = MkExpDummy();
             Initializer init = MkInitializerAssignment(exp);
             init.loc = @3;
             exp.loc = @3;
-            ListAdd($2, init); 
+            ListAdd($2, init);
          }
       }
        ;
@@ -2865,10 +3040,10 @@ initializer:
 initializer_error:
      assignment_expression_error    { $$ = MkInitializerAssignment($1); $$.loc = @$; }
        | '{' initializer_list '}' error      { $$ = MkInitializerList($2); $$.loc = @$; }
-   | '{' initializer_list                 { $$ = MkInitializerList($2); $$.loc = @$; }
-       | '{' initializer_list ',' '}' error  
-      { 
-         $$ = MkInitializerList($2); 
+   | '{' initializer_list                 { yyerror(); $$ = MkInitializerList($2); $$.loc = @$; }
+       | '{' initializer_list ',' '}' error
+      {
+         $$ = MkInitializerList($2);
          $$.loc = @$;
 
          {
@@ -2876,12 +3051,13 @@ initializer_error:
             Initializer init = MkInitializerAssignment(exp);
             init.loc = @3;
             exp.loc = @3;
-            ListAdd($2, init); 
+            ListAdd($2, init);
          }
       }
        | '{' initializer_list ','
-      { 
-         $$ = MkInitializerList($2); 
+      {
+         yyerror();
+         $$ = MkInitializerList($2);
          $$.loc = @$;
 
          {
@@ -2889,7 +3065,7 @@ initializer_error:
             Initializer init = MkInitializerAssignment(exp);
             init.loc = @3;
             exp.loc = @3;
-            ListAdd($2, init); 
+            ListAdd($2, init);
          }
       }
        ;
@@ -2908,36 +3084,56 @@ initializer_condition_error:
 initializer_list:
          initializer                       { $$ = MkList(); ListAdd($$, $1); }
    | initializer_error                 { $$ = MkList(); ListAdd($$, $1); }
-       | initializer_list ',' initializer  { ListAdd($1, $3); }
-   | initializer_list ',' initializer_error  { ListAdd($1, $3); }
+       | initializer_list ',' initializer  { $$ = $1; ListAdd($1, $3); }
+   | initializer_list ',' initializer_error  { $$ = $1; ListAdd($1, $3); }
 
    // Errors
-       | initializer_list initializer  { ListAdd($1, $2); }
-   | initializer_list initializer_error  { ListAdd($1, $2); }
+       | initializer_list initializer  { yyerror(); $$ = $1; ListAdd($1, $2); }
+   | initializer_list initializer_error  { $$ = $1; ListAdd($1, $2); }
        ;
 
 init_declarator:
          declarator                     { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
+   | declarator_type_ok             { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
        | declarator '=' initializer     { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
        ;
 
 init_declarator_error:
          declarator error                 { $$ = MkInitDeclarator($1, null); $$.loc = @$; }
+   /* Useless rules due to conflicts
    | declarator '=' error                 { $$ = MkInitDeclarator($1, MkInitializerAssignment(MkExpDummy())); $$.loc = @$; $$.initializer.loc = @2; $$.initializer.exp.loc = @2; }
+   */
        | declarator '=' initializer_error     { $$ = MkInitDeclarator($1, $3); $$.loc = @$; $$.initializer.loc.start = @2.end; }
        ;
 
 init_declarator_list:
          init_declarator                            { $$ = MkList(); ListAdd($$, $1); }
-       | init_declarator_list ',' init_declarator   { ListAdd($1, $3); }
-   | init_declarator_list_error ',' init_declarator   { ListAdd($1, $3); }
+       | init_declarator_list ',' init_declarator   { $$ = $1; ListAdd($1, $3); }
+       | UINT ',' init_declarator                  { $$ = MkList(); ListAdd($$, MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("uint")), null)); ListAdd($$, $3); }
+   | INT64 ',' init_declarator                  { $$ = MkList(); ListAdd($$, MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("int64")), null)); ListAdd($$, $3); }
+   | INT128 ',' init_declarator                 { $$ = MkList(); ListAdd($$, MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("__int128")), null)); ListAdd($$, $3); }
+       | base_strict_type ',' init_declarator
+   {
+      char * colon = RSearchString($1.name, "::", strlen($1.name), true, false);
+      String s = colon ? colon + 2 : $1.name;
+      $$ = MkList();
+      ListAdd($$, MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), null));
+      ListAdd($$, $3);
+      FreeSpecifier($1);
+   }
+   | init_declarator_list_error ',' init_declarator   { $$ = $1; ListAdd($1, $3); }
+   /*| base_strict_type ',' init_declarator
+      {
+         $$ = MkList();
+         ListAdd($1, $3);
+      }*/
        ;
 
 init_declarator_list_error:
          init_declarator_error                            { $$ = MkList(); ListAdd($$, $1); }
    | init_declarator error                            { $$ = MkList(); ListAdd($$, $1); }
-       | init_declarator_list ',' init_declarator_error   { ListAdd($1, $3); }
-   | init_declarator_list_error ',' init_declarator_error   { ListAdd($1, $3); }
+       | init_declarator_list ',' init_declarator_error   { $$ = $1; ListAdd($1, $3); }
+   | init_declarator_list_error ',' init_declarator_error   { $$ = $1; ListAdd($1, $3); }
        ;
 
 type_name:
@@ -2952,21 +3148,21 @@ guess_type_name:
 
 /*** PARAMETERS **********************************************************************/
 parameter_declaration:
-     guess_declaration_specifiers declarator          { $$ = MkTypeName($1, $2); }
+     guess_declaration_specifiers declarator_type_ok          { $$ = MkTypeName($1, $2); }
    | guess_declaration_specifiers abstract_declarator { $$ = MkTypeName($1, $2); }
    | guess_declaration_specifiers '&'                 { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), null)); }
-   | guess_declaration_specifiers '&' declarator      { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
-       | guess_declaration_specifiers                     { $$ = MkTypeName($1, null); }
+   | guess_declaration_specifiers '&' declarator_type_ok      { $$ = MkTypeName($1, MkDeclaratorPointer(MkPointer(null,null), $3)); }
+       | guess_declaration_specifiers                     { $$ = MkTypeNameGuessDecl($1, null); }
    | CLASS
       { $$ = MkTypeName(MkListOne(MkSpecifier(CLASS)), null); }
 /*
-   | TYPED_OBJECT                                            
+   | TYPED_OBJECT
       { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), null); }
    | TYPED_OBJECT '&'
       { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), null)); }
-   | TYPED_OBJECT declarator                                           
+   | TYPED_OBJECT declarator
       { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), $2);  }
-   | TYPED_OBJECT '&' declarator                                       
+   | TYPED_OBJECT '&' declarator
       { $$ = MkTypeName(MkListOne(MkSpecifier(TYPED_OBJECT)), MkDeclaratorPointer(MkPointer(null,null), $3)); }
    | ANY_OBJECT
       { $$ = MkTypeName(MkListOne(MkSpecifier(ANY_OBJECT)), null); }
@@ -2976,55 +3172,55 @@ parameter_declaration:
        ;
 
 parameter_declaration_error:
-         guess_declaration_specifiers declarator error          { $$ = MkTypeName($1, $2); }
+         guess_declaration_specifiers declarator_type_ok error          { $$ = MkTypeName($1, $2); }
        | guess_declaration_specifiers abstract_declarator error { $$ = MkTypeName($1, $2); }
        ;
 
 parameter_list:
          parameter_declaration                      { $$ = MkList(); ListAdd($$, $1); }
-       | parameter_list ',' parameter_declaration   { ListAdd($1, $3); }
-   | parameter_list error ',' parameter_declaration   { ListAdd($1, $4); }
-   | parameter_list_error ',' parameter_declaration   { ListAdd($1, $3); }
-   | parameter_list_error error ',' parameter_declaration   { ListAdd($1, $4); }
+       | parameter_list ',' parameter_declaration   { $$ = $1; ListAdd($1, $3); }
+   | parameter_list error ',' parameter_declaration   { $$ = $1; ListAdd($1, $4); }
+   | parameter_list_error ',' parameter_declaration   { $$ = $1; ListAdd($1, $3); }
+   | parameter_list_error error ',' parameter_declaration   { $$ = $1; ListAdd($1, $4); }
    | error ',' parameter_declaration   { $$ = MkList(); ListAdd($$, MkTypeName(MkList(), null)); ListAdd($$, $3); }
 
-       | identifier_list ',' parameter_declaration   { ListAdd($1, $3); }
-   | identifier_list error ',' parameter_declaration   { ListAdd($1, $4); }
-   | identifier_list_error ',' parameter_declaration   { ListAdd($1, $3); }
-   | identifier_list_error error ',' parameter_declaration   { ListAdd($1, $4); }
+       | identifier_list ',' parameter_declaration   { $$ = $1; ListAdd($1, $3); }
+   | identifier_list error ',' parameter_declaration   { $$ = $1; ListAdd($1, $4); }
+   | identifier_list_error ',' parameter_declaration   { $$ = $1; ListAdd($1, $3); }
+   | identifier_list_error error ',' parameter_declaration   { $$ = $1; ListAdd($1, $4); }
 ;
 
 parameter_list_error:
          parameter_declaration_error                      { $$ = MkList(); ListAdd($$, $1); }
-       | parameter_list ',' parameter_declaration_error   { ListAdd($1, $3); }
-   | parameter_list_error ',' parameter_declaration_error   { ListAdd($1, $3); }
-   | parameter_list_error error ',' parameter_declaration_error   { ListAdd($1, $4); }
+       | parameter_list ',' parameter_declaration_error   { $$ = $1; ListAdd($1, $3); }
+   | parameter_list_error ',' parameter_declaration_error   { $$ = $1; ListAdd($1, $3); }
+   | parameter_list_error error ',' parameter_declaration_error   { $$ = $1; ListAdd($1, $4); }
    | error ',' parameter_declaration_error   { $$ = MkList(); ListAdd($$, MkTypeName(MkList(), null)); ListAdd($$, $3); }
 
-       | identifier_list ',' parameter_declaration_error   { ListAdd($1, $3); }
-   | identifier_list_error ',' parameter_declaration_error   { ListAdd($1, $3); }
-   | identifier_list_error error ',' parameter_declaration_error   { ListAdd($1, $4); }
-       ;   
+       | identifier_list ',' parameter_declaration_error   { $$ = $1; ListAdd($1, $3); }
+   | identifier_list_error ',' parameter_declaration_error   { $$ = $1; ListAdd($1, $3); }
+   | identifier_list_error error ',' parameter_declaration_error   { $$ = $1; ListAdd($1, $4); }
+       ;
 
 parameter_type_list:
          parameter_list
-       | parameter_list ',' ELLIPSIS                { ListAdd($1, MkTypeName(null, null)); }
-   | parameter_list_error ',' ELLIPSIS                { ListAdd($1, MkTypeName(null, null)); }
-       | identifier_list ',' ELLIPSIS                { ListAdd($1, MkTypeName(null, null)); }
-   | identifier_list_error ',' ELLIPSIS                { ListAdd($1, MkTypeName(null, null)); }
+       | parameter_list ',' ELLIPSIS                { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
+   | parameter_list_error ',' ELLIPSIS                { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
+       | identifier_list ',' ELLIPSIS                { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
+   | identifier_list_error ',' ELLIPSIS                { $$ = $1; ListAdd($1, MkTypeName(null, null)); }
    | error ',' ELLIPSIS                { $$ = MkList(); ListAdd($$, MkTypeName(null, null)); }
        ;
 
-parameter_type_list_error: 
+parameter_type_list_error:
     parameter_list_error
-   | parameter_list ',' error                { ListAdd($1, null); }
+   | parameter_list ',' error                { $$ = $1; ListAdd($1, null); }
    | parameter_list_error error
        ;
 
 /****** STATEMENTS *******************************************************************/
 statement:
          labeled_statement
-   | EXT_ATTRIB { $$ = MkExpressionStmt(null); }   // Ignoring this for now... ( For __attribute__ ((__unused__)) )
+   | attrib { $$ = MkExpressionStmt(null); FreeAttrib($1); }   // Ignoring this for now... ( For __attribute__ ((__unused__)) )
        | compound_statement
    | ';' { $$ = MkExpressionStmt(null); }
    | ':' { $$ = MkExpressionStmt(null); }
@@ -3032,26 +3228,26 @@ statement:
        | selection_statement
        | iteration_statement
        | jump_statement
-   | asm_statement {}
-
+   | asm_statement
    | firewatchers ';'
    | stopwatching ';'
    | watch_definition ';'
        ;
 
 statement_error:
-       labeled_statement_error          { $$ = $1; Compiler_Error("syntax error\n"); } 
-   | iteration_statement_error      { $$ = $1; Compiler_Error("syntax error\n"); } 
-   | compound_statement_error       { $$ = $1; Compiler_Error("syntax error\n"); } 
-       | selection_statement_error      { $$ = $1; Compiler_Error("syntax error\n"); } 
-   | jump_statement_error           { $$ = $1; Compiler_Error("syntax error\n"); } 
-       | jump_statement error           { $$ = $1; Compiler_Error("syntax error\n"); } 
-   | expression_error { $$ = MkExpressionStmt($1); Compiler_Error("syntax error\n"); $$.loc = @1; }
+       labeled_statement_error          { $$ = $1; Compiler_Error($"syntax error\n"); }
+   | iteration_statement_error      { $$ = $1; Compiler_Error($"syntax error\n"); }
+   | compound_statement_error       { $$ = $1; Compiler_Error($"syntax error\n"); }
+       | selection_statement_error      { $$ = $1; Compiler_Error($"syntax error\n"); }
+   | jump_statement_error           { $$ = $1; Compiler_Error($"syntax error\n"); }
+       | jump_statement error           { $$ = $1; Compiler_Error($"syntax error\n"); }
+   | expression_error { $$ = MkExpressionStmt($1); Compiler_Error($"syntax error\n"); $$.loc = @1; }
    ;
 
 asm_field:
-     string_literal { $$ = MkAsmField($1, null); $$.loc = @1; }
-   | string_literal '(' assignment_expression ')' { $$ = MkAsmField($1, $3); $$.loc = @$; }
+     string_literal { $$ = MkAsmField($1, null, null); $$.loc = @1; }
+   | string_literal '(' assignment_expression ')' { $$ = MkAsmField($1, $3, null); $$.loc = @$; }
+   | '[' identifier ']' string_literal '(' assignment_expression ')' { $$ = MkAsmField($4, $6, $2); $$.loc = @$; }
    ;
 
 asm_field_list:
@@ -3065,7 +3261,7 @@ asm_statement:
    | ASM type_qualifier '(' string_literal ':' asm_field_list ')' ';'                                       { $$ = MkAsmStmt($2, $4, $6, null, null); $$.loc = @$; }
    | ASM type_qualifier '(' string_literal ':' asm_field_list ':' asm_field_list ')' ';'                    { $$ = MkAsmStmt($2, $4, $6, $8, null); $$.loc = @$; }
    | ASM type_qualifier '(' string_literal ':' asm_field_list ':' asm_field_list ':' asm_field_list ')' ';' { $$ = MkAsmStmt($2, $4, $6, $8, $10); $$.loc = @$; }
-   
+
    | ASM type_qualifier '(' string_literal IDENTIFIER asm_field_list ')' ';'                                { $$ = MkAsmStmt($2, $4, null, $6, null); $$.loc = @$; }
    | ASM type_qualifier '(' string_literal IDENTIFIER asm_field_list ':' asm_field_list ')' ';'             { $$ = MkAsmStmt($2, $4, null, $6, $8); $$.loc = @$; }
    | ASM type_qualifier '(' string_literal ':' asm_field_list IDENTIFIER asm_field_list ')' ';'             { $$ = MkAsmStmt($2, $4, $6, null, $8); $$.loc = @$; }
@@ -3081,27 +3277,39 @@ asm_statement:
    ;
 
 labeled_statement:
-         identifier ':' statement                { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
-   | CASE constant_expression ':' statement  { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
-   | CASE constant_expression_error ':' statement  { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
-   | CASE ':' statement  { $$ = MkCaseStmt(MkExpDummy(), $3); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
-       | DEFAULT ':' statement                   { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
-       ;
-
-labeled_statement_error
-       : identifier ':' statement_error                { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
-   | CASE constant_expression ':' statement_error  { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
-   | CASE constant_expression_error ':' statement_error  { $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
-   | CASE ':' statement_error  { $$ = MkCaseStmt(MkExpDummy(), $3); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
+     identifier ':' statement                      { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
+   | CASE constant_expression ':' statement        { /*if($4.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE constant_expression_error ':' statement  { /*if($4.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE ':' statement                            { /*if($3.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt(MkExpDummy(), $3); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
+   | DEFAULT ':' statement                         { /*if($3.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt(null, $3); $$.loc = @$; }
+
+   | identifier ':' declaration                      { Statement stmt = MkBadDeclStmt($3); stmt.loc = @3; Compiler_Warning(C89_DECL_WARNING); $$ = MkLabeledStmt($1, stmt); $$.loc = @$; }
+   | CASE constant_expression ':' declaration        { Statement stmt = MkBadDeclStmt($4); stmt.loc = @4; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt($2, stmt); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE constant_expression_error ':' declaration  { Statement stmt = MkBadDeclStmt($4); stmt.loc = @4; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt($2, stmt); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE ':' declaration                            { Statement stmt = MkBadDeclStmt($3); stmt.loc = @3; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt(MkExpDummy(), stmt); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
+   | DEFAULT ':' declaration                         { Statement stmt = MkBadDeclStmt($3); stmt.loc = @3; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt(null, stmt); $$.loc = @$; }
+   ;
+
+labeled_statement_error:
+         identifier ':' statement_error                { $$ = MkLabeledStmt($1, $3); $$.loc = @$; }
+   | CASE constant_expression ':' statement_error  { /*if($4.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE constant_expression_error ':' statement_error  { /*if($4.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt($2, $4); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE ':' statement_error  { /*if($3.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt(MkExpDummy(), $3); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
    | CASE ':' { $$ = MkCaseStmt(MkExpDummy(), null); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
-       | DEFAULT ':' statement_error                   { $$ = MkCaseStmt(null, $3); $$.loc = @$; }
+       | DEFAULT ':' statement_error                   { /*if($3.type == labeledStmt) Compiler_Warning(CASE_LABELED_STMT_WARNING);*/ $$ = MkCaseStmt(null, $3); $$.loc = @$; }
    | DEFAULT ':'  { $$ = MkCaseStmt(null, null); $$.loc = @$; }
+
+   | identifier ':' declaration_error                      { Statement stmt = MkBadDeclStmt($3); stmt.loc = @3; Compiler_Warning(C89_DECL_WARNING); $$ = MkLabeledStmt($1, stmt); $$.loc = @$; }
+   | CASE constant_expression ':' declaration_error        { Statement stmt = MkBadDeclStmt($4); stmt.loc = @4; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt($2, stmt); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE constant_expression_error ':' declaration_error  { Statement stmt = MkBadDeclStmt($4); stmt.loc = @4; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt($2, stmt); $$.loc = @$; $2.loc.start = @1.end; }
+   | CASE ':' declaration_error                            { Statement stmt = MkBadDeclStmt($3); stmt.loc = @3; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt(MkExpDummy(), stmt); $$.caseStmt.exp.loc = @2; $$.loc = @$; $$.caseStmt.exp.loc.start = @1.end; }
+   | DEFAULT ':' declaration_error                         { Statement stmt = MkBadDeclStmt($3); stmt.loc = @3; Compiler_Warning(C89_DECL_WARNING); $$ = MkCaseStmt(null, stmt); $$.loc = @$; }
        ;
 
 declaration_mode:
-     PUBLIC    { $$ = declMode = publicAccess; }
-   | PRIVATE   { $$ = declMode = privateAccess; }
-   | DEFAULT   { $$ = declMode = defaultAccess; }
+     PUBLIC    { $$ = structDeclMode = declMode = publicAccess; }
+   | PRIVATE   { $$ = structDeclMode = declMode = privateAccess; }
+   | DEFAULT   { $$ = structDeclMode = declMode = defaultAccess; }
    ;
 
 member_access:
@@ -3110,10 +3318,10 @@ member_access:
    ;
 
 declaration:
-         declaration_specifiers ';'                       { $$ = MkDeclaration($1, null); $$.loc = @$; }
-       | declaration_specifiers init_declarator_list ';'  { $$ = MkDeclaration($1, $2); $$.loc = @$; }
-   | instantiation_named ';'                          { $$ = MkDeclarationInst($1); $$.loc = @$; }
-   | declaration_error ';'                          {}
+         declaration_specifiers ';'                       { $$ = MkDeclaration($1, null); $$.loc = @$; structDeclMode = defaultDeclMode; }
+       | declaration_specifiers init_declarator_list ';'  { $$ = MkDeclaration($1, $2); $$.loc = @$; structDeclMode = defaultDeclMode; }
+   | instantiation_named ';'                          { $$ = MkDeclarationInst($1); $$.loc = @$; structDeclMode = defaultDeclMode; }
+   | declaration_error ';'                            { $$ = $1; structDeclMode = defaultDeclMode; }
        ;
 
 external_guess_declaration:
@@ -3123,7 +3331,7 @@ external_guess_declaration:
 
    | external_guess_instantiation_named ';'                          { $$ = MkDeclarationInst($1); $$.loc = @$; }
    | DEFINE identifier '=' conditional_expression ';' { $$ = MkDeclarationDefine($2, $4); $$.loc = @$; }
-   | STATIC DEFINE identifier '=' conditional_expression ';' { declMode = staticAccess; $$ = MkDeclarationDefine($3, $5); $$.loc = @$; }
+   | STATIC DEFINE identifier '=' conditional_expression ';' { structDeclMode = declMode = staticAccess; $$ = MkDeclarationDefine($3, $5); $$.loc = @$; }
        ;
 
 external_guess_declaration_error:
@@ -3131,40 +3339,40 @@ external_guess_declaration_error:
        ;
 
 declaration_error:
-     declaration_specifiers error                       { $$ = MkDeclaration($1, null); $$.loc = @$; }
-   | declaration_error error {}
+     declaration_specifiers error                       { $$ = MkDeclaration($1, null); $$.loc = @$; structDeclMode = defaultDeclMode; }
+   | declaration_error error                            { structDeclMode = defaultDeclMode;  }
 
-   | instantiation_named_error error                   { $$ = MkDeclarationInst($1); $$.loc = @$; }
-   | instantiation_named error                         { $$ = MkDeclarationInst($1); $$.loc = @$; }
-   | declaration_specifiers init_declarator_list_error  { $$ = MkDeclaration($1, $2); $$.loc = @$; }
+   | instantiation_named_error error                   { $$ = MkDeclarationInst($1); $$.loc = @$; structDeclMode = defaultDeclMode; }
+   | instantiation_named error                         { $$ = MkDeclarationInst($1); $$.loc = @$; structDeclMode = defaultDeclMode; }
+   | declaration_specifiers init_declarator_list_error  { $$ = MkDeclaration($1, $2); $$.loc = @$; structDeclMode = defaultDeclMode; }
    ;
 
 declaration_list:
          declaration                       { $$ = MkList(); ListAdd($$, $1); /*declMode = defaultDeclMode;*/ }
-       | declaration_list declaration      { ListAdd($1, $2); /*declMode = defaultDeclMode; */}
-   | declaration_list_error declaration      { ListAdd($1, $2); /*declMode = defaultDeclMode; */}
-   | declaration_list error ';'       { }
+       | declaration_list declaration      { $$ = $1; ListAdd($1, $2); /*declMode = defaultDeclMode; */}
+   | declaration_list_error declaration      { $$ = $1; ListAdd($1, $2); /*declMode = defaultDeclMode; */}
+   | declaration_list error ';'       { $$ = $1; }
        ;
 
 declaration_list_error:
     declaration_error                       { $$ = MkList(); ListAdd($$, $1); }
-   | declaration_list declaration_error { ListAdd($1, $2); }
+   | declaration_list declaration_error { $$ = $1; ListAdd($1, $2); }
        ;
 
 statement_list:
          statement                         { $$ = MkList(); ListAdd($$, $1); }
-       | statement_list statement          { ListAdd($1, $2); }
-   | statement_list_error statement          { ListAdd($1, $2); }
+       | statement_list statement          { $$ = $1; ListAdd($1, $2); }
+   | statement_list_error statement          { $$ = $1; ListAdd($1, $2); }
        ;
 
 statement_list_error:
      statement_error                   { $$ = MkList(); ListAdd($$, $1); }
-   | statement_list statement_error          { ListAdd($1, $2); }
-   | statement_list_error statement_error          { ListAdd($1, $2); }
-   | statement_list declaration              { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; yyerror(); ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
-   | statement_list_error declaration        { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; yyerror(); ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
-   | statement_list declaration_error        { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; yyerror(); ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
-   | statement_list_error declaration_error  { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; yyerror(); ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
+   | statement_list statement_error          { $$ = $1; ListAdd($1, $2); }
+   | statement_list_error statement_error          { $$ = $1; ListAdd($1, $2); }
+   | statement_list declaration              { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; Compiler_Warning(C89_DECL_WARNING); $$ = $1; ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
+   | statement_list_error declaration        { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; Compiler_Warning(C89_DECL_WARNING); $$ = $1; ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
+   | statement_list declaration_error        { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; Compiler_Warning(C89_DECL_WARNING); $$ = $1; ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
+   | statement_list_error declaration_error  { Statement stmt = MkBadDeclStmt($2); stmt.loc = @2; Compiler_Warning(C89_DECL_WARNING); $$ = $1; ListAdd($1, stmt); /*declMode = defaultDeclMode;*/ }
    ;
 
 compound_inside:
@@ -3182,17 +3390,17 @@ compound_inside_error:
    ;
 
 compound_start:
-    '{' { $<context>$ = PushContext(); } 
+    '{' { $<context>$ = PushContext(); }
     ;
 
-compound_statement: 
-   compound_statement_error '}'     { $$.loc = @$; }
+compound_statement:
+   compound_statement_error '}'     { $$ = $1; $$.loc = @$; }
        ;
 
-compound_statement_error: 
+compound_statement_error:
          compound_start compound_inside_error
       { $$ = $2; $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; }
-   |   compound_start 
+   |   compound_start
       { $$ = MkCompoundStmt(null, null); $$.compound.context = $<context>1; PopContext($<context>1); $$.loc = @$; $$.loc.end.charPos++; $$.loc.end.pos++; }
 
        | compound_start compound_inside
@@ -3223,16 +3431,16 @@ selection_statement_error:
 iteration_statement:
          WHILE '(' expression ')' statement           { $$ = MkWhileStmt($3, $5); $$.loc = @$; }
    | WHILE '(' expression_error statement     { $$ = MkWhileStmt($3, $4); $$.loc = @$; }
-   | WHILE '(' ')' statement     { $$ = MkWhileStmt(null, $4); $$.loc = @$; }
+   | WHILE '(' ')' statement     { yyerror(); $$ = MkWhileStmt(null, $4); $$.loc = @$; }
 
        | DO statement WHILE '(' expression ')' ';'     { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
    | DO statement WHILE '(' expression_error ';'     { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; }
 
        | FOR '(' expression_statement expression_statement ')' statement                   { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; }
-   | FOR '(' expression_statement ')' statement                   { $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
+   | FOR '(' expression_statement ')' statement                   { yyerror(); $$ = MkForStmt($3, null, null, $5); $$.loc = @$; }
        | FOR '(' expression_statement expression_statement expression ')' statement        { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; }
    | FOR '(' expression_statement expression_statement expression_error statement  { $$ = MkForStmt($3, $4, $5, $6 ); $$.loc = @$; }
-   | FOR '(' ')' statement  { $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
+   | FOR '(' ')' statement  { yyerror(); $$ = MkForStmt(null, null, null, $4); $$.loc = @$; }
 
    | FOR '(' identifier ':' expression ')' statement                   { $$ = MkForEachStmt($3, $5, null, $7); $$.loc = @$; }
    | FOR '(' identifier ':' expression ';' expression ')' statement    { $$ = MkForEachStmt($3, $5, $7, $9); $$.loc = @$; }
@@ -3243,26 +3451,32 @@ iteration_statement_error:
        FOR '(' expression_error error                                       { $$ = MkForStmt(MkExpressionStmt($3), null, null, null); $$.forStmt.init.loc = @3; $$.loc = @$; } |
        FOR '(' expression_statement error                                   { $$ = MkForStmt($3, null, null, null); $$.loc = @$; } |
        FOR '(' expression_statement expression_error error                  { $$ = MkForStmt($3, MkExpressionStmt($4), null, null); $$.loc = @$; $$.forStmt.check.loc = @4; } |
+   /* Useless rules due to conflicts
        FOR '(' expression_statement expression_statement error              { $$ = MkForStmt($3, $4, null, null); $$.loc = @$; } |
+   */
    FOR '(' expression_statement expression_statement expression_error   { $$ = MkForStmt($3, $4, $5, null); $$.loc = @$; } |
        FOR '(' expression_statement expression_statement ')' statement_error                   { $$ = MkForStmt($3, $4, null, $6); $$.loc = @$; } |
        FOR '(' expression_statement expression_statement expression ')' statement_error  { $$ = MkForStmt($3, $4, $5, $7); $$.loc = @$; } |
    FOR '(' expression_statement expression_statement expression_error statement_error  { $$ = MkForStmt($3, $4, $5, $6 ); $$.loc = @$; } |
 
-       DO statement WHILE '(' expression ')'     { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; } |
-       DO statement WHILE '(' expression      { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; } |
+       DO statement WHILE '(' expression ')'     { yyerror(); $$ = MkDoWhileStmt($2, $5); $$.loc = @$; } |
+       DO statement WHILE '(' expression      { yyerror(); $$ = MkDoWhileStmt($2, $5); $$.loc = @$; } |
    DO statement WHILE '(' expression_error      { $$ = MkDoWhileStmt($2, $5); $$.loc = @$; } |
        DO statement WHILE '(' { $$ = MkDoWhileStmt($2, null); $$.loc = @$; } |
-   DO statement WHILE { $$ = MkDoWhileStmt($2, null); $$.loc = @$; } |
-       DO statement { $$ = MkDoWhileStmt($2, null); $$.loc = @$; } |
-   DO { $$ = MkDoWhileStmt(null, null); $$.loc = @$; } |
+   DO statement WHILE { yyerror(); $$ = MkDoWhileStmt($2, null); $$.loc = @$; } |
+       DO statement { yyerror(); $$ = MkDoWhileStmt($2, null); $$.loc = @$; } |
+   DO { yyerror(); $$ = MkDoWhileStmt(null, null); $$.loc = @$; } |
 
 
    WHILE error           { $$ = MkWhileStmt(null, null); $$.loc = @$; } |
+   /* Useless rules due to conflicts
        WHILE '(' error           { $$ = MkWhileStmt(null, null); $$.loc = @$; } |
+   */
    WHILE '(' ')' error           { $$ = MkWhileStmt(null, null); $$.loc = @$; } |
        WHILE '(' expression_error           { $$ = MkWhileStmt($3, null); $$.loc = @$; } |
+   /* Useless rules due to conflicts
    WHILE '(' expression_error error          { $$ = MkWhileStmt($3, null); $$.loc = @$; } |
+   */
        WHILE '(' expression ')' statement_error           { $$ = MkWhileStmt($3, $5); $$.loc = @$; } |
    WHILE '(' expression_error statement_error     { $$ = MkWhileStmt($3, $4 ); $$.loc = @$; }
 
@@ -3289,7 +3503,10 @@ jump_statement_error:
 
 function_definition:
          external_guess_declaration_specifiers declarator_function declaration_list compound_statement      { $$ = MkFunction($1, $2, $3); ProcessFunctionBody($$, $4); $$.loc = @$; }
-       | external_guess_declaration_specifiers declarator_function compound_statement                       
+       | external_guess_declaration_specifiers declarator_function compound_statement
+       { $$ = MkFunction($1, $2, null); ProcessFunctionBody($$, $3); $$.loc = @$; }
+       | external_guess_declaration_specifiers declarator_function_type_ok declaration_list compound_statement      { $$ = MkFunction($1, $2, $3); ProcessFunctionBody($$, $4); $$.loc = @$; }
+       | external_guess_declaration_specifiers declarator_function_type_ok compound_statement
        { $$ = MkFunction($1, $2, null); ProcessFunctionBody($$, $3); $$.loc = @$; }
 
        | declarator_function declaration_list compound_statement                             { $$ = MkFunction(null, $1, $2); ProcessFunctionBody($$, $3); $$.loc = @$; }
@@ -3298,14 +3515,16 @@ function_definition:
 function_definition_error:
      external_guess_declaration_specifiers declarator_function declaration_list compound_statement_error      { $$ = MkFunction($1, $2, $3); ProcessFunctionBody($$, $4); $$.loc = @$; $$.loc.end = $4.loc.end; }
        | external_guess_declaration_specifiers declarator_function compound_statement_error                       { $$ = MkFunction($1, $2, null); ProcessFunctionBody($$, $3); $$.loc = @$; $$.loc.end = $3.loc.end; }
+   | external_guess_declaration_specifiers declarator_function_type_ok declaration_list compound_statement_error      { $$ = MkFunction($1, $2, $3); ProcessFunctionBody($$, $4); $$.loc = @$; $$.loc.end = $4.loc.end; }
+       | external_guess_declaration_specifiers declarator_function_type_ok compound_statement_error                       { $$ = MkFunction($1, $2, null); ProcessFunctionBody($$, $3); $$.loc = @$; $$.loc.end = $3.loc.end; }
        | declarator_function declaration_list compound_statement_error                             { $$ = MkFunction(null, $1, $2); ProcessFunctionBody($$, $3); $$.loc = @$; $$.loc.end = $3.loc.end; }
        | declarator_function compound_statement_error                                              { $$ = MkFunction(null, $1, null); ProcessFunctionBody($$, $2); $$.loc = @$; $$.loc.end = $2.loc.end; }
    ;
 
 string_literal:
    STRING_LITERAL { $$ = CopyString(yytext); }
-   | string_literal STRING_LITERAL 
-   { 
+   | string_literal STRING_LITERAL
+   {
       int len1 = strlen($1);
       int len2 = strlen(yytext);
       $$ = new byte[len1-1 + len2-1 + 1];
@@ -3316,64 +3535,89 @@ string_literal:
    ;
 
 external_declaration:
-         function_definition { $$ = MkExternalFunction($1); $$.loc = @$; $1.declMode = declMode; declMode = defaultDeclMode; }
-   | class               
-      { $$ = MkExternalClass($1);  $$.loc = @$; $1.declMode = (declMode != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; }
+         function_definition { $$ = MkExternalFunction($1); $$.loc = @$; $1.declMode = declMode; structDeclMode = declMode = defaultDeclMode; }
+   | class
+      { $$ = MkExternalClass($1);  $$.loc = @$; $1.declMode = (declMode != defaultAccess) ? declMode : privateAccess; structDeclMode = declMode = defaultDeclMode; }
 
    | external_guess_declaration_specifiers class
-      { $$ = MkExternalClass($2);  $$.loc = @$; $2.declMode = (declMode != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; FreeList($1, FreeSpecifier); }
+      { $$ = MkExternalClass($2);  $$.loc = @$; $2.declMode = (declMode != defaultAccess) ? declMode : privateAccess; structDeclMode = declMode = defaultDeclMode; FreeList($1, FreeSpecifier); }
 
        | external_guess_declaration
-      { $$ = MkExternalDeclaration($1);  $$.loc = @$; $1.declMode = declMode; declMode = defaultDeclMode; }
+      { $$ = MkExternalDeclaration($1);  $$.loc = @$; $1.declMode = declMode; structDeclMode = declMode = defaultDeclMode; }
    | IMPORT string_literal { $$ = MkExternalImport($2, normalImport, (declMode != defaultAccess) ? declMode : privateAccess);  $$.loc = @$; }
    | IMPORT STATIC string_literal { $$ = MkExternalImport($3, staticImport, (declMode != defaultAccess) ? declMode : privateAccess);  $$.loc = @$; }
-   | IMPORT identifier string_literal { if(!strcmp($2.string, "remote")) { $$ = MkExternalImport($3, remoteImport, (declMode != defaultAccess) ? declMode : privateAccess);  $$.loc = @$; } else yyerror(); FreeIdentifier($2); }
-   
+   | IMPORT identifier string_literal
+   {
+      bool isRemote = !strcmp($2.string, "remote");
+      $$ = MkExternalImport($3, isRemote ? remoteImport : normalImport, (declMode != defaultAccess) ? declMode : privateAccess);
+      $$.loc = @$;
+      FreeIdentifier($2);
+      if(!isRemote)
+         yyerror();
+   }
+
    | ';' { $$ = null; }
 
-       | declaration_mode function_definition { $$ = MkExternalFunction($2); $$.loc = @$; $2.declMode = $1; declMode = defaultDeclMode; }
-   | declaration_mode class               
-      { $$ = MkExternalClass($2);  $$.loc = @$; $2.declMode = ($1 != defaultAccess) ? $1 : privateAccess; declMode = defaultDeclMode; }
-       | declaration_mode external_guess_declaration         { $$ = MkExternalDeclaration($2); $$.loc = @$; $2.declMode = $1; declMode = defaultDeclMode; }
-   | declaration_mode IMPORT string_literal { $$ = MkExternalImport($3, normalImport, ($1 != defaultAccess) ? $1 : privateAccess);  $$.loc = @$; declMode = defaultDeclMode; }
-   | declaration_mode IMPORT STATIC string_literal { $$ = MkExternalImport($4, staticImport, ($1 != defaultAccess) ? $1 : privateAccess);  $$.loc = @$; declMode = defaultDeclMode; }
-   | declaration_mode IMPORT identifier string_literal { if(!strcmp($3.string, "remote")) { $$ = MkExternalImport($4, remoteImport, ($1 != defaultAccess) ? $1 : privateAccess);  $$.loc = @$; FreeIdentifier($3); } else yyerror();  declMode = defaultDeclMode; }
+       | declaration_mode function_definition { $$ = MkExternalFunction($2); $$.loc = @$; $2.declMode = $1; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode class
+      { $$ = MkExternalClass($2);  $$.loc = @$; $2.declMode = ($1 != defaultAccess) ? $1 : privateAccess; structDeclMode = declMode = defaultDeclMode; }
+       | declaration_mode external_guess_declaration         { $$ = MkExternalDeclaration($2); $$.loc = @$; $2.declMode = $1; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode IMPORT string_literal { $$ = MkExternalImport($3, normalImport, ($1 != defaultAccess) ? $1 : privateAccess);  $$.loc = @$; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode IMPORT STATIC string_literal { $$ = MkExternalImport($4, staticImport, ($1 != defaultAccess) ? $1 : privateAccess);  $$.loc = @$; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode IMPORT identifier string_literal
+   {
+      bool isRemote = !strcmp($3.string, "remote");
+      $$ = MkExternalImport($4, isRemote ? remoteImport : normalImport, ($1 != defaultAccess) ? $1 : privateAccess);
+      $$.loc = @$;
+      FreeIdentifier($3);
+      structDeclMode = declMode = defaultDeclMode;
+      if(!isRemote)
+         yyerror();
+   }
    | declaration_mode ':' { defaultDeclMode = $1; $$ = null; }
    | STATIC ':' { defaultDeclMode = staticAccess; $$ = null; }
    | NAMESPACE identifier { $$ = MkExternalNameSpace($2); $$.loc = @$; }
    | NAMESPACE strict_type { $$ = MkExternalNameSpace(MkIdentifier($2.name)); FreeSpecifier($2); $$.loc = @$; }
-   | dbtable_definition { $$ = MkExternalDBTable($1); $$.loc = @$;  $1.declMode = (declMode != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; }
-   | declaration_mode  dbtable_definition { $$ = MkExternalDBTable($2); $$.loc = @$;  $2.declMode = ($1 != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; }
+   | dbtable_definition { $$ = MkExternalDBTable($1); $$.loc = @$;  $1.declMode = (declMode != defaultAccess) ? declMode : privateAccess; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode  dbtable_definition { $$ = MkExternalDBTable($2); $$.loc = @$;  $2.declMode = ($1 != defaultAccess) ? declMode : privateAccess; structDeclMode = declMode = defaultDeclMode; }
    ;
 
 external_declaration_error:
-     class_error               { $$ = MkExternalClass($1);  $$.loc = $1.loc; $1.declMode = (declMode != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; }
-   | external_guess_declaration_specifiers class_error               { $$ = MkExternalClass($2);  $$.loc = $2.loc; $2.declMode = (declMode != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; }
-   | function_definition_error { $$ = MkExternalFunction($1); $$.loc = $1.loc;  $1.declMode = declMode; declMode = defaultDeclMode; }
+     class_error               { yyerror(); $$ = MkExternalClass($1);  $$.loc = $1.loc; $1.declMode = (declMode != defaultAccess) ? declMode : privateAccess; structDeclMode = declMode = defaultDeclMode; }
+   | external_guess_declaration_specifiers class_error
+   {
+      yyerror();
+      FreeList($1, FreeSpecifier);
+      $$ = MkExternalClass($2);
+      $$.loc = $2.loc;
+      $2.declMode = (declMode != defaultAccess) ? declMode : privateAccess;
+      structDeclMode = declMode = defaultDeclMode;
+   }
+   | function_definition_error { yyerror(); $$ = MkExternalFunction($1); $$.loc = $1.loc;  $1.declMode = declMode; structDeclMode = declMode = defaultDeclMode; }
 
-   | declaration_mode class_error               { $$ = MkExternalClass($2);  $$.loc = $2.loc; $2.declMode = ($1 != defaultAccess) ? $1 : privateAccess; declMode = defaultDeclMode; }
-   | declaration_mode function_definition_error { $$ = MkExternalFunction($2); $$.loc = $2.loc; $2.declMode = $1; declMode = defaultDeclMode; }
+   | declaration_mode class_error               { yyerror(); $$ = MkExternalClass($2);  $$.loc = $2.loc; $2.declMode = ($1 != defaultAccess) ? $1 : privateAccess; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode function_definition_error { yyerror(); $$ = MkExternalFunction($2); $$.loc = $2.loc; $2.declMode = $1; structDeclMode = declMode = defaultDeclMode; }
 
        | external_guess_declaration_error
-      { $$ = MkExternalDeclaration($1);  $$.loc = @$; $1.declMode = declMode; declMode = defaultDeclMode; }
-   | declaration_mode external_guess_declaration_error         { $$ = MkExternalDeclaration($2); $$.loc = @$; $2.declMode = $1; declMode = defaultDeclMode; }
+      { yyerror(); $$ = MkExternalDeclaration($1);  $$.loc = @$; $1.declMode = declMode; structDeclMode = declMode = defaultDeclMode; }
+   | declaration_mode external_guess_declaration_error         { yyerror(); $$ = MkExternalDeclaration($2); $$.loc = @$; $2.declMode = $1; structDeclMode = declMode = defaultDeclMode; }
    ;
 
 translation_unit_error:
      external_declaration_error                    { $$ = MkList(); ListAdd($$, $1); ast = $$; }
-   | translation_unit external_declaration_error   { ListAdd($1, $2); }
-   | translation_unit_error external_declaration_error   { ListAdd($1, $2); }
+   | translation_unit external_declaration_error   { $$ = $1; ListAdd($1, $2); }
+   | translation_unit_error external_declaration_error   { $$ = $1; ListAdd($1, $2); }
    | translation_unit error
    | translation_unit_error error
        ;
 
 translation_unit:
          external_declaration                    { $$ = MkList(); ListAdd($$, $1); ast = $$; }
-       | translation_unit external_declaration   { ListAdd($1, $2); }
-   | translation_unit_error class  
-      { External _class = MkExternalClass($2); ListAdd($1, _class); _class.loc = @2;  $2.declMode = (declMode != defaultAccess) ? declMode : privateAccess; declMode = defaultDeclMode; }
+       | translation_unit external_declaration   { $$ = $1; ListAdd($1, $2); }
+   | translation_unit_error class
+      { External _class = MkExternalClass($2); $$ = $1; ListAdd($1, _class); _class.loc = @2;  $2.declMode = (declMode != defaultAccess) ? declMode : privateAccess; structDeclMode = declMode = defaultDeclMode; }
    | translation_unit_error declaration_mode class
-      { External _class = MkExternalClass($3); ListAdd($1, _class); _class.loc = @3;  $3.declMode = ($2 != defaultAccess) ? $2 : privateAccess; declMode = defaultDeclMode; }
+      { External _class = MkExternalClass($3); $$ = $1; ListAdd($1, _class); _class.loc = @3;  $3.declMode = ($2 != defaultAccess) ? $2 : privateAccess; structDeclMode = declMode = defaultDeclMode; }
        ;
 
 thefile:
@@ -3383,8 +3627,8 @@ thefile:
    ;
 
 dbtable_definition:
-     DBTABLE string_literal identifier   '{' dbfield_definition_list '}' { Symbol symbol = DeclClassAddNameSpace(globalContext.nextID++, $3.string); FreeIdentifier($3); $$ = MkDBTableDef($2, symbol, $5); }
-   | DBTABLE string_literal strict_type  '{' dbfield_definition_list '}' { Symbol symbol = DeclClass(globalContext.nextID++, $3.name); FreeSpecifier($3); $$ = MkDBTableDef($2, symbol, $5); }
+     DBTABLE string_literal identifier   '{' dbfield_definition_list '}' { Symbol symbol = DeclClassAddNameSpace($3._class, $3.string); FreeIdentifier($3); $$ = MkDBTableDef($2, symbol, $5); }
+   | DBTABLE string_literal strict_type  '{' dbfield_definition_list '}' { Symbol symbol = DeclClass($3.nsSpec, $3.name); FreeSpecifier($3); $$ = MkDBTableDef($2, symbol, $5); }
    | DBTABLE string_literal '{' dbfield_definition_list '}' { $$ = MkDBTableDef($2, null, $4); }
    ;
 
@@ -3416,7 +3660,7 @@ dbfield_definition_list:
    ;
 
 database_open:
-   DATABASE_OPEN '(' assignment_expression ',' assignment_expression ')'     { $$ = MkExpDBOpen($3, $5); }      
+   DATABASE_OPEN '(' assignment_expression ',' assignment_expression ')'     { $$ = MkExpDBOpen($3, $5); }
    ;
 
 dbfield: