* ILParser.jay: Add module refs, allow them to be referenced.
[mono.git] / mcs / ilasm / parser / ILParser.jay
index 48080ce6bba4347d91f6732ced2047bf0adbf63d..886f47990a93a1012a8fbb9d239ca671e07883d8 100644 (file)
@@ -18,8 +18,18 @@ namespace Mono.ILASM {
 \r
                private CodeGen codegen;\r
 \r
-               public ILParser (CodeGen codegen) {\r
+               private bool is_value_class;\r
+               private bool is_enum_class;\r
+                private bool pinvoke_info;\r
+                private string pinvoke_mod;\r
+                private string pinvoke_meth;\r
+                private PEAPI.PInvokeAttr pinvoke_attr;\r
+                private ILTokenizer tokenizer;\r
+                                \r
+               public ILParser (CodeGen codegen, ILTokenizer tokenizer)\r
+                {\r
                        this.codegen = codegen;\r
+                        this.tokenizer = tokenizer;\r
                }\r
 \r
                public CodeGen CodeGen {\r
@@ -39,6 +49,9 @@ namespace Mono.ILASM {
 /* SQSTRING - single quoted string */\r
 %token SQSTRING\r
 \r
+/* COMP_NAME - A name with dots */\r
+%token COMP_NAME\r
+\r
 /* INT32 - 32 bit integer */\r
 %token INT32\r
 \r
@@ -425,6 +438,7 @@ vtfixup_decl                : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET
                        ;\r
 \r
 vtfixup_attr           : /* EMPTY */\r
+                       | vtfixup_attr int32\r
                        | vtfixup_attr int64\r
                        | vtfixup_attr K_FROMUNMANAGED\r
                        | vtfixup_attr K_CALLMOSTDERIVED\r
@@ -453,20 +467,30 @@ class_head                : D_CLASS class_attr id formal_typars_clause extends_clause
                           {\r
                                 codegen.BeginTypeDef ((TypeAttr) $2, (string) $3, \r
                                                $5 as IClassRef, $6 as ArrayList, null);\r
+                               \r
+                               if (is_value_class)\r
+                                       codegen.CurrentTypeDef.MakeValueClass ();\r
+                               if (is_enum_class)\r
+                                       codegen.CurrentTypeDef.MakeEnumClass ();\r
 \r
                                 if ($4 != null) {\r
                                         ArrayList typars_list = (ArrayList) $4;\r
                                         foreach (string id in typars_list)\r
                                                 codegen.CurrentTypeDef.AddGenericParam (id);\r
-                                }\r
-                                \r
+                                }                                \r
                           }\r
                        ;\r
 \r
 class_attrs            : class_attrs class_attr\r
                        ;\r
 \r
-class_attr             : /* EMPTY */                           { $$ = new TypeAttr (); }\r
+class_attr             : /* EMPTY */                           \r
+                         { \r
+                               // Reset some flags\r
+                               is_value_class = false;\r
+                               is_enum_class = false;\r
+                               $$ = new TypeAttr ();\r
+                         }\r
                        | class_attr K_PUBLIC                   { $$ = (TypeAttr)$1 | TypeAttr.Public; }        \r
                        | class_attr K_PRIVATE                  { $$ = (TypeAttr)$1 | TypeAttr.Private; }\r
                        | class_attr K_NESTED K_PRIVATE         { $$ = (TypeAttr)$1 | TypeAttr.NestedPrivate; }\r
@@ -475,8 +499,9 @@ class_attr          : /* EMPTY */                           { $$ = new TypeAttr (); }
                        | class_attr K_NESTED K_ASSEMBLY        { $$ = (TypeAttr)$1 | TypeAttr.NestedAssembly;}\r
                        | class_attr K_NESTED K_FAMANDASSEM     { $$ = (TypeAttr)$1 | TypeAttr.NestedFamAndAssem; }\r
                        | class_attr K_NESTED K_FAMORASSEM      { $$ = (TypeAttr)$1 | TypeAttr.NestedFamOrAssem; }\r
-                       | class_attr K_VALUE                    {  }\r
-                       | class_attr K_ENUM                     {  }\r
+                       | class_attr K_VALUE                    { is_value_class = true; }\r
+                       | class_attr K_ENUM                     { is_enum_class = true; is_value_class = true;\r
+                         }\r
                        | class_attr K_INTERFACE                { $$ = (TypeAttr)$1 | TypeAttr.Interface; }\r
                        | class_attr K_SEALED                   { $$ = (TypeAttr)$1 | TypeAttr.Sealed; }\r
                        | class_attr K_ABSTRACT                 { $$ = (TypeAttr)$1 | TypeAttr.Abstract; }\r
@@ -576,15 +601,22 @@ slashed_name              : comp_name
                           }\r
                        ;\r
 \r
-class_ref              : OPEN_BRACKET file_name CLOSE_BRACKET slashed_name\r
+class_ref              : OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name\r
                           {\r
                                 if (codegen.IsThisAssembly ((string) $2)) {\r
-                                        $$ = new TypeRef ((string) $4, null);\r
+                                        $$ = new TypeRef ((string) $4, false, null);\r
+                                } else {\r
+                                        $$ = codegen.ExternTable.GetTypeRef ((string) $2, (string) $4, false);\r
+                                }\r
+                          }\r
+                       | OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET slashed_name\r
+                          {\r
+                                if (codegen.IsThisModule ((string) $3)) {\r
+                                        $$ = new TypeRef ((string) $5, false, null);\r
                                 } else {\r
-                                        $$ = new ExternTypeRef ((string) $2, (string) $4);\r
+                                        $$ = codegen.ExternTable.GetModuleTypeRef ((string) $3, (string) $5, false);\r
                                 }\r
                           }\r
-                       | OPEN_BRACKET D_MODULE file_name CLOSE_BRACKET slashed_name\r
                        | slashed_name\r
                           {\r
                                 PrimitiveTypeRef prim = PrimitiveTypeRef.GetPrimitiveType ((string) $1);\r
@@ -592,7 +624,7 @@ class_ref           : OPEN_BRACKET file_name CLOSE_BRACKET slashed_name
                                 if (prim != null)\r
                                         $$ = prim;\r
                                 else\r
-                                        $$ = new TypeRef ((string) $1, null);\r
+                                        $$ = new TypeRef ((string) $1, false, null);\r
                           }\r
                       \r
                        ;\r
@@ -621,8 +653,30 @@ class_decl         : method_all
                           {\r
                                 codegen.CurrentTypeDef.SetPack ((int) $2);\r
                           }\r
-                       | D_OVERRIDE type_spec DOUBLE_COLON method_name\r
-                         K_WITH call_conv type type_spec DOUBLE_COLON method_name\r
+                       | D_OVERRIDE type_spec DOUBLE_COLON method_name K_WITH call_conv type\r
+                          type_spec DOUBLE_COLON method_name type_list\r
+                          {\r
+                                //\r
+                                // My copy of the spec didn't have a type_list but\r
+                                // it seems pretty crucial\r
+                                //\r
+                                ITypeRef owner = (ITypeRef) $2;\r
+                                ArrayList arg_list = (ArrayList) $11;\r
+                                ITypeRef[] param_list;\r
+                                IMethodRef decl;\r
+\r
+                                if (arg_list != null)\r
+                                        param_list = (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef));\r
+                                else\r
+                                        param_list = new ITypeRef[0];\r
+\r
+                                decl = owner.GetMethodRef ((ITypeRef) $7,\r
+                                        (CallConv) $6, (string) $4, param_list);\r
+\r
+                                string sig = MethodDef.CreateSignature ((string) $10,\r
+                                                                        param_list);\r
+                                codegen.CurrentTypeDef.AddOverride (sig, decl);                                        \r
+                          }\r
                          OPEN_PARENS sig_args CLOSE_PARENS\r
                        | language_decl\r
                         | constraint_decl\r
@@ -642,55 +696,82 @@ type                      : K_CLASS class_ref
                           }\r
                        | K_VALUE K_CLASS class_ref\r
                           {\r
-                                $$ = $3;\r
+                               IClassRef class_ref = (IClassRef) $3;\r
+                               class_ref.MakeValueClass ();\r
+                                $$ = class_ref;\r
                           }\r
