%{ // Mono::ILASM::ILParser // // (C) Sergey Chaban (serge@wildwestsoftware.com) using PEAPI; using System; using System.Collections; namespace Mono.ILASM { public class ILParser { private CodeGen codegen; public ILParser (CodeGen codegen) { this.codegen = codegen; } public CodeGen CodeGen { get { return codegen; } } %} %token EOF /* ID - alpha-numeric identifier */ %token ID /* QSTRING - quoted string */ %token QSTRING /* SQSTRING - single quoted string */ %token SQSTRING /* INT32 - 32 bit integer */ %token INT32 /* INT64 - 64 bit integer */ %token INT64 /* FLOAT64 - floating point number */ %token FLOAT64 /* HEXBYTE - two digit hex number */ %token HEXBYTE /* Punctuation */ %token DOT "." %token OPEN_BRACE "{" %token CLOSE_BRACE "}" %token OPEN_BRACKET "[" %token CLOSE_BRACKET "]" %token OPEN_PARENS "(" %token CLOSE_PARENS ")" %token COMMA "," %token COLON ":" %token DOUBLE_COLON "::" %token SEMICOLON ";" %token ASSIGN "=" %token STAR "*" %token AMPERSAND "&" %token PLUS "+" %token SLASH "/" %token BANG "!" %token ELLIPSIS "..." %token DASH "-" %token UNKNOWN /* INSTR_* instruction types */ %token INSTR_NONE %token INSTR_VAR %token INSTR_I %token INSTR_I8 %token INSTR_R %token INSTR_BRTARGET %token INSTR_METHOD %token INSTR_NEWOBJ %token INSTR_FIELD %token INSTR_TYPE %token INSTR_STRING %token INSTR_SIG %token INSTR_RVA %token INSTR_TOK %token INSTR_SWITCH %token INSTR_PHI /* Mechanically generated - DO NOT EDIT! */ /* Directives */ %token D_ADDON %token D_ALGORITHM %token D_ASSEMBLY %token D_BACKING %token D_BLOB %token D_CAPABILITY %token D_CCTOR %token D_CLASS %token D_COMTYPE %token D_CONFIG %token D_CORFLAGS %token D_CTOR %token D_CUSTOM %token D_DATA %token D_EMITBYTE %token D_ENTRYPOINT %token D_EVENT %token D_EXELOC %token D_EXPORT %token D_FIELD %token D_FILE %token D_FIRE %token D_GET %token D_HASH %token D_IMPLICITCOM %token D_LANGUAGE %token D_LINE %token D_XLINE %token D_LOCALE %token D_LOCALS %token D_MANIFESTRES %token D_MAXSTACK %token D_METHOD %token D_MIME %token D_MODULE %token D_MRESOURCE %token D_NAMESPACE %token D_ORIGINATOR %token D_OS %token D_OTHER %token D_OVERRIDE %token D_PACK %token D_PARAM %token D_PERMISSION %token D_PERMISSIONSET %token D_PROCESSOR %token D_PROPERTY %token D_PUBLICKEY %token D_PUBLICKEYTOKEN %token D_REMOVEON %token D_SET %token D_SIZE %token D_SUBSYSTEM %token D_TITLE %token D_TRY %token D_VER %token D_VTABLE %token D_VTENTRY %token D_VTFIXUP %token D_ZEROINIT /* Keywords */ %token K_AT %token K_AS %token K_IMPLICITCOM %token K_IMPLICITRES %token K_NOAPPDOMAIN %token K_NOPROCESS %token K_NOMACHINE %token K_EXTERN %token K_INSTANCE %token K_EXPLICIT %token K_DEFAULT %token K_VARARG %token K_UNMANAGED %token K_CDECL %token K_STDCALL %token K_THISCALL %token K_FASTCALL %token K_MARSHAL %token K_IN %token K_OUT %token K_OPT %token K_LCID %token K_RETVAL %token K_STATIC %token K_PUBLIC %token K_PRIVATE %token K_FAMILY %token K_INITONLY %token K_RTSPECIALNAME %token K_SPECIALNAME %token K_ASSEMBLY %token K_FAMANDASSEM %token K_FAMORASSEM %token K_PRIVATESCOPE %token K_LITERAL %token K_NOTSERIALIZED %token K_VALUE %token K_NOT_IN_GC_HEAP %token K_INTERFACE %token K_SEALED %token K_ABSTRACT %token K_AUTO %token K_SEQUENTIAL %token K_ANSI %token K_UNICODE %token K_AUTOCHAR %token K_IMPORT %token K_SERIALIZABLE %token K_NESTED %token K_LATEINIT %token K_EXTENDS %token K_IMPLEMENTS %token K_FINAL %token K_VIRTUAL %token K_HIDEBYSIG %token K_NEWSLOT %token K_UNMANAGEDEXP %token K_PINVOKEIMPL %token K_NOMANGLE %token K_OLE %token K_LASTERR %token K_WINAPI %token K_NATIVE %token K_IL %token K_CIL %token K_OPTIL %token K_MANAGED %token K_FORWARDREF %token K_RUNTIME %token K_INTERNALCALL %token K_SYNCHRONIZED %token K_NOINLINING %token K_CUSTOM %token K_FIXED %token K_SYSSTRING %token K_ARRAY %token K_VARIANT %token K_CURRENCY %token K_SYSCHAR %token K_VOID %token K_BOOL %token K_INT8 %token K_INT16 %token K_INT32 %token K_INT64 %token K_FLOAT32 %token K_FLOAT64 %token K_ERROR %token K_UNSIGNED %token K_DECIMAL %token K_DATE %token K_BSTR %token K_LPSTR %token K_LPWSTR %token K_LPTSTR %token K_OBJECTREF %token K_IUNKNOWN %token K_IDISPATCH %token K_STRUCT %token K_SAFEARRAY %token K_INT %token K_BYVALSTR %token K_TBSTR %token K_LPVOID %token K_ANY %token K_FLOAT %token K_LPSTRUCT %token K_NULL %token K_PTR %token K_VECTOR %token K_HRESULT %token K_CARRAY %token K_USERDEFINED %token K_RECORD %token K_FILETIME %token K_BLOB %token K_STREAM %token K_STORAGE %token K_STREAMED_OBJECT %token K_STORED_OBJECT %token K_BLOB_OBJECT %token K_CF %token K_CLSID %token K_METHOD %token K_CLASS %token K_PINNED %token K_MODREQ %token K_MODOPT %token K_TYPEDREF %token K_WCHAR %token K_CHAR %token K_FROMUNMANAGED %token K_CALLMOSTDERIVED %token K_BYTEARRAY %token K_WITH %token K_INIT %token K_TO %token K_CATCH %token K_FILTER %token K_FINALLY %token K_FAULT %token K_HANDLER %token K_TLS %token K_FIELD %token K_REQUEST %token K_DEMAND %token K_ASSERT %token K_DENY %token K_PERMITONLY %token K_LINKCHECK %token K_INHERITCHECK %token K_REQMIN %token K_REQOPT %token K_REQREFUSE %token K_PREJITGRANT %token K_PREJITDENY %token K_NONCASDEMAND %token K_NONCASLINKDEMAND %token K_NONCASINHERITANCE %token K_READONLY %token K_NOMETADATA %token K_ALGORITHM %token K_FULLORIGIN %token K_NAN %token K_INF %token K_PUBLICKEY %token K_ENABLEJITTRACKING %token K_DISABLEJITOPTIMIZER %token K_PRESERVESIG %token K_BEFOREFIELDINIT %token K_ALIGNMENT %token K_NULLREF %token K_VALUETYPE %token K_COMPILERCONTROLLED %token K_REQSECOBJ %token K_ENUM %token K_OBJECT %token K_STRING %token K_TRUE %token K_FALSE /* end generated */ %start il_file %% il_file : decls ; decls : /* EMPTY */ | decls decl ; decl : class_all | namespace_all | method_all | field_decl | data_decl | vtfixup_decl | file_decl | assembly_all | assemblyref_all | exptype_all | manifestres_all | module_head | sec_decl | customattr_decl | D_SUBSYSTEM int32 | D_CORFLAGS int32 | D_FILE K_ALIGNMENT int32 /* | D_IMAGEBASE int64 */ | extsource_spec | language_decl ; extsource_spec : D_LINE int32 SQSTRING | D_LINE int32 | D_LINE int32 COLON int32 SQSTRING | D_LINE int32 COLON int32 ; language_decl : D_LANGUAGE SQSTRING | D_LANGUAGE SQSTRING COMMA SQSTRING | D_LANGUAGE SQSTRING COMMA SQSTRING COMMA SQSTRING ; vtfixup_decl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET vtfixup_attr K_AT id ; vtfixup_attr : /* EMPTY */ | vtfixup_attr int32 | vtfixup_attr int64 | vtfixup_attr K_FROMUNMANAGED | vtfixup_attr K_CALLMOSTDERIVED ; namespace_all : namespace_head OPEN_BRACE decls CLOSE_BRACE { codegen.CurrentNameSpace = null; } ; namespace_head : D_NAMESPACE comp_name { codegen.CurrentNameSpace = (string) $2; } ; class_all : class_head OPEN_BRACE class_decls CLOSE_BRACE { codegen.CurrentClass = null; } ; class_head : D_CLASS class_attr id extends_clause impl_clause { if ($4 != null) { codegen.AddClass ((TypeAttr) $2, (string) $3, ((TypeRef)$4).Type as Class, null); } else { codegen.AddClass ((TypeAttr)$2, (string) $3, null); } ArrayList impl_list = (ArrayList) $5; if (impl_list != null) { foreach (TypeRef type_ref in impl_list) codegen.CurrentClass.AddImplementedInterface (type_ref.Type as Class); } } ; class_attrs : class_attrs class_attr ; class_attr : /* EMPTY */ { $$ = new TypeAttr (); } | class_attr K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.Public; } | class_attr K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.Private; } | class_attr K_NESTED K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.NestedPrivate; } | class_attr K_NESTED K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.NestedPublic; } | class_attr K_NESTED K_FAMILY { $$ = (TypeAttr)$1 | TypeAttr.NestedFamily; } | class_attr K_NESTED K_ASSEMBLY { $$ = (TypeAttr)$1 | TypeAttr.NestedAssembly;} | class_attr K_NESTED K_FAMANDASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamAndAssem; } | class_attr K_NESTED K_FAMORASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamOrAssem; } | class_attr K_VALUE { } | class_attr K_ENUM { } | class_attr K_INTERFACE { $$ = (TypeAttr)$1 | TypeAttr.Interface; } | class_attr K_SEALED { $$ = (TypeAttr)$1 | TypeAttr.Sealed; } | class_attr K_ABSTRACT { $$ = (TypeAttr)$1 | TypeAttr.Abstract; } | class_attr K_AUTO { } | class_attr K_SEQUENTIAL { $$ = (TypeAttr)$1 | TypeAttr.SequentialLayout; } | class_attr K_EXPLICIT { $$ = (TypeAttr)$1 | TypeAttr.ExplicitLayout; } | class_attr K_ANSI { } | class_attr K_UNICODE { $$ = (TypeAttr)$1 | TypeAttr.UnicodeClass; } | class_attr K_AUTOCHAR { $$ = (TypeAttr)$1 | TypeAttr.AutoClass; } | class_attr K_IMPORT { $$ = (TypeAttr)$1 | TypeAttr.Import; } | class_attr K_SERIALIZABLE { $$ = (TypeAttr)$1 | TypeAttr.Serializable; } | class_attr K_BEFOREFIELDINIT { $$ = (TypeAttr)$1 | TypeAttr.BeforeFieldInit; } | class_attr K_SPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.SpecialName; } | class_attr K_RTSPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.RTSpecialName; } ; extends_clause : /* EMPTY */ | K_EXTENDS class_ref { $$ = $2; } ; impl_clause : /* EMPTY */ | K_IMPLEMENTS class_refs { $$ = $2; } ; class_refs : class_ref { ArrayList class_list = new ArrayList (); class_list.Add ($1); $$ = class_list; } | class_refs COMMA class_ref { ArrayList class_list = (ArrayList) $1; class_list.Add ($3); $$ = class_list; } ; slashed_name : comp_name | slashed_name SLASH comp_name { $$ = String.Format ("{0}/{1}", $1, $3); } ; class_ref : OPEN_BRACKET comp_name CLOSE_BRACKET slashed_name { PEAPI.Type type = codegen.ExternTable.GetClass ((string) $2, (string)$4); $$ = new TypeRef (type, (string) $4); } | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET slashed_name | slashed_name { $$ = new TypeRef (codegen.ClassTable.GetReference ((string) $1, null), (string) $1); } ; class_decls : /* EMPTY */ | class_decls class_decl ; class_decl : method_all | class_all | event_all | prop_all | field_decl | data_decl | sec_decl | extsource_spec | customattr_decl | D_SIZE int32 | D_PACK int32 | D_OVERRIDE type_spec DOUBLE_COLON method_name K_WITH call_conv type type_spec DOUBLE_COLON method_name OPEN_PARENS sig_args CLOSE_PARENS | language_decl ; type : K_CLASS class_ref { $$ = $2; } | K_OBJECT { $$ = new TypeRef (PrimitiveType.Object, "System.Object"); } | K_STRING { $$ = new TypeRef (PrimitiveType.String, "System.String"); } | K_VALUE K_CLASS class_ref { $$ = $3; } | K_VALUETYPE class_ref { $$ = $2; } | type OPEN_BRACKET CLOSE_BRACKET { TypeRef base_type = (TypeRef) $1; PEAPI.Type arr_type = new ZeroBasedArray (base_type.Type); $$ = new TypeRef (arr_type, base_type.FullName + "[]"); } | type OPEN_BRACKET bounds CLOSE_BRACKET { // TODO } | type AMPERSAND { TypeRef base_type = $1 as TypeRef; PEAPI.Type ref_type = new ManagedPointer (base_type.Type); $$ = new TypeRef (ref_type, base_type.FullName + '&'); } | type STAR { TypeRef base_type = (TypeRef) $1; PEAPI.Type ptr_type = new UnmanagedPointer (base_type.Type); $$ = new TypeRef (ptr_type, base_type.FullName + '&'); } | type K_PINNED | type K_MODREQ OPEN_PARENS class_ref CLOSE_PARENS | type K_MODOPT OPEN_PARENS class_ref CLOSE_PARENS | K_METHOD call_conv type STAR OPEN_PARENS sig_args CLOSE_PARENS | K_TYPEDREF | K_CHAR { $$ = new TypeRef (PrimitiveType.Char, "System.Char"); } | K_VOID { $$ = new TypeRef (PrimitiveType.Void, "System.Void"); } | K_BOOL { $$ = new TypeRef (PrimitiveType.Boolean, "System.Bool"); } | K_INT8 { $$ = new TypeRef (PrimitiveType.Int8, "System.Int8"); } | K_INT16 { $$ = new TypeRef (PrimitiveType.Int16, "System.Int16"); } | K_INT32 { $$ = new TypeRef (PrimitiveType.Int32, "System.Int32"); } | K_INT64 { $$ = new TypeRef (PrimitiveType.Int64, "System.Int64"); } | K_FLOAT32 { $$ = new TypeRef (PrimitiveType.Float32, "System.Float32"); } | K_FLOAT64 { $$ = new TypeRef (PrimitiveType.Float64, "System.Float64"); } | K_UNSIGNED K_INT8 { $$ = new TypeRef (PrimitiveType.UInt8, "System.UInt8"); } | K_UNSIGNED K_INT16 { $$ = new TypeRef (PrimitiveType.UInt16, "System.UInt16"); } | K_UNSIGNED K_INT32 { $$ = new TypeRef (PrimitiveType.UInt32, "System.UInt32"); } | K_UNSIGNED K_INT64 { $$ = new TypeRef (PrimitiveType.UInt64, "System.UInt64"); } | K_NATIVE K_INT { // TODO: Is this the proper full name $$ = new TypeRef (PrimitiveType.NativeInt, "native int"); } | K_NATIVE K_UNSIGNED K_INT { // TODO: Is this the proper full name $$ = new TypeRef (PrimitiveType.NativeUInt, "native uint"); } ; bounds : bound | bounds COMMA bound ; bound : /* EMPTY */ | ELLIPSIS | int32 | int32 ELLIPSIS int32 | int32 ELLIPSIS ; call_conv : K_INSTANCE call_conv | K_EXPLICIT call_conv | call_kind ; call_kind : /* EMPTY */ | K_DEFAULT | K_VARARG | K_UNMANAGED K_CDECL | K_UNMANAGED K_STDCALL | K_UNMANAGED K_THISCALL | K_UNMANAGED K_FASTCALL ; native_type : /* EMPTY */ | K_CUSTOM OPEN_PARENS comp_qstring COMMA comp_qstring CLOSE_PARENS | K_FIXED K_SYSSTRING OPEN_BRACKET int32 CLOSE_BRACKET | K_FIXED K_ARRAY OPEN_BRACKET int32 CLOSE_BRACKET | K_VARIANT | K_CURRENCY | K_SYSCHAR | K_VOID | K_BOOL | K_INT8 | K_INT16 | K_INT32 | K_INT64 | K_FLOAT32 | K_FLOAT64 | K_ERROR | K_UNSIGNED K_INT8 | K_UNSIGNED K_INT16 | K_UNSIGNED K_INT32 | K_UNSIGNED K_INT64 | native_type STAR | native_type OPEN_BRACKET CLOSE_BRACKET | native_type OPEN_BRACKET int32 CLOSE_BRACKET | native_type OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET | native_type OPEN_BRACKET PLUS int32 CLOSE_BRACKET | K_DECIMAL | K_DATE | K_BSTR | K_LPSTR | K_LPWSTR | K_LPTSTR | K_OBJECTREF | K_IUNKNOWN | K_IDISPATCH | K_STRUCT | K_INTERFACE | K_SAFEARRAY variant_type | K_SAFEARRAY variant_type COMMA comp_qstring | K_INT | K_UNSIGNED K_INT | K_NESTED K_STRUCT | K_BYVALSTR | K_ANSI K_BSTR | K_TBSTR | K_VARIANT K_BOOL | K_METHOD | K_AS K_ANY | K_LPSTRUCT ; variant_type : /* EMPTY */ | K_NULL | K_VARIANT | K_CURRENCY | K_VOID | K_BOOL | K_INT8 | K_INT16 | K_INT32 | K_INT64 | K_FLOAT32 | K_FLOAT64 | K_UNSIGNED K_INT8 | K_UNSIGNED K_INT16 | K_UNSIGNED K_INT32 | K_UNSIGNED K_INT64 | STAR | variant_type OPEN_BRACKET CLOSE_BRACKET | variant_type K_VECTOR | variant_type AMPERSAND | K_DECIMAL | K_DATE | K_BSTR | K_LPSTR | K_LPWSTR | K_IUNKNOWN | K_IDISPATCH | K_SAFEARRAY | K_INT | K_UNSIGNED K_INT | K_ERROR | K_HRESULT | K_CARRAY | K_USERDEFINED | K_RECORD | K_FILETIME | K_BLOB | K_STREAM | K_STORAGE | K_STREAMED_OBJECT | K_STORED_OBJECT | K_BLOB_OBJECT | K_CF | K_CLSID ; field_decl : D_FIELD repeat_opt field_attr type id at_opt init_opt ; repeat_opt : /* EMPTY */ | OPEN_BRACKET int32 CLOSE_BRACKET ; field_attr : /* EMPTY */ | field_attr K_PUBLIC | field_attr K_PRIVATE | field_attr K_FAMILY | field_attr K_ASSEMBLY | field_attr K_FAMANDASSEM | field_attr K_FAMORASSEM | field_attr K_PRIVATESCOPE | field_attr K_STATIC | field_attr K_INITONLY | field_attr K_RTSPECIALNAME | field_attr K_SPECIALNAME | field_attr K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS | field_attr K_LITERAL | field_attr K_NOTSERIALIZED ; at_opt : /* EMPTY */ | K_AT id ; init_opt : /* EMPTY */ | ASSIGN field_init ; field_init : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS | K_FLOAT32 OPEN_PARENS int64 CLOSE_PARENS | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS | K_INT64 OPEN_PARENS int64 CLOSE_PARENS | K_INT32 OPEN_PARENS int64 CLOSE_PARENS | K_INT16 OPEN_PARENS int64 CLOSE_PARENS | K_CHAR OPEN_PARENS int64 CLOSE_PARENS | K_INT8 OPEN_PARENS int64 CLOSE_PARENS | K_BOOL OPEN_PARENS truefalse CLOSE_PARENS | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS | comp_qstring // ******** ADDED | K_NULLREF ; data_decl : data_head data_body ; data_head : D_DATA tls id ASSIGN | D_DATA tls ; tls : /* EMPTY */ | K_TLS ; data_body : OPEN_BRACE dataitem_list CLOSE_BRACE | dataitem ; dataitem_list : dataitem | dataitem_list COMMA dataitem ; dataitem : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS | AMPERSAND OPEN_PARENS id CLOSE_PARENS | K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS // ******** ADDED | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS repeat_opt | K_INT64 OPEN_PARENS int64 CLOSE_PARENS repeat_opt | K_INT32 OPEN_PARENS int32 CLOSE_PARENS repeat_opt | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt | K_FLOAT32 repeat_opt | K_FLOAT64 repeat_opt | K_INT64 repeat_opt | K_INT32 repeat_opt | K_INT16 repeat_opt | K_INT8 repeat_opt ; method_all : method_head OPEN_BRACE method_decls CLOSE_BRACE ; method_head : D_METHOD meth_attr call_conv param_attr type method_name OPEN_PARENS sig_args CLOSE_PARENS impl_attr | D_METHOD meth_attr call_conv param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS method_name OPEN_PARENS sig_args CLOSE_PARENS impl_attr ; meth_attr : /* EMPTY */ | meth_attr K_STATIC | meth_attr K_PUBLIC | meth_attr K_PRIVATE | meth_attr K_FAMILY | meth_attr K_ASSEMBLY | meth_attr K_FAMANDASSEM | meth_attr K_FAMORASSEM | meth_attr K_PRIVATESCOPE | meth_attr K_FINAL | meth_attr K_VIRTUAL | meth_attr K_ABSTRACT | meth_attr K_HIDEBYSIG | meth_attr K_NEWSLOT | meth_attr K_REQSECOBJ | meth_attr K_SPECIALNAME | meth_attr K_RTSPECIALNAME | meth_attr K_UNMANAGEDEXP | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring K_AS comp_qstring pinv_attr CLOSE_PARENS | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring pinv_attr CLOSE_PARENS | meth_attr K_PINVOKEIMPL OPEN_PARENS pinv_attr CLOSE_PARENS ; pinv_attr : /* EMPTY */ | pinv_attr K_NOMANGLE | pinv_attr K_ANSI | pinv_attr K_UNICODE | pinv_attr K_AUTOCHAR | pinv_attr K_LASTERR | pinv_attr K_WINAPI | pinv_attr K_CDECL | pinv_attr K_STDCALL | pinv_attr K_THISCALL | pinv_attr K_FASTCALL ; method_name : D_CTOR | D_CCTOR | comp_name ; param_attr : /* EMPTY */ | param_attr OPEN_BRACKET K_IN CLOSE_BRACKET | param_attr OPEN_BRACKET K_OUT CLOSE_BRACKET | param_attr OPEN_BRACKET K_OPT CLOSE_BRACKET ; impl_attr : /* EMPTY */ | impl_attr K_NATIVE | impl_attr K_CIL | impl_attr K_OPTIL | impl_attr K_MANAGED | impl_attr K_UNMANAGED | impl_attr K_FORWARDREF | impl_attr K_PRESERVESIG | impl_attr K_RUNTIME | impl_attr K_INTERNALCALL | impl_attr K_SYNCHRONIZED | impl_attr K_NOINLINING ; sig_args : /* EMPTY */ | sig_arg_list ; sig_arg_list : sig_arg | sig_arg_list COMMA sig_arg ; sig_arg : param_attr type | param_attr type id | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id ; method_decls : /* EMPTY */ | method_decls method_decl ; method_decl : D_EMITBYTE int32 | D_MAXSTACK int32 | D_LOCALS OPEN_PARENS sig_args CLOSE_PARENS | D_LOCALS K_INIT OPEN_PARENS sig_args CLOSE_PARENS | D_ENTRYPOINT | D_ZEROINIT | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id | D_VTENTRY int32 COLON int32 | D_OVERRIDE type_spec DOUBLE_COLON method_name | scope_block | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt | id COLON | seh_block | instr | sec_decl | extsource_spec | language_decl | customattr_decl | data_decl ; type_spec : class_ref | OPEN_BRACKET comp_name CLOSE_BRACKET | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET | type ; scope_block : OPEN_BRACE method_decls CLOSE_BRACE ; seh_block : try_block seh_clauses ; try_block : D_TRY scope_block | D_TRY id K_TO id | D_TRY int32 K_TO int32 ; seh_clauses : seh_clause | seh_clauses seh_clause ; seh_clause : K_CATCH class_ref handler_block | K_FINALLY handler_block | K_FAULT handler_block | filter_clause handler_block ; filter_clause : K_FILTER scope_block | K_FILTER id | K_FILTER int32 ; handler_block : scope_block | K_HANDLER id K_TO id | K_HANDLER int32 K_TO int32 ; instr : INSTR_NONE | INSTR_VAR int32 | INSTR_I int32 | INSTR_I id /* Allow variable names :p */ | INSTR_I8 int64 | INSTR_R float64 | INSTR_R int64 | INSTR_R OPEN_PARENS bytes CLOSE_PARENS | INSTR_BRTARGET int32 | INSTR_BRTARGET id | INSTR_METHOD method_ref | INSTR_FIELD type type_spec DOUBLE_COLON id | INSTR_FIELD type id | INSTR_TYPE K_FIELD type type_spec DOUBLE_COLON id // ****** ADDED | INSTR_TYPE K_FIELD type id // ****** ADDED | INSTR_TYPE type_spec | INSTR_STRING comp_qstring | INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS | INSTR_STRING K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS // ****** ADDED | INSTR_SIG call_conv type OPEN_PARENS sig_args CLOSE_PARENS | INSTR_TOK owner_type | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS ; method_ref : call_conv type type_spec DOUBLE_COLON method_name OPEN_PARENS sig_args CLOSE_PARENS | call_conv type method_name OPEN_PARENS sig_args CLOSE_PARENS ; labels : /* EMPTY */ | id | int32 | labels COMMA id | labels COMMA int32 ; owner_type : type_spec | member_ref ; member_ref : K_METHOD member_ref | K_FIELD type type_spec DOUBLE_COLON id | K_FIELD type id ; event_all : event_head OPEN_BRACE event_decls CLOSE_BRACE ; event_head : D_EVENT event_attr type_spec id | D_EVENT event_attr id ; event_attr : /* EMPTY */ | event_attr K_RTSPECIALNAME | event_attr K_SPECIALNAME ; event_decls : /* EMPTY */ | event_decls event_decl ; event_decl : D_ADDON method_ref | D_REMOVEON method_ref | D_FIRE method_ref | D_OTHER method_ref | customattr_decl | extsource_spec | language_decl ; prop_all : prop_head OPEN_BRACE prop_decls CLOSE_BRACE ; prop_head : D_PROPERTY prop_attr type id OPEN_PARENS sig_args CLOSE_PARENS init_opt ; prop_attr : /* EMPTY */ | prop_attr K_RTSPECIALNAME | prop_attr K_SPECIALNAME ; prop_decls : /* EMPTY */ | prop_decls prop_decl ; prop_decl : D_SET method_ref | D_GET method_ref | D_OTHER method_ref | customattr_decl | extsource_spec | language_decl ; customattr_decl : D_CUSTOM custom_type | D_CUSTOM custom_type ASSIGN comp_qstring | D_CUSTOM custom_type ASSIGN OPEN_PARENS bytes CLOSE_PARENS | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN comp_qstring | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN OPEN_PARENS bytes CLOSE_PARENS ; custom_type : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS sig_args CLOSE_PARENS | call_conv type D_CTOR OPEN_PARENS sig_args CLOSE_PARENS ; sec_decl : D_PERMISSION sec_action type_spec OPEN_PARENS nameval_pairs CLOSE_PARENS | D_PERMISSION sec_action type_spec | D_PERMISSIONSET sec_action ASSIGN OPEN_PARENS bytes CLOSE_PARENS ; nameval_pairs : nameval_pair | nameval_pairs COMMA nameval_pair ; nameval_pair : comp_qstring ASSIGN cavalue ; cavalue : truefalse | int32 | int32 OPEN_PARENS int32 CLOSE_PARENS | comp_qstring | class_ref OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS | class_ref OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS | class_ref OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS | class_ref OPEN_PARENS int32 CLOSE_PARENS ; sec_action : K_REQUEST | K_DEMAND | K_ASSERT | K_DENY | K_PERMITONLY | K_LINKCHECK | K_INHERITCHECK | K_REQMIN | K_REQOPT | K_REQREFUSE | K_PREJITGRANT | K_PREJITDENY | K_NONCASDEMAND | K_NONCASLINKDEMAND | K_NONCASINHERITANCE ; module_head : D_MODULE | D_MODULE comp_name | D_MODULE K_EXTERN comp_name ; file_decl : D_FILE file_attr comp_name file_entry D_HASH ASSIGN OPEN_PARENS bytes CLOSE_PARENS file_entry | D_FILE file_attr comp_name file_entry ; file_attr : /* EMPTY */ | file_attr K_NOMETADATA ; file_entry : /* EMPTY */ | D_ENTRYPOINT ; assembly_all : assembly_head OPEN_BRACE assembly_decls CLOSE_BRACE ; assembly_head : D_ASSEMBLY asm_attr comp_name ; asm_attr : /* EMPTY */ | asm_attr K_NOAPPDOMAIN | asm_attr K_NOPROCESS | asm_attr K_NOMACHINE ; assembly_decls : /* EMPTY */ | assembly_decls assembly_decl ; assembly_decl : D_HASH K_ALGORITHM int32 | sec_decl | asm_or_ref_decl ; asm_or_ref_decl : D_PUBLICKEY ASSIGN OPEN_PARENS bytes CLOSE_PARENS | D_VER int32 COLON int32 COLON int32 COLON int32 | D_LOCALE comp_qstring | D_LOCALE ASSIGN OPEN_PARENS bytes CLOSE_PARENS | customattr_decl ; assemblyref_all : assemblyref_head OPEN_BRACE assemblyref_decls CLOSE_BRACE ; assemblyref_head : D_ASSEMBLY K_EXTERN comp_name | D_ASSEMBLY K_EXTERN comp_name K_AS comp_name ; assemblyref_decls : /* EMPTY */ | assemblyref_decls assemblyref_decl ; assemblyref_decl : D_HASH ASSIGN OPEN_PARENS bytes CLOSE_PARENS | asm_or_ref_decl | D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS bytes CLOSE_PARENS ; exptype_all : exptype_head OPEN_BRACE exptype_decls CLOSE_BRACE ; exptype_head : D_CLASS K_EXTERN expt_attr comp_name ; expt_attr : /* EMPTY */ | expt_attr K_PRIVATE | expt_attr K_PUBLIC | expt_attr K_NESTED K_PUBLIC | expt_attr K_NESTED K_PRIVATE | expt_attr K_NESTED K_FAMILY | expt_attr K_NESTED K_ASSEMBLY | expt_attr K_NESTED K_FAMANDASSEM | expt_attr K_NESTED K_FAMORASSEM ; exptype_decls : /* EMPTY */ | exptype_decls exptype_decl ; exptype_decl : D_FILE comp_name | D_CLASS K_EXTERN comp_name | D_CLASS int32 | customattr_decl ; manifestres_all : manifestres_head OPEN_BRACE manifestres_decls CLOSE_BRACE ; manifestres_head : D_MRESOURCE manres_attr comp_name ; manres_attr : /* EMPTY */ | manres_attr K_PUBLIC | manres_attr K_PRIVATE ; manifestres_decls : /* EMPTY */ | manifestres_decls manifestres_decl ; manifestres_decl : D_FILE comp_name K_AT int32 | D_ASSEMBLY K_EXTERN comp_name | customattr_decl ; dotted_name : id | dotted_name DOT id { $$ = String.Format ("{0}.{1}", $1, $3); } ; comp_qstring : QSTRING | comp_qstring PLUS QSTRING { $$ = String.Format ("{0}{1}", $1, $3); } ; int32 : INT32 | INT64 ; int64 : INT32 | INT64 ; float64 : FLOAT64 | K_FLOAT32 OPEN_PARENS int32 CLOSE_PARENS | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS ; hexbyte : HEXBYTE | INT32 // ******** ADDED | ID // ******** ADDED ; bytes : /* EMPTY */ | hexbytes ; hexbytes : hexbyte | hexbytes hexbyte ; truefalse : K_TRUE | K_FALSE ; id : ID | SQSTRING ; comp_name : id | dotted_name ; dotted_name : id | dotted_name DOT id ; %% }