%{ // Mono::ILASM::ILParser // // (C) Sergey Chaban (serge@wildwestsoftware.com) using System; using System.Reflection; using System.Reflection.Emit; namespace Mono.ILASM { public class ILParser { private Method method; private InstrBase currentInstr; private CallingConventions currentCallConv; private TypeAttributes currentTypeAttrs; private Class currentClass; private CodeGen codegen; private string defaultAsmName = "output"; 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 /* 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_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_MAXSTCCK %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 : classAll | nameSpaceHead OPEN_BRACE decls CLOSE_BRACE | methodAll | fieldDecl | dataDecl | vtableDecl | vtfixupDecl | extSourceSpec | fileDecl | assemblyHead OPEN_BRACE assemblyDecls CLOSE_BRACE | assemblyRefHead OPEN_BRACE assemblyRefDecls CLOSE_BRACE | comtypeHead OPEN_BRACE comtypeDecls CLOSE_BRACE | manifestResHead OPEN_BRACE manifestResDecls CLOSE_BRACE | moduleHead | secDecl | customAttrDecl | D_SUBSYSTEM int32 | D_CORFLAGS int32 | D_FILE K_ALIGNMENT int32 | languageDecl ; compQstring : QSTRING | compQstring PLUS QSTRING {$$ = ($1 as string) + ($3 as string);} ; languageDecl : D_LANGUAGE SQSTRING | D_LANGUAGE SQSTRING COMMA SQSTRING | D_LANGUAGE SQSTRING COMMA SQSTRING COMMA SQSTRING ; customAttrDecl : D_CUSTOM customType | D_CUSTOM customType ASSIGN compQstring | customHead bytes CLOSE_PARENS | D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType | D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType ASSIGN compQstring | customHeadWithOwner bytes CLOSE_PARENS ; moduleHead : D_MODULE | D_MODULE name1 | D_MODULE K_EXTERN name1 ; vtfixupDecl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET vtfixupAttr K_AT id ; vtfixupAttr : /* EMPTY */ | vtfixupAttr K_INT32 | vtfixupAttr K_INT64 | vtfixupAttr K_FROMUNMANAGED | vtfixupAttr K_CALLMOSTDERIVED ; vtableDecl : vtableHead bytes CLOSE_PARENS ; vtableHead : D_VTABLE ASSIGN OPEN_PARENS ; nameSpaceHead : D_NAMESPACE name1 ; classHead : D_CLASS classAttr id extendsClause implClause { currentTypeAttrs = 0; currentClass = new Class ($3 as string); currentClass.Attrs = currentTypeAttrs; // TODO: extends/implemets } ; classAttr : /* EMPTY */ | classAttr K_PUBLIC {currentTypeAttrs |= TypeAttributes.Public;} | classAttr K_PRIVATE {currentTypeAttrs &= ~TypeAttributes.Public;} | classAttr K_VALUE { /* FIXME */ } | classAttr K_ENUM { /* FIXME */ } | classAttr K_INTERFACE {currentTypeAttrs |= TypeAttributes.Interface;} | classAttr K_SEALED {currentTypeAttrs |= TypeAttributes.Sealed;} | classAttr K_ABSTRACT {currentTypeAttrs |= TypeAttributes.Abstract;} | classAttr K_AUTO {currentTypeAttrs |= TypeAttributes.AutoLayout;} | classAttr K_SEQUENTIAL {currentTypeAttrs |= TypeAttributes.SequentialLayout;} | classAttr K_EXPLICIT {currentTypeAttrs |= TypeAttributes.ExplicitLayout;} | classAttr K_ANSI {currentTypeAttrs |= TypeAttributes.AnsiClass;} | classAttr K_UNICODE {currentTypeAttrs |= TypeAttributes.UnicodeClass;} | classAttr K_AUTOCHAR {currentTypeAttrs |= TypeAttributes.AutoClass;} | classAttr K_IMPORT {currentTypeAttrs |= TypeAttributes.Import;} | classAttr K_SERIALIZABLE {currentTypeAttrs |= TypeAttributes.Serializable;} | classAttr K_NESTED K_PUBLIC {currentTypeAttrs |= TypeAttributes.NestedPublic;} | classAttr K_NESTED K_PRIVATE {currentTypeAttrs |= TypeAttributes.NestedPrivate;} | classAttr K_NESTED K_FAMILY {currentTypeAttrs |= TypeAttributes.NestedFamily;} | classAttr K_NESTED K_ASSEMBLY {currentTypeAttrs |= TypeAttributes.NestedAssembly;} | classAttr K_NESTED K_FAMANDASSEM {currentTypeAttrs |= TypeAttributes.NestedFamANDAssem;} | classAttr K_NESTED K_FAMORASSEM {currentTypeAttrs |= TypeAttributes.NestedFamORAssem;} | classAttr K_BEFOREFIELDINIT {currentTypeAttrs |= TypeAttributes.BeforeFieldInit;} | classAttr K_SPECIALNAME {currentTypeAttrs |= TypeAttributes.SpecialName;} | classAttr K_RTSPECIALNAME {currentTypeAttrs |= TypeAttributes.RTSpecialName;} ; extendsClause : /* EMPTY */ | K_EXTENDS className ; implClause : /* EMPTY */ | K_IMPLEMENTS classNames ; classNames : classNames COMMA className | className ; classDecls : /* EMPTY */ | classDecls classDecl ; classAll : classHead OPEN_BRACE classDecls CLOSE_BRACE { codegen.AddClass (currentClass); currentClass = null; } ; classDecl : methodAll | classAll | eventHead OPEN_BRACE eventDecls CLOSE_BRACE | propHead OPEN_BRACE propDecls CLOSE_BRACE | fieldDecl | dataDecl | secDecl | extSourceSpec | customAttrDecl | D_SIZE int32 | D_PACK int32 | exportHead OPEN_BRACE comtypeDecls CLOSE_BRACE | D_OVERRIDE typeSpec DOUBLE_COLON methodName K_WITH callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | languageDecl ; fieldDecl : D_FIELD repeatOpt fieldAttr type id atOpt initOpt ; atOpt : /* EMPTY */ | K_AT id ; initOpt : /* EMPTY */ | ASSIGN fieldInit ; repeatOpt : /* EMPTY */ | OPEN_BRACKET int32 CLOSE_BRACKET ; customHead : D_CUSTOM customType ASSIGN OPEN_PARENS ; customHeadWithOwner : D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType ASSIGN OPEN_PARENS ; customType : typeSpec | callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS ; eventHead : D_EVENT eventAttr typeSpec id | D_EVENT eventAttr id ; eventAttr : /* EMPTY */ | eventAttr K_RTSPECIALNAME /**/ | eventAttr K_SPECIALNAME ; eventDecls : /* EMPTY */ | eventDecls eventDecl ; eventDecl : D_ADDON callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_ADDON callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_REMOVEON callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_REMOVEON callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_FIRE callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_FIRE callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_OTHER callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_OTHER callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | extSourceSpec | customAttrDecl | languageDecl ; propHead : D_PROPERTY propAttr callConv type id OPEN_PARENS sigArgs0 CLOSE_PARENS initOpt ; propAttr : /* EMPTY */ | propAttr K_RTSPECIALNAME /**/ | propAttr K_SPECIALNAME ; propDecls : /* EMPTY */ | propDecls propDecl ; propDecl : D_SET callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_SET callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_GET callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_GET callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_OTHER callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | D_OTHER callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | customAttrDecl | extSourceSpec | languageDecl ; methodHeadPart1 : D_METHOD { method = new Method (); currentCallConv = 0; /*?*/ } ; methodHead : methodHeadPart1 methAttr callConv paramAttr type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS implAttr OPEN_BRACE { method.SetMethodName ($6 as MethodName); method.CallConv = currentCallConv; method.RetType = $5 as string; } | methodHeadPart1 methAttr callConv paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS methodName OPEN_PARENS sigArgs0 CLOSE_PARENS implAttr OPEN_BRACE ; methodAll : methodHead methodDecls CLOSE_BRACE { // Console.WriteLine (method); currentClass.AddMethod (method); } ; methAttr : /* EMPTY */ | methAttr K_STATIC {method.Attrs |= MethodAttributes.Static;} | methAttr K_PUBLIC {method.Attrs |= MethodAttributes.Public;} | methAttr K_PRIVATE {method.Attrs &= ~MethodAttributes.Public;} | methAttr K_FAMILY {method.Attrs |= MethodAttributes.Family;} | methAttr K_FINAL {method.Attrs |= MethodAttributes.Final;} | methAttr K_SPECIALNAME {method.Attrs |= MethodAttributes.SpecialName;} | methAttr K_VIRTUAL {method.Attrs |= MethodAttributes.Virtual;} | methAttr K_ABSTRACT {method.Attrs |= MethodAttributes.Abstract;} | methAttr K_ASSEMBLY {method.Attrs |= MethodAttributes.Assembly;} | methAttr K_FAMANDASSEM {method.Attrs |= MethodAttributes.FamANDAssem;} | methAttr K_FAMORASSEM {method.Attrs |= MethodAttributes.FamORAssem;} | methAttr K_COMPILERCONTROLLED {/* FIXME */} | methAttr K_HIDEBYSIG {method.Attrs |= MethodAttributes.HideBySig;} | methAttr K_NEWSLOT {method.Attrs |= MethodAttributes.NewSlot;} | methAttr K_RTSPECIALNAME /**/ {/* FIXME */} | methAttr K_UNMANAGEDEXP {method.Attrs |= MethodAttributes.UnmanagedExport;} | methAttr K_REQSECOBJ {method.Attrs |= MethodAttributes.RequireSecObject;} | methAttr K_PINVOKEIMPL OPEN_PARENS compQstring K_AS compQstring pinvAttr CLOSE_PARENS {/* FIXME */} | methAttr K_PINVOKEIMPL OPEN_PARENS compQstring pinvAttr CLOSE_PARENS {/* FIXME */} | methAttr K_PINVOKEIMPL OPEN_PARENS pinvAttr CLOSE_PARENS {/* FIXME */} ; pinvAttr : /* EMPTY */ | pinvAttr K_NOMANGLE | pinvAttr K_ANSI | pinvAttr K_UNICODE | pinvAttr K_AUTOCHAR | pinvAttr K_LASTERR | pinvAttr K_WINAPI | pinvAttr K_CDECL | pinvAttr K_STDCALL | pinvAttr K_THISCALL | pinvAttr K_FASTCALL ; methodName : D_CTOR {$$ = new MethodName ("ctor", true);} | D_CCTOR {$$ = new MethodName ("cctor", true);} | name1 {$$ = new MethodName ($1 as string);} ; paramAttr : /* EMPTY */ | paramAttr OPEN_BRACKET K_IN CLOSE_BRACKET | paramAttr OPEN_BRACKET K_OUT CLOSE_BRACKET | paramAttr OPEN_BRACKET K_OPT CLOSE_BRACKET | paramAttr OPEN_BRACKET int32 CLOSE_BRACKET ; fieldAttr : /* EMPTY */ | fieldAttr K_STATIC | fieldAttr K_PUBLIC | fieldAttr K_PRIVATE | fieldAttr K_FAMILY | fieldAttr K_INITONLY | fieldAttr K_RTSPECIALNAME /**/ | fieldAttr K_SPECIALNAME /* commented out because PInvoke for fields is not supported by EE | fieldAttr K_PINVOKEIMPL OPEN_PARENS compQstring K_AS compQstring pinvAttr CLOSE_PARENS | fieldAttr K_PINVOKEIMPL OPEN_PARENS compQstring pinvAttr CLOSE_PARENS | fieldAttr K_PINVOKEIMPL OPEN_PARENS pinvAttr CLOSE_PARENS */ | fieldAttr K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS | fieldAttr K_ASSEMBLY | fieldAttr K_FAMANDASSEM | fieldAttr K_FAMORASSEM | fieldAttr K_COMPILERCONTROLLED | fieldAttr K_LITERAL | fieldAttr K_NOTSERIALIZED ; implAttr : /* empty */ | implAttr K_NATIVE | implAttr ELLIPSIS | implAttr K_IL /* LAMESPEC: absent in docs */ | implAttr K_CIL /* LAMESPEC: same as above */ | implAttr K_OPTIL | implAttr K_MANAGED | implAttr K_UNMANAGED | implAttr K_FORWARDREF | implAttr K_PRESERVESIG | implAttr K_RUNTIME | implAttr K_INTERNALCALL | implAttr K_SYNCHRONIZED | implAttr K_NOINLINING ; localsHead : D_LOCALS ; methodDecl : D_EMITBYTE int32 | sehBlock | D_MAXSTACK int32 | localsHead OPEN_PARENS sigArgs0 CLOSE_PARENS | localsHead K_INIT OPEN_PARENS sigArgs0 CLOSE_PARENS | D_ENTRYPOINT {method.IsEntryPoint = true;} | D_ZEROINIT | dataDecl | instr { method.AddInstruction (currentInstr); } | id COLON | secDecl | extSourceSpec | languageDecl | customAttrDecl | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id | D_VTENTRY int32 COLON int32 | D_OVERRIDE typeSpec DOUBLE_COLON methodName | scopeBlock | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET initOpt ; scopeBlock : scopeOpen methodDecls CLOSE_BRACE ; scopeOpen : OPEN_BRACE ; sehBlock : tryBlock sehClauses ; sehClauses : sehClause sehClauses | sehClause ; tryBlock : tryHead scopeBlock | tryHead id K_TO id | tryHead int32 K_TO int32 ; tryHead : D_TRY ; sehClause : catchClause handlerBlock | filterClause handlerBlock | finallyClause handlerBlock | faultClause handlerBlock ; filterClause : filterHead scopeBlock | filterHead id | filterHead int32 ; filterHead : K_FILTER ; catchClause : K_CATCH className ; finallyClause : K_FINALLY ; faultClause : K_FAULT ; handlerBlock : scopeBlock | K_HANDLER id K_TO id | K_HANDLER int32 K_TO int32 ; methodDecls : /* EMPTY */ | methodDecls methodDecl ; dataDecl : ddHead ddBody ; ddHead : D_DATA tls id ASSIGN | D_DATA tls ; tls : /* EMPTY */ | K_TLS ; ddBody : OPEN_BRACE ddItemList CLOSE_BRACE | ddItem ; ddItemList : ddItem COMMA ddItemList | ddItem ; ddItemCount : /* EMPTY */ | OPEN_BRACKET int32 CLOSE_BRACKET ; ddItem : K_CHAR STAR OPEN_PARENS compQstring CLOSE_PARENS | AMPERSAND OPEN_PARENS id CLOSE_PARENS | bytearrayhead bytes CLOSE_PARENS | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS ddItemCount | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS ddItemCount | K_INT64 OPEN_PARENS int64 CLOSE_PARENS ddItemCount | K_INT32 OPEN_PARENS int32 CLOSE_PARENS ddItemCount | K_INT16 OPEN_PARENS int32 CLOSE_PARENS ddItemCount | K_INT8 OPEN_PARENS int32 CLOSE_PARENS ddItemCount | K_FLOAT32 ddItemCount | K_FLOAT64 ddItemCount | K_INT64 ddItemCount | K_INT32 ddItemCount | K_INT16 ddItemCount | K_INT8 ddItemCount ; fieldInit : 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 | compQstring | bytearrayhead bytes CLOSE_PARENS | K_NULLREF ; bytearrayhead : K_BYTEARRAY OPEN_PARENS ; hexbyte : INT32 | id ; bytes : /* EMPTY */ | hexbytes ; hexbytes : hexbyte | hexbytes hexbyte ; instr_r_head : INSTR_R OPEN_PARENS ; methodSpec : K_METHOD ; instr : INSTR_NONE {currentInstr = new InstrNone ((OpCode) $1);} | INSTR_VAR int32 {currentInstr = new InstrVar ((OpCode) $1, $2);} | INSTR_VAR id {currentInstr = new InstrVar ((OpCode) $1, $2);} | INSTR_I int32 {currentInstr = new InstrI ((OpCode) $1, (Int32) $2);} | INSTR_I8 int64 {currentInstr = new InstrI8 ((OpCode) $1, (Int64) $2);} | INSTR_R float64 {currentInstr = new InstrR ((OpCode) $1, (Double) $2);} | INSTR_R int64 {currentInstr = new InstrR ((OpCode) $1, (Int64) $2);} | instr_r_head bytes CLOSE_PARENS | INSTR_BRTARGET int32 | INSTR_BRTARGET id | INSTR_METHOD callConv type assembly_name name1 DOUBLE_COLON ID OPEN_PARENS signature_args CLOSE_PARENS { currentInstr = new InstrCall ((OpCode) $1, (string)$3, (string)$4, (string)$5, (string)$7, (string)$9); } | INSTR_METHOD callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS { } | INSTR_FIELD type typeSpec DOUBLE_COLON id | INSTR_FIELD type id | INSTR_TYPE typeSpec | INSTR_STRING compQstring { currentInstr = new InstrString ((OpCode) $1, $2 as string); } | INSTR_STRING bytearrayhead bytes CLOSE_PARENS | INSTR_SIG callConv type OPEN_PARENS sigArgs0 CLOSE_PARENS | INSTR_RVA id | INSTR_RVA int32 | INSTR_TOK methodSpec callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | INSTR_TOK methodSpec callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS | INSTR_TOK K_FIELD type typeSpec DOUBLE_COLON id | INSTR_TOK K_FIELD type id | INSTR_TOK typeSpec | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS | INSTR_PHI int16s ; signature_args : /* EMPTY */ | type | type COMMA signature_args ; sigArgs0 : /* EMPTY */ | sigArgs1 ; sigArgs1 : sigArg | sigArgs1 COMMA sigArg ; sigArg : ELLIPSIS | paramAttr type | paramAttr type id | paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS | paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS id sint ; dottedName : id DOT id {$$ = ($1 as string) + "." + ($3 as string);} ; name1 : id | dottedName | name1 DOT name1 ; assembly_ref : id | id DASH id {$$ = String.Format ("{0}-{1}", $1, $3);} ; assembly_name : OPEN_BRACKET assembly_ref CLOSE_BRACKET {$$ = ($2 as string);} ; className : OPEN_BRACKET name1 CLOSE_BRACKET slashedName | OPEN_BRACKET D_MODULE name1 CLOSE_BRACKET slashedName | slashedName ; slashedName : name1 | slashedName SLASH name1 {$$ = ($1 as string) + "/" + ($3 as string);} ; typeSpec : className | OPEN_BRACKET name1 CLOSE_BRACKET | OPEN_BRACKET D_MODULE name1 CLOSE_BRACKET | type ; callConv : K_INSTANCE callConv {currentCallConv |= CallingConventions.HasThis;} | K_EXPLICIT callConv {currentCallConv |= CallingConventions.ExplicitThis;} | callKind ; callKind : /* EMPTY */ | K_DEFAULT {currentCallConv |= CallingConventions.Standard;} | K_VARARG {currentCallConv |= CallingConventions.VarArgs;} | K_UNMANAGED K_CDECL | K_UNMANAGED K_STDCALL | K_UNMANAGED K_THISCALL | K_UNMANAGED K_FASTCALL ; nativeType : /* EMPTY */ | K_CUSTOM OPEN_PARENS compQstring COMMA compQstring COMMA compQstring COMMA compQstring CLOSE_PARENS | K_CUSTOM OPEN_PARENS compQstring COMMA compQstring 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 | nativeType STAR | nativeType OPEN_BRACKET CLOSE_BRACKET | nativeType OPEN_BRACKET int32 CLOSE_BRACKET | nativeType OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET | nativeType 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 variantType | K_INT | K_UNSIGNED K_INT | K_NESTED K_STRUCT | K_BYVALSTR | K_ANSI K_BSTR | K_TBSTR | K_VARIANT K_BOOL | methodSpec | K_AS K_ANY | K_LPSTRUCT ; variantType : /* 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 | variantType OPEN_BRACKET CLOSE_BRACKET | variantType K_VECTOR | variantType 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 ; type : K_CLASS className | K_OBJECT | K_STRING | K_VALUE K_CLASS className | K_VALUETYPE className | type OPEN_BRACKET CLOSE_BRACKET | type OPEN_BRACKET bounds1 CLOSE_BRACKET /* uncomment when and if this type is supported by the Runtime | type K_VALUE OPEN_BRACKET int32 CLOSE_BRACKET */ | type AMPERSAND | type STAR | type K_PINNED | type K_MODREQ OPEN_PARENS className CLOSE_PARENS | type K_MODOPT OPEN_PARENS className CLOSE_PARENS | BANG int32 | methodSpec callConv type STAR OPEN_PARENS sigArgs0 CLOSE_PARENS | K_TYPEDREF | K_CHAR | K_VOID | K_BOOL | K_INT8 | K_INT16 | K_INT32 | K_INT64 | K_FLOAT32 | K_FLOAT64 | K_UNSIGNED K_INT8 {$$ = "uint8";} | K_UNSIGNED K_INT16 {$$ = "uint16";} | K_UNSIGNED K_INT32 {$$ = "uint32";} | K_UNSIGNED K_INT64 {$$ = "uint64";} | K_NATIVE K_INT | K_NATIVE K_UNSIGNED K_INT | K_NATIVE K_FLOAT ; bounds1 : bound | bounds1 COMMA bound ; bound : /* EMPTY */ | ELLIPSIS | int32 | int32 ELLIPSIS int32 | int32 ELLIPSIS ; labels : /* empty */ | id COMMA labels | int32 COMMA labels | id | int32 ; id : ID | SQSTRING ; int16s : /* EMPTY */ | int16s int32 ; int32 : INT32 /* NOTE: it's INT64 in docs */ ; int64 : INT64 ; float64 : FLOAT64 | K_FLOAT32 OPEN_PARENS int32 CLOSE_PARENS | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS ; secDecl : D_PERMISSION secAction typeSpec OPEN_PARENS nameValPairs CLOSE_PARENS | D_PERMISSION secAction typeSpec | psetHead bytes CLOSE_PARENS ; psetHead : D_PERMISSIONSET secAction ASSIGN OPEN_PARENS ; nameValPairs : nameValPair | nameValPair COMMA nameValPairs ; nameValPair : compQstring ASSIGN caValue ; truefalse : K_TRUE | K_FALSE ; caValue : truefalse | int32 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS | compQstring | className OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS | className OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS | className OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS | className OPEN_PARENS int32 CLOSE_PARENS ; secAction : 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 ; extSourceSpec : D_LINE int32 SQSTRING | D_LINE int32 | D_XLINE int32 QSTRING ; fileDecl : D_FILE fileAttr name1 fileEntry hashHead bytes CLOSE_PARENS fileEntry | D_FILE fileAttr name1 fileEntry ; fileAttr : /* EMPTY */ | fileAttr K_NOMETADATA ; fileEntry : /* EMPTY */ | D_ENTRYPOINT ; hashHead : D_HASH ASSIGN OPEN_PARENS ; assemblyHead : D_ASSEMBLY asmAttr name1 { // TODO: set assembly attrs codegen.SetName ($3 as string); } ; asmAttr : /* EMPTY */ | asmAttr K_NOAPPDOMAIN | asmAttr K_NOPROCESS | asmAttr K_NOMACHINE ; assemblyDecls : /* EMPTY */ | assemblyDecls assemblyDecl ; assemblyDecl : D_HASH K_ALGORITHM int32 | secDecl | asmOrRefDecl ; asmOrRefDecl : publicKeyHead bytes CLOSE_PARENS | D_VER int32 COLON int32 COLON int32 COLON int32 | D_LOCALE compQstring | localeHead bytes CLOSE_PARENS | D_PROCESSOR int32 | D_OS int32 D_VER int32 COLON int32 | customAttrDecl ; publicKeyHead : D_PUBLICKEY ASSIGN OPEN_PARENS ; publicKeyTokenHead : D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS ; localeHead : D_LOCALE ASSIGN OPEN_PARENS ; assemblyRefHead : D_ASSEMBLY K_EXTERN name1 ; assemblyRefDecls : /* EMPTY */ | assemblyRefDecls assemblyRefDecl ; assemblyRefDecl : hashHead bytes CLOSE_PARENS | asmOrRefDecl | publicKeyTokenHead bytes CLOSE_PARENS ; comtypeHead : D_CLASS K_EXTERN comtAttr name1 ; exportHead : D_EXPORT comtAttr name1 ; comtAttr : /* EMPTY */ | comtAttr K_PRIVATE | comtAttr K_PUBLIC | comtAttr K_NESTED K_PUBLIC | comtAttr K_NESTED K_PRIVATE | comtAttr K_NESTED K_FAMILY | comtAttr K_NESTED K_ASSEMBLY | comtAttr K_NESTED K_FAMANDASSEM | comtAttr K_NESTED K_FAMORASSEM ; comtypeDecls : /* EMPTY */ | comtypeDecls comtypeDecl ; comtypeDecl : D_FILE name1 | D_CLASS K_EXTERN name1 | D_CLASS int32 | customAttrDecl ; manifestResHead : D_MRESOURCE manresAttr name1 ; manresAttr : /* EMPTY */ | manresAttr K_PUBLIC | manresAttr K_PRIVATE ; manifestResDecls : /* EMPTY */ | manifestResDecls manifestResDecl ; manifestResDecl : D_FILE name1 K_AT int32 | D_ASSEMBLY K_EXTERN name1 | customAttrDecl ; %% } // namespace Mono.ILASM