-                       | K_VALUETYPE OPEN_BRACKET file_name CLOSE_BRACKET slashed_name\r
+                       | K_VALUETYPE OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name\r
                           {\r
-                                $$ = new ExternTypeRef ((string) $3, (string) $5);\r
+                                ExternTypeRef ext_ref = codegen.ExternTable.GetTypeRef ((string) $3, (string) $5, false);\r
+                                ExternTypeRefInst inst = new ExternTypeRefInst (ext_ref, true);\r
+                                $$ = inst;\r
                           }\r
                         | K_VALUETYPE slashed_name\r
                           {\r
-                                $$ = new TypeRef ((string) $2, null);\r
+                                TypeRef t_ref = new TypeRef ((string) $2, true, null);\r
+                                t_ref.MakeValueClass ();\r
+                                $$ = t_ref;\r
                           }\r
                        | type OPEN_BRACKET CLOSE_BRACKET\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 base_type.MakeArray ();\r
+                                $$ = base_type;\r
                           }\r
                        | type OPEN_BRACKET bounds CLOSE_BRACKET\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 ArrayList bound_list = (ArrayList) $3;\r
                                 base_type.MakeBoundArray (bound_list);\r
+                                $$ = base_type;\r
                           }\r
                        | type AMPERSAND\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 base_type.MakeManagedPointer ();\r
+                                $$ = base_type;\r
                           }\r
                        | type STAR\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 base_type.MakeUnmanagedPointer ();\r
+                                $$ = base_type;\r
                           }\r
                        | type K_PINNED\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 base_type.MakePinned ();\r
+                                $$ = base_type;\r
                           }\r
                        | type K_MODREQ OPEN_PARENS class_ref CLOSE_PARENS\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 IClassRef class_ref = (IClassRef) $4;\r
                                 base_type.MakeCustomModified (codegen,\r
-                                        CustomModifier.modopt, class_ref);    \r
+                                        CustomModifier.modopt, class_ref);\r
+                                $$ = base_type;\r
                           }\r
                        | type K_MODOPT OPEN_PARENS class_ref CLOSE_PARENS\r
                           {\r
                                 ITypeRef base_type = (ITypeRef) $1;\r
+                                if (base_type is ExternTypeRef)\r
+                                        base_type = ((ExternTypeRef) base_type).Clone ();\r
                                 IClassRef class_ref = (IClassRef) $4;\r
                                 base_type.MakeCustomModified (codegen,\r
-                                        CustomModifier.modopt, class_ref);    \r
+                                        CustomModifier.modopt, class_ref);\r
+                                $$ = base_type;\r
                           }\r
                        | K_METHOD call_conv type STAR OPEN_PARENS sig_args CLOSE_PARENS\r
                        | K_TYPEDREF\r
@@ -702,6 +783,10 @@ type                       : K_CLASS class_ref
                           {\r
                                 $$ = new PrimitiveTypeRef (PrimitiveType.Char, "System.Char");\r
                           }\r
+                       | K_WCHAR\r
+                         {\r
+                               $$ = new PrimitiveTypeRef (PrimitiveType.Char, "System.Char");\r
+                         }\r
                        | K_VOID\r
                           {\r
                                 $$ = new PrimitiveTypeRef (PrimitiveType.Void, "System.Void");\r
@@ -767,12 +852,12 @@ type                      : K_CLASS class_ref
                           }\r
                         | BANG BANG int32\r
                           {\r
-                                // access method type parameter by number\r
+                                MVar mvar = new MVar ((int) $3);\r
+                                $$ = new GenericTypeRef (mvar, $3.ToString ());\r
                           }\r
                         | K_CLASS slashed_name OPEN_ANGLE_BRACKET BANG int32 CLOSE_ANGLE_BRACKET\r
                           {\r
-                                // Just cheat for now\r
-                                $$ = new TypeRef ((string) $2, null);\r
+                                $$ = new TypeRef ((string) $2, false, null);\r
                           }\r
                         | K_CLASS slashed_name OPEN_ANGLE_BRACKET typars CLOSE_ANGLE_BRACKET\r
                           {\r
@@ -797,6 +882,10 @@ bounds                     : bound
                        ;\r
 \r
 bound                  : /* EMPTY */\r
+                          {\r
+                                // This is shortref for no lowerbound or size\r
+                                $$ = new DictionaryEntry (TypeRef.Ellipsis, TypeRef.Ellipsis);\r
+                          }\r
                        | ELLIPSIS\r
                           {\r
                                 // No lower bound or size\r
@@ -1054,11 +1143,11 @@ field_decl              : D_FIELD repeat_opt field_attr type id at_opt init_opt
                                 if ($2 != null) {\r
                                         field_def.SetOffset ((uint) $2);\r
                                 }\r
-                                /*\r
+\r
                                 if ($6 != null) {\r
-                                        field_def.AddDataValue ((DataConstant) $6);\r
+                                        field_def.AddDataValue ((string) $6);\r
                                 }\r
-                                */\r
+\r
                                 if ($7 != null) {\r
                                         field_def.SetValue ((Constant) $7);\r
                                 }\r
@@ -1137,8 +1226,7 @@ field_attr                : /* EMPTY */
 at_opt                 : /* EMPTY */\r
                        | K_AT id\r
                           {\r
-                                // TODO: Implement DataTable\r
-                                // $$ = new DataConstant (DataTable.GetOffset ((string) $2));\r
+                                $$ = $2;\r
                           }\r
                        ;\r
 \r
@@ -1163,7 +1251,7 @@ field_init                : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
                           }\r
                        | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS\r
                           {\r
-                                $$ = new DoubleConst (Convert.ToDouble (3));\r
+                                $$ = new DoubleConst (Convert.ToDouble ($3));\r
                           }\r
                        | K_INT64 OPEN_PARENS int64 CLOSE_PARENS\r
                           {\r
@@ -1171,16 +1259,20 @@ field_init              : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
                           }\r
                        | K_INT32 OPEN_PARENS int64 CLOSE_PARENS\r
                           {\r
-                                $$ = new IntConst (Convert.ToUInt32 ($3));\r
+                                $$ = new IntConst (Convert.ToInt32 ($3));\r
                           }\r
                        | K_INT16 OPEN_PARENS int64 CLOSE_PARENS\r
                           {\r
-                                $$ = new IntConst (Convert.ToUInt16 ($3));\r
+                                $$ = new IntConst (Convert.ToInt16 ($3));\r
                           }\r
                        | K_CHAR OPEN_PARENS int64 CLOSE_PARENS\r
                           {\r
                                 $$ = new CharConst (Convert.ToChar ($3));\r
                           }\r
+                       | K_WCHAR OPEN_PARENS int64 CLOSE_PARENS\r
+                         {\r
+                               $$ = new CharConst (Convert.ToChar ($3));\r
+                         }\r
                        | K_INT8 OPEN_PARENS int64 CLOSE_PARENS\r
                           {\r
                                 $$ = new IntConst (Convert.ToByte ($3));\r
@@ -1189,9 +1281,9 @@ field_init                : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
                           {\r
                                 $$ = new BoolConst ((bool) $3);\r
                           }\r
-                       | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS\r
+                       | K_BYTEARRAY bytes_list\r
                           {\r
-                                $$ = new ByteArrConst ((byte[]) $3);\r
+                                $$ = new ByteArrConst ((byte[]) $2);\r
                           }\r
                        | comp_qstring\r
                           {\r
@@ -1206,9 +1298,6 @@ field_init                : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
 \r
 data_decl              : data_head data_body\r
                           {\r
-                                /*\r
-                                Console.WriteLine ("Creating data decl: '{0}' '{1}'", $1, $2);\r
-\r
                                 DataDef datadef = (DataDef) $1;\r
                                 \r
                                 if ($2 is ArrayList) {\r
@@ -1222,7 +1311,7 @@ data_decl         : data_head data_body
                                 } else {\r
                                         datadef.PeapiConstant = (PEAPI.Constant) $2;\r
                                 }\r
-                                */\r
+                                codegen.AddDataDef (datadef);\r
                           }\r
                        ;\r
 \r
@@ -1245,23 +1334,44 @@ data_body               : OPEN_BRACE dataitem_list CLOSE_BRACE
                        ;\r
 \r
 dataitem_list          : dataitem\r
+                          {\r
+                                ArrayList dataitem_list = new ArrayList ();\r
+                                dataitem_list.Add ($1);\r
+                                $$ = dataitem_list;\r
+                          }\r
                        | dataitem_list COMMA dataitem\r
+                          {\r
+                                ArrayList list = (ArrayList) $1;\r
+                                list.Add ($3);\r
+                          }\r
                        ;\r
 \r
 dataitem               : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS\r
+                          {\r
+                                $$ = new StringConst ((string) $4);\r
+                          }\r
+                       | K_WCHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS\r
+                         {\r
+                               $$ = new StringConst ((string) $4);\r
+                         }\r
                        | AMPERSAND OPEN_PARENS id CLOSE_PARENS\r
-                       | K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
                           {\r
-                                $$ = new ByteArrConst ((byte[]) $4);\r
+                           //     DataDef def = codegen.CurrentTypeDef.GetDataDef ((string) $3);\r
+                           //     $$ = new AddressConstant ((DataConstant) def.PeapiConstant);\r
                           }\r
-                       | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS\r
+                       | K_BYTEARRAY ASSIGN bytes_list\r
                           {\r
-                                // ******** THIS IS NOT IN THE SPECIFICATION ******** //\r
                                 $$ = new ByteArrConst ((byte[]) $3);\r
                           }\r
+                       | K_BYTEARRAY bytes_list\r
+                          {\r
+                                // ******** THIS IS NOT IN THE SPECIFICATION ******** //\r
+                                $$ = new ByteArrConst ((byte[]) $2);\r
+                          }\r
                        | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt\r
                           {\r
-                                FloatConst float_const = new FloatConst ((float) $3);\r
+                                double d = (double) $3;\r
+                                FloatConst float_const = new FloatConst ((float) d);\r
 \r
                                 if ($5 != null)\r
                                         $$ = new RepeatedConstant (float_const, (int) $5);\r
@@ -1297,7 +1407,8 @@ dataitem          : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
                           }\r
                        | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
-                                IntConst int_const = new IntConst ((short) $3);\r
+                                int i = (int) $3;\r
+                                IntConst int_const = new IntConst ((short) i);\r
 \r
                                 if ($5 != null)\r
                                         $$ = new RepeatedConstant (int_const, (int) $5);\r
@@ -1306,7 +1417,8 @@ dataitem          : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
                           }\r
                        | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt\r
                           {\r
-                                IntConst int_const = new IntConst ((sbyte) $3);\r
+                                int i = (int) $3;\r
+                                IntConst int_const = new IntConst ((sbyte) i);\r
 \r
                                 if ($5 != null)\r
                                         $$ = new RepeatedConstant (int_const, (int) $5);\r
@@ -1382,6 +1494,17 @@ method_head              : D_METHOD meth_attr call_conv param_attr type method_name
                                         (ImplAttr) $11, (string) $6, (ITypeRef) $5,\r
                                         (ArrayList) $9);\r
                                 codegen.BeginMethodDef (methdef);\r
+\r
+                                if (pinvoke_info) {\r
+                                        methdef.AddPInvokeInfo (pinvoke_attr, pinvoke_mod, pinvoke_meth);\r
+                                        pinvoke_info = false;\r
+                                }\r
+\r
+                                if ($7 != null) {\r
+                                        ArrayList typars_list = (ArrayList) $7;\r
+                                        foreach (string id in typars_list)\r
+                                                methdef.AddGenericParam (id);\r
+                                }\r
                           }\r
                        | D_METHOD meth_attr call_conv param_attr type \r
                          K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS method_name\r
@@ -1405,24 +1528,43 @@ meth_attr               : /* EMPTY */                   { $$ = new MethAttr (); }
                        | meth_attr K_REQSECOBJ         { $$ = (MethAttr) $1 | MethAttr.RequireSecObject; }\r
                        | meth_attr K_SPECIALNAME       { $$ = (MethAttr) $1 | MethAttr.SpecialName; }\r
                        | meth_attr K_RTSPECIALNAME     { $$ = (MethAttr) $1 | MethAttr.RTSpecialName; }\r
+                        | meth_attr K_COMPILERCONTROLLED { /* Do nothing */ }\r
                        | meth_attr K_UNMANAGEDEXP      \r
                        | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring K_AS\r
                                comp_qstring pinv_attr CLOSE_PARENS\r
+                          {\r
+                                pinvoke_info = true;\r
+                                pinvoke_mod = (string) $4;\r
+                                pinvoke_meth = (string) $6;\r
+                                pinvoke_attr = (PInvokeAttr) $7;\r
+                          }\r
                        | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring pinv_attr CLOSE_PARENS\r
+                          {\r
+                                pinvoke_info = true;\r
+                                pinvoke_mod = (string) $4;\r
+                                pinvoke_meth = null;\r
+                                pinvoke_attr = (PInvokeAttr) $5;\r
+                          }\r
                        | meth_attr K_PINVOKEIMPL OPEN_PARENS pinv_attr CLOSE_PARENS\r
+                          {\r
+                                pinvoke_info = true;\r
+                                pinvoke_mod = null;\r
+                                pinvoke_meth = null;\r
+                                pinvoke_attr = (PInvokeAttr) $4;\r
+                          }\r
                        ;\r
 \r
-pinv_attr              : /* EMPTY */\r
-                       | pinv_attr K_NOMANGLE\r
-                       | pinv_attr K_ANSI\r
-                       | pinv_attr K_UNICODE\r
-                       | pinv_attr K_AUTOCHAR\r
-                       | pinv_attr K_LASTERR\r
-                       | pinv_attr K_WINAPI\r
-                       | pinv_attr K_CDECL\r
-                       | pinv_attr K_STDCALL\r
-                       | pinv_attr K_THISCALL\r
-                       | pinv_attr K_FASTCALL\r
+pinv_attr              : /* EMPTY */ { $$ = new PInvokeAttr (); }\r
+                       | pinv_attr K_NOMANGLE { $$ = (PInvokeAttr) $1 | PInvokeAttr.nomangle; }\r
+                       | pinv_attr K_ANSI { $$ = (PInvokeAttr) $1 | PInvokeAttr.ansi; }\r
+                       | pinv_attr K_UNICODE { $$ = (PInvokeAttr) $1 | PInvokeAttr.unicode; }\r
+                       | pinv_attr K_AUTOCHAR { $$ = (PInvokeAttr) $1 | PInvokeAttr.autochar; }\r
+                       | pinv_attr K_LASTERR { $$ = (PInvokeAttr) $1 | PInvokeAttr.lasterr; }\r
+                       | pinv_attr K_WINAPI { $$ = (PInvokeAttr) $1 | PInvokeAttr.winapi; }\r
+                       | pinv_attr K_CDECL { $$ = (PInvokeAttr) $1 | PInvokeAttr.cdecl; }\r
+                       | pinv_attr K_STDCALL { $$ = (PInvokeAttr) $1 | PInvokeAttr.stdcall; }\r
+                       | pinv_attr K_THISCALL { $$ = (PInvokeAttr) $1 | PInvokeAttr.thiscall; }\r
+                       | pinv_attr K_FASTCALL { $$ = (PInvokeAttr) $1 | PInvokeAttr.fastcall; }\r
                        ;\r
 \r
 method_name            : D_CTOR\r
@@ -1479,34 +1621,41 @@ sig_arg                 : param_attr type
                           }\r
                         | ELLIPSIS\r
                           {\r
-                                $$ = ParamDef.Ellipsis;\r
+                               $$ = new ParamDef ((ParamAttr) 0, "...", new SentinelTypeRef ());\r
+                                // $$ = ParamDef.Ellipsis;\r
                           }\r
                        | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS\r
                        | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id\r
                        ;\r
 \r
 type_list               : /* EMPTY */\r
+                          {\r
+                                $$ = new ArrayList (0);\r
+                          }\r
                         | ELLIPSIS\r
                           {\r
                                 ArrayList type_list = new ArrayList ();\r
-                                type_list.Add (TypeRef.Ellipsis);\r
+                                // type_list.Add (TypeRef.Ellipsis);\r
+                               type_list.Add (new SentinelTypeRef ());\r
                                 $$ = type_list;\r
                           }\r
                         | type_list COMMA ELLIPSIS\r
                           {\r
                                 ArrayList type_list = (ArrayList) $1;\r
-                                type_list.Add (TypeRef.Ellipsis);\r
+                                // type_list.Add (TypeRef.Ellipsis);\r
+                               type_list.Add (new SentinelTypeRef ());\r
+                               $$ = type_list;\r
                           }\r
-                        | type opt_id\r
+                        | param_attr type opt_id\r
                           {\r
                                 ArrayList type_list = new ArrayList ();\r
-                                type_list.Add ($1);\r
+                                type_list.Add ($2);\r
                                 $$ = type_list;\r
                           }\r
-                        | type_list COMMA type opt_id\r
+                        | type_list COMMA param_attr type opt_id\r
                           {\r
                                 ArrayList type_list = (ArrayList) $1;\r
-                                type_list.Add ($3);\r
+                                type_list.Add ($4);\r
                           }\r
                         ;\r
 \r
@@ -1543,10 +1692,18 @@ method_decl             : D_EMITBYTE int32
                                 codegen.CurrentMethodDef.EntryPoint ();\r
                           }\r
                        | D_ZEROINIT\r
+                          {\r
+                                codegen.CurrentMethodDef.ZeroInit ();\r
+                          }\r
                        | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET\r
                        | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id\r
                        | D_VTENTRY int32 COLON int32 \r
                        | D_OVERRIDE type_spec DOUBLE_COLON method_name\r
+                          {\r
+                                codegen.CurrentTypeDef.AddOverride (codegen.CurrentMethodDef,\r
+                                        (ITypeRef) $2, (string) $4);\r
+                                \r
+                          }\r
                        | scope_block\r
                        | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt\r
                        | id COLON\r
@@ -1604,18 +1761,21 @@ slot_num                : OPEN_BRACKET int32 CLOSE_BRACKET
                         ;\r
 \r
 type_spec              : class_ref\r
-                       | OPEN_BRACKET file_name CLOSE_BRACKET\r
+                       | OPEN_BRACKET slashed_name CLOSE_BRACKET\r
                           {\r
                                 // This is a reference to a global method in another\r
                                 // assembly. This is not supported in the MS version of ilasm\r
                           }\r
-                       | OPEN_BRACKET D_MODULE file_name CLOSE_BRACKET\r
+                       | OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET\r
+                          {\r
+\r
+                          }\r
                        | type\r
                        ;\r
 \r
 scope_block            : scope_block_begin method_decls CLOSE_BRACE\r
                           {\r
-                                $$ = new HandlerBlock ((int) $1,\r
+                                $$ = new HandlerBlock ((LabelInfo) $1,\r
                                         codegen.CurrentMethodDef.AddLabel ());\r
                           }\r
                        ;\r
@@ -1645,11 +1805,17 @@ try_block               : D_TRY scope_block
                           }\r
                        | D_TRY id K_TO id\r
                           {\r
-                                $$ = new TryBlock (new HandlerBlock ((string) $2, (string) $4));\r
+                               LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);\r
+                               LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4);\r
+                               \r
+                                $$ = new TryBlock (new HandlerBlock (from, to));\r
                           }\r
                        | D_TRY int32 K_TO int32\r
                          {\r
-                               $$ = new TryBlock (new HandlerBlock ((int) $2, (int) $4, true));\r
+                               LabelInfo from = codegen.CurrentMethodDef.AddLabel ((int) $2);\r
+                               LabelInfo to = codegen.CurrentMethodDef.AddLabel ((int) $4);\r
+                               \r
+                               $$ = new TryBlock (new HandlerBlock (from, to));\r
                          }\r
                        ;\r
 \r
@@ -1700,12 +1866,14 @@ filter_clause           : K_FILTER scope_block
                           }\r
                        | K_FILTER id\r
                           {\r
-                                FilterBlock fb = new FilterBlock (new HandlerBlock (null, (string) $2));\r
+                               LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);\r
+                                FilterBlock fb = new FilterBlock (new HandlerBlock (from, null));\r
                                 $$ = fb;\r
                           }\r
                        | K_FILTER int32\r
                          {\r
-                               FilterBlock fb = new FilterBlock (new HandlerBlock (-1, (int) $2, true));\r
+                               LabelInfo from = codegen.CurrentMethodDef.AddLabel ((int) $2);\r
+                               FilterBlock fb = new FilterBlock (new HandlerBlock (from, null));\r
                                $$ = fb;\r
                          }\r
                        ;\r
@@ -1715,12 +1883,18 @@ handler_block           : scope_block
                                 \r
                           }\r
                        | K_HANDLER id K_TO id\r
-                          {\r
-                                $$ = new HandlerBlock ((string) $2, (string) $4);\r
+                          {    \r
+                               LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);\r
+                               LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4);\r
+\r
+                                $$ = new HandlerBlock (from, to);\r
                           }\r
                        | K_HANDLER int32 K_TO int32\r
                          {\r
-                               $$ = new HandlerBlock ((int) $2, (int) $4, true);\r
+                               LabelInfo from = codegen.CurrentMethodDef.AddLabelRef ((string) $2);\r
+                               LabelInfo to = codegen.CurrentMethodDef.AddLabelRef ((string) $4);\r
+\r
+                               $$ = new HandlerBlock (from, to);\r
                          }\r
                        ;\r
 \r
@@ -1793,15 +1967,18 @@ instr                   : INSTR_NONE
                                         break;\r
                                 }\r
                           }\r
-                       | INSTR_R OPEN_PARENS bytes CLOSE_PARENS\r
+                       | INSTR_R bytes_list\r
                        | INSTR_BRTARGET int32\r
                           {\r
-                                // Need to add this to PEAPI        \r
+                               LabelInfo target = codegen.CurrentMethodDef.AddLabel ((int) $2);\r
+                                codegen.CurrentMethodDef.AddInstr (new BranchInstr ((BranchOp) $1,\r
+                                                                  target));  \r
                           }\r
                        | INSTR_BRTARGET id\r
                           {\r
+                               LabelInfo target = codegen.CurrentMethodDef.AddLabelRef ((string) $2);\r
                                 codegen.CurrentMethodDef.AddInstr (new BranchInstr ((BranchOp) $1,\r
-                                                                  (string) $2));\r
+                                                                  target));\r
                           }\r
                        | INSTR_METHOD method_ref\r
                           {\r
@@ -1833,8 +2010,18 @@ instr                    : INSTR_NONE
                                 if ((MiscInstr) $1 == MiscInstr.ldstr)\r
                                         codegen.CurrentMethodDef.AddInstr (new LdstrInstr ((string) $2));\r
                           }\r
-                       | INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
-                       | INSTR_STRING K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS               // ****** ADDED\r
+                       | INSTR_STRING K_BYTEARRAY ASSIGN bytes_list\r
+                          {\r
+                                byte[] bs = (byte[]) $4;\r
+                                if ((MiscInstr) $1 == MiscInstr.ldstr)\r
+                                        codegen.CurrentMethodDef.AddInstr (new LdstrInstr (bs));\r
+                          }\r
+                       | INSTR_STRING K_BYTEARRAY bytes_list\r
+                          {\r
+                                byte[] bs = (byte[]) $3;\r
+                                if ((MiscInstr) $1 == MiscInstr.ldstr)\r
+                                        codegen.CurrentMethodDef.AddInstr (new LdstrInstr (bs));\r
+                          }\r
                        | INSTR_SIG call_conv type OPEN_PARENS type_list CLOSE_PARENS\r
                           {\r
                                 ArrayList arg_list = (ArrayList) $5;\r
@@ -1843,7 +2030,7 @@ instr                     : INSTR_NONE
                                 if (arg_list != null)\r
                                         arg_array = (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef));\r
 \r
-                                codegen.CurrentMethodDef.AddInstr (new CalliInstr ((CallConv) $1,\r
+                                codegen.CurrentMethodDef.AddInstr (new CalliInstr ((CallConv) $2,\r
                                         (ITypeRef) $3, arg_array));\r
                           }     \r
                        | INSTR_TOK owner_type\r
@@ -1864,20 +2051,28 @@ instr                   : INSTR_NONE
                           }\r
                        ;\r
 \r
-method_ref             : call_conv type type_spec DOUBLE_COLON method_name \r
-                         OPEN_PARENS type_list CLOSE_PARENS\r
+method_ref             : call_conv type type_spec DOUBLE_COLON method_name\r
+                          OPEN_PARENS type_list CLOSE_PARENS \r
                           {\r
                                 ITypeRef owner = (ITypeRef) $3;\r
                                 ArrayList arg_list = (ArrayList) $7;\r
                                 ITypeRef[] param_list;\r
-  \r
+                                IMethodRef methref;\r
+\r
                                 if (arg_list != null)\r
                                         param_list = (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef));\r
                                 else\r
                                         param_list = new ITypeRef[0];\r
 \r
-                                $$ = owner.GetMethodRef ((ITypeRef) $2,\r
-                                        (CallConv) $1, (string) $5, param_list);\r
+                                if (owner.UseTypeSpec) {\r
+                                        methref = new TypeSpecMethodRef (owner, (ITypeRef) $2,\r
+                                                (CallConv) $1, (string) $5, param_list);\r
+                                } else {\r
+                                        methref = owner.GetMethodRef ((ITypeRef) $2,\r
+                                                (CallConv) $1, (string) $5, param_list);\r
+                                }\r
+\r
+                                $$ = methref;\r
                           }\r
                        | call_conv type method_name \r
                          OPEN_PARENS type_list CLOSE_PARENS\r
@@ -1893,6 +2088,36 @@ method_ref               : call_conv type type_spec DOUBLE_COLON method_name
                                 $$ = new GlobalMethodRef ((ITypeRef) $2, (CallConv) $1,\r
                                         (string) $3, param_list);\r
                           }\r
+                        | call_conv type type_spec DOUBLE_COLON method_name\r
+                          typars_clause OPEN_PARENS type_list CLOSE_PARENS \r
+                          {\r
+                                ITypeRef owner = (ITypeRef) $3;\r
+                                ArrayList arg_list = (ArrayList) $8;\r
+                                ITypeRef[] param_list;\r
+                                IMethodRef methref;\r
+\r
+                                if (arg_list != null)\r
+                                        param_list = (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef));\r
+                                else\r
+                                        param_list = new ITypeRef[0];\r
+\r
+                                if (owner.UseTypeSpec) {\r
+                                        methref = new TypeSpecMethodRef (owner, (ITypeRef) $2,\r
+                                                (CallConv) $1, (string) $5, param_list);\r
+                                } else {\r
+                                        methref = owner.GetMethodRef ((ITypeRef) $2,\r
+                                                (CallConv) $1, (string) $5, param_list);\r
+                                }\r
+\r
+                                if ($6 != null) {\r
+                                        ArrayList tp = (ArrayList) $6;\r
+                                        ITypeRef[] ta = (ITypeRef[]) tp.ToArray (typeof (ITypeRef));\r
+                                        \r
+                                        methref = new GenericMethodRef (methref, new GenericMethodSig (ta));\r
+                                }\r
+                                \r
+                                $$ = methref;\r
+                          }\r
                        ;\r
 \r
 labels                 : /* EMPTY */\r
@@ -2029,6 +2254,9 @@ prop_attr                 : /* EMPTY */
                           {\r
                                 $$ = (FeatureAttr) $1 | FeatureAttr.Specialname;\r
                           }\r
+                        | prop_attr K_INSTANCE\r
+                          {\r
+                          }\r
                        ;\r
 \r
 prop_decls             : /* EMPTY */\r
@@ -2057,15 +2285,15 @@ customattr_decl         : D_CUSTOM custom_type
                                 $$ = new CustomAttr ((IMethodRef) $2, null);\r
                           }\r
                        | D_CUSTOM custom_type ASSIGN comp_qstring\r
-                       | D_CUSTOM custom_type ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
+                       | D_CUSTOM custom_type ASSIGN bytes_list\r
                           {\r
                                 $$ = new CustomAttr ((IMethodRef) $2,\r
-                                        (byte[]) $5);\r
+                                        (byte[]) $4);\r
                           }\r
                        | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type\r
                        | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN comp_qstring\r
                        | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN\r
-                         OPEN_PARENS bytes CLOSE_PARENS\r
+                         bytes_list\r
                        ;\r
                        \r
 custom_type            : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS type_list CLOSE_PARENS\r
@@ -2099,7 +2327,7 @@ custom_type               : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS type_lis
 \r
 sec_decl               : D_PERMISSION sec_action type_spec OPEN_PARENS nameval_pairs CLOSE_PARENS\r
                        | D_PERMISSION sec_action type_spec\r
-                       | D_PERMISSIONSET sec_action ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
+                       | D_PERMISSIONSET sec_action ASSIGN bytes_list\r
                        ;\r
 \r
 nameval_pairs          : nameval_pair \r
@@ -2137,12 +2365,20 @@ sec_action              : K_REQUEST
                        ;\r
 \r
 module_head            : D_MODULE\r
+                          {\r
+                          }\r
                        | D_MODULE comp_name\r
+                          {\r
+                                codegen.SetModuleName ((string) $2);\r
+                          }\r
                        | D_MODULE K_EXTERN comp_name\r
+                          {\r
+                                codegen.ExternTable.AddModule ((string) $3);                         \r
+                          }\r
                        ;\r
 \r
 file_decl              : D_FILE file_attr comp_name file_entry D_HASH ASSIGN\r
-                         OPEN_PARENS bytes CLOSE_PARENS file_entry\r
+                         bytes_list file_entry\r
                        | D_FILE file_attr comp_name file_entry\r
                        ;\r
 \r
@@ -2157,7 +2393,7 @@ file_entry                : /* EMPTY */
 assembly_all           : assembly_head OPEN_BRACE assembly_decls CLOSE_BRACE\r
                        ;\r
 \r
-assembly_head          : D_ASSEMBLY asm_attr file_name\r
+assembly_head          : D_ASSEMBLY asm_attr slashed_name\r
                           {\r
                                 codegen.SetAssemblyName ((string) $3);\r
                           }\r
@@ -2173,34 +2409,53 @@ assembly_decls          : /* EMPTY */
                        | assembly_decls assembly_decl\r
                        ;\r
 \r
-assembly_decl          : D_HASH K_ALGORITHM int32\r
+assembly_decl          : D_PUBLICKEY ASSIGN bytes_list\r
+                         {\r
+                               codegen.SetAssemblyPublicKey ((byte []) $3);\r
+                         }\r
+                       | D_VER int32 COLON int32 COLON int32 COLON int32\r
+                         {\r
+                               codegen.SetAssemblyVersion ((int) $2, (int) $4, (int) $6, (int) $8);\r
+                         }\r
+                       | D_LOCALE comp_qstring\r
+                         {\r
+                               codegen.SetAssemblyLocale ((string) $2);\r
+                         }\r
+                       | D_LOCALE ASSIGN bytes_list\r
+                       | D_HASH K_ALGORITHM int32\r
+                         {\r
+                               codegen.SetAssemblyHashAlgorithm ((int) $3);\r
+                         }\r
+                       | customattr_decl\r
+                         {\r
+                               codegen.AddAssemblyCustomAttribute ((CustomAttr) $1);\r
+                         }\r
                        | sec_decl\r
-                       | asm_or_ref_decl\r
                        ;\r
 \r
-asm_or_ref_decl                : D_PUBLICKEY ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
+asm_or_ref_decl                : D_PUBLICKEY ASSIGN bytes_list\r
                        | D_VER int32 COLON int32 COLON int32 COLON int32 \r
                        | D_LOCALE comp_qstring\r
-                       | D_LOCALE ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
+                       | D_LOCALE ASSIGN bytes_list\r
                        | customattr_decl\r
                        ;\r
 \r
 assemblyref_all                : assemblyref_head OPEN_BRACE assemblyref_decls CLOSE_BRACE\r
                        ;\r
 \r
-assemblyref_head       : D_ASSEMBLY K_EXTERN file_name\r
+assemblyref_head       : D_ASSEMBLY K_EXTERN slashed_name\r
                           {\r
                                 System.Reflection.AssemblyName asmb_name = \r
                                        new System.Reflection.AssemblyName ();\r
                                asmb_name.Name = (string) $3;\r
-                               codegen.ExternTable.AddAssembly ((string) $3, asmb_name);\r
+                               codegen.BeginAssemblyRef ((string) $3, asmb_name);\r
                           }\r
-                       | D_ASSEMBLY K_EXTERN file_name K_AS file_name\r
+                       | D_ASSEMBLY K_EXTERN slashed_name K_AS slashed_name\r
                           {\r
                                 System.Reflection.AssemblyName asmb_name = \r
                                        new System.Reflection.AssemblyName ();\r
                                asmb_name.Name = (string) $3;\r
-                               codegen.ExternTable.AddAssembly ((string) $5, asmb_name);\r
+                               codegen.BeginAssemblyRef ((string) $5, asmb_name);\r
                           }\r
                        ;\r
 \r
@@ -2208,9 +2463,29 @@ assemblyref_decls        : /* EMPTY */
                        | assemblyref_decls assemblyref_decl\r
                        ;\r
 \r
-assemblyref_decl       : D_HASH ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
-                       | asm_or_ref_decl\r
-                       | D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
+assemblyref_decl       : D_VER int32 COLON int32 COLON int32 COLON int32\r
+                          {\r
+                                codegen.CurrentAssemblyRef.SetVersion ((int) $2, (int) $4, (int) $6, (int) $8);\r
+                          }\r
+                        | D_PUBLICKEY ASSIGN bytes_list\r
+                          {\r
+                                codegen.CurrentAssemblyRef.SetPublicKey ((byte []) $3);\r
+                          }\r
+                        | D_PUBLICKEYTOKEN ASSIGN bytes_list\r
+                          {\r
+                                codegen.CurrentAssemblyRef.SetPublicKeyToken ((byte []) $3);\r
+                          }\r
+                       | D_LOCALE comp_qstring\r
+                          {\r
+                                codegen.CurrentAssemblyRef.SetLocale ((string) $2);\r
+                          }\r
+                       | D_LOCALE ASSIGN bytes_list\r
+                       \r
+                        | D_HASH ASSIGN bytes_list\r
+                          {\r
+                                codegen.CurrentAssemblyRef.SetHash ((byte []) $3);\r
+                          }\r
+                        | customattr_decl\r
                        ;\r
 \r
 exptype_all            : exptype_head OPEN_BRACE exptype_decls CLOSE_BRACE\r
@@ -2256,7 +2531,7 @@ manifestres_decls : /* EMPTY */
                        ;\r
 \r
 manifestres_decl       : D_FILE comp_name K_AT int32\r
-                       | D_ASSEMBLY K_EXTERN file_name\r
+                       | D_ASSEMBLY K_EXTERN slashed_name\r
                        | customattr_decl\r
                        ;\r
 \r
@@ -2264,20 +2539,15 @@ comp_qstring            : QSTRING
                        | comp_qstring PLUS QSTRING     { $$ = String.Format ("{0}{1}", $1, $3); }\r
                        ;\r
 \r
-int32                  : INT32\r
-                        | INT64\r
+int32                  : INT64\r
                           {\r
                                 long l = (long) $1;\r
                                 byte[] intb = BitConverter.GetBytes (l);\r
-                                $$ = BitConverter.ToInt32 (intb, 0);\r
+                                $$ = BitConverter.ToInt32 (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
                           }\r
                        ;\r
 \r
 int64                  : INT64\r
-                        | INT32\r
-                          {\r
-                                $$ = Convert.ToInt64 ($1);\r
-                          }\r
                        ;\r
 \r
 float64                        : FLOAT64\r
@@ -2285,33 +2555,39 @@ float64                 : FLOAT64
                           {\r
                                 int i = (int) $3;\r
                                 byte[] intb = BitConverter.GetBytes (i);\r
-                                $$ = (double) BitConverter.ToSingle (intb, 0);\r
+                                $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
                           }\r
                         | K_FLOAT32 OPEN_PARENS INT64 CLOSE_PARENS\r
                           {\r
                                 long l = (long) $3;\r
                                 byte[] intb = BitConverter.GetBytes (l);\r
-                                $$ = (double) BitConverter.ToSingle (intb, 0);\r
+                                $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
                           }\r
                        | K_FLOAT64 OPEN_PARENS INT64 CLOSE_PARENS\r
                           {\r
                                 byte[] intb = BitConverter.GetBytes ((long) $3);\r
-                                $$ = BitConverter.ToDouble (intb, 0);\r
+                               $$ = BitConverter.ToDouble (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
                           }\r
                         | K_FLOAT64 OPEN_PARENS INT32 CLOSE_PARENS\r
                           {\r
                                 byte[] intb = BitConverter.GetBytes ((int) $3);\r
-                                $$ = (double) BitConverter.ToSingle (intb, 0);\r
+                                $$ = (double) BitConverter.ToSingle (intb, BitConverter.IsLittleEndian ? 0 : 4);\r
                           }\r
                        ;\r
 \r
-hexbyte                        : HEXBYTE\r
-                        | INT32         { $$ = Convert.ToByte ($1); }\r
-                        | ID\r
+hexbyte                        : HEXBYTE       { }\r
+                       ;\r
+\r
+bytes_list              : OPEN_PARENS\r
                           {\r
-                                $$ = Byte.Parse ((string) $1, NumberStyles.HexNumber);\r
+                                tokenizer.InByteArray = true;\r
                           }\r
-                       ;\r
+                          bytes CLOSE_PARENS\r
+                          {\r
+                                $$ = $3;\r
+                                tokenizer.InByteArray = false;\r
+                          }\r
+                        ;\r
 \r
 bytes                  : /* EMPTY */   { $$ = new byte[0]; }\r
                        | hexbytes\r
@@ -2335,7 +2611,13 @@ hexbytes         : hexbyte
                        ;\r
 \r
 truefalse              : K_TRUE\r
+                          {\r
+                                $$ = true;\r
+                          }\r
                        | K_FALSE\r
+                          {\r
+                                $$ = false;\r
+                          }\r
                        ;\r
 \r
 id                     : ID\r
@@ -2347,16 +2629,9 @@ comp_name                : id
                           {\r
                                 $$ = (string) $1 + '.' + (string) $3;\r
                           }\r
+                        | COMP_NAME\r
                        ;\r
 \r
-file_name               : comp_name\r
-                        | file_name DASH comp_name\r
-                          {\r
-                                $$ = (string) $1 + '-' + (string) $3;\r
-                          }\r
-                        ;\r
-\r
-\r
 %%\r
 \r
 }\r