2 // Mono::ILASM::ILParser
\r
4 // (C) Sergey Chaban (serge@wildwestsoftware.com)
\r
8 using System.Collections;
\r
10 namespace Mono.ILASM {
\r
12 public class ILParser {
\r
14 private CodeGen codegen;
\r
16 public ILParser (CodeGen codegen) {
\r
17 this.codegen = codegen;
\r
20 public CodeGen CodeGen {
\r
21 get { return codegen; }
\r
28 /* ID - alpha-numeric identifier */
\r
31 /* QSTRING - quoted string */
\r
34 /* SQSTRING - single quoted string */
\r
37 /* INT32 - 32 bit integer */
\r
40 /* INT64 - 64 bit integer */
\r
43 /* FLOAT64 - floating point number */
\r
46 /* HEXBYTE - two digit hex number */
\r
52 %token OPEN_BRACE "{"
\r
53 %token CLOSE_BRACE "}"
\r
54 %token OPEN_BRACKET "["
\r
55 %token CLOSE_BRACKET "]"
\r
56 %token OPEN_PARENS "("
\r
57 %token CLOSE_PARENS ")"
\r
60 %token DOUBLE_COLON "::"
\r
61 %token SEMICOLON ";"
\r
64 %token AMPERSAND "&"
\r
68 %token ELLIPSIS "..."
\r
70 %token OPEN_ANGLE_BRACKET "<"
\r
71 %token CLOSE_ANGLE_BRACKET ">"
\r
78 /* INSTR_* instruction types */
\r
84 %token INSTR_BRTARGET
\r
102 /* Mechanically generated - DO NOT EDIT! */
\r
111 %token D_CAPABILITY
\r
121 %token D_ENTRYPOINT
\r
130 %token D_IMPLICITCOM
\r
136 %token D_MANIFESTRES
\r
143 %token D_ORIGINATOR
\r
149 %token D_PERMISSION
\r
150 %token D_PERMISSIONSET
\r
154 %token D_PUBLICKEYTOKEN
\r
171 %token K_IMPLICITCOM
\r
172 %token K_IMPLICITRES
\r
173 %token K_NOAPPDOMAIN
\r
197 %token K_RTSPECIALNAME
\r
198 %token K_SPECIALNAME
\r
200 %token K_FAMANDASSEM
\r
201 %token K_FAMORASSEM
\r
202 %token K_PRIVATESCOPE
\r
204 %token K_NOTSERIALIZED
\r
206 %token K_NOT_IN_GC_HEAP
\r
211 %token K_SEQUENTIAL
\r
216 %token K_SERIALIZABLE
\r
220 %token K_IMPLEMENTS
\r
225 %token K_UNMANAGEDEXP
\r
226 %token K_PINVOKEIMPL
\r
236 %token K_FORWARDREF
\r
238 %token K_INTERNALCALL
\r
239 %token K_SYNCHRONIZED
\r
240 %token K_NOINLINING
\r
281 %token K_USERDEFINED
\r
287 %token K_STREAMED_OBJECT
\r
288 %token K_STORED_OBJECT
\r
289 %token K_BLOB_OBJECT
\r
300 %token K_FROMUNMANAGED
\r
301 %token K_CALLMOSTDERIVED
\r
317 %token K_PERMITONLY
\r
319 %token K_INHERITCHECK
\r
323 %token K_PREJITGRANT
\r
324 %token K_PREJITDENY
\r
325 %token K_NONCASDEMAND
\r
326 %token K_NONCASLINKDEMAND
\r
327 %token K_NONCASINHERITANCE
\r
329 %token K_NOMETADATA
\r
331 %token K_FULLORIGIN
\r
335 %token K_ENABLEJITTRACKING
\r
336 %token K_DISABLEJITOPTIMIZER
\r
337 %token K_PRESERVESIG
\r
338 %token K_BEFOREFIELDINIT
\r
342 %token K_COMPILERCONTROLLED
\r
350 /* end generated */
\r
363 decls : /* EMPTY */
\r
381 | D_SUBSYSTEM int32
\r
383 | D_FILE K_ALIGNMENT int32
\r
384 /* | D_IMAGEBASE int64 */
\r
389 extsource_spec : D_LINE int32 SQSTRING
\r
391 | D_LINE int32 COLON int32 SQSTRING
\r
392 | D_LINE int32 COLON int32
\r
395 language_decl : D_LANGUAGE SQSTRING
\r
396 | D_LANGUAGE SQSTRING COMMA SQSTRING
\r
397 | D_LANGUAGE SQSTRING COMMA SQSTRING COMMA SQSTRING
\r
400 vtfixup_decl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET
\r
401 vtfixup_attr K_AT id
\r
404 vtfixup_attr : /* EMPTY */
\r
405 | vtfixup_attr int32
\r
406 | vtfixup_attr int64
\r
407 | vtfixup_attr K_FROMUNMANAGED
\r
408 | vtfixup_attr K_CALLMOSTDERIVED
\r
411 namespace_all : namespace_head OPEN_BRACE decls CLOSE_BRACE
\r
413 codegen.CurrentNameSpace = null;
\r
417 namespace_head : D_NAMESPACE comp_name
\r
419 codegen.CurrentNameSpace = (string) $2;
\r
423 class_all : class_head OPEN_BRACE class_decls CLOSE_BRACE
\r
425 codegen.EndTypeDef ();
\r
429 class_head : D_CLASS class_attr id typars_clause extends_clause
\r
432 codegen.BeginTypeDef ((TypeAttr) $2, (string) $3,
\r
433 $5 as IClassRef, $6 as ArrayList, null);
\r
436 // Lets not worry about generics for now :p
\r
438 ArrayList typars_list = (ArrayList) $4;
\r
440 foreach (DictionaryEntry entry in typars_list) {
\r
441 TypeRef type = (TypeRef) entry.Key;
\r
442 string name = (string) entry.Value;
\r
443 codegen.CurrentClass.AddGenericParameter ((short) index++, type.Type, name);
\r
450 class_attrs : class_attrs class_attr
\r
453 class_attr : /* EMPTY */ { $$ = new TypeAttr (); }
\r
454 | class_attr K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.Public; }
\r
455 | class_attr K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.Private; }
\r
456 | class_attr K_NESTED K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.NestedPrivate; }
\r
457 | class_attr K_NESTED K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.NestedPublic; }
\r
458 | class_attr K_NESTED K_FAMILY { $$ = (TypeAttr)$1 | TypeAttr.NestedFamily; }
\r
459 | class_attr K_NESTED K_ASSEMBLY { $$ = (TypeAttr)$1 | TypeAttr.NestedAssembly;}
\r
460 | class_attr K_NESTED K_FAMANDASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamAndAssem; }
\r
461 | class_attr K_NESTED K_FAMORASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamOrAssem; }
\r
462 | class_attr K_VALUE { }
\r
463 | class_attr K_ENUM { }
\r
464 | class_attr K_INTERFACE { $$ = (TypeAttr)$1 | TypeAttr.Interface; }
\r
465 | class_attr K_SEALED { $$ = (TypeAttr)$1 | TypeAttr.Sealed; }
\r
466 | class_attr K_ABSTRACT { $$ = (TypeAttr)$1 | TypeAttr.Abstract; }
\r
467 | class_attr K_AUTO { }
\r
468 | class_attr K_SEQUENTIAL { $$ = (TypeAttr)$1 | TypeAttr.SequentialLayout; }
\r
469 | class_attr K_EXPLICIT { $$ = (TypeAttr)$1 | TypeAttr.ExplicitLayout; }
\r
470 | class_attr K_ANSI { }
\r
471 | class_attr K_UNICODE { $$ = (TypeAttr)$1 | TypeAttr.UnicodeClass; }
\r
472 | class_attr K_AUTOCHAR { $$ = (TypeAttr)$1 | TypeAttr.AutoClass; }
\r
473 | class_attr K_IMPORT { $$ = (TypeAttr)$1 | TypeAttr.Import; }
\r
474 | class_attr K_SERIALIZABLE { $$ = (TypeAttr)$1 | TypeAttr.Serializable; }
\r
475 | class_attr K_BEFOREFIELDINIT { $$ = (TypeAttr)$1 | TypeAttr.BeforeFieldInit; }
\r
476 | class_attr K_SPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.SpecialName; }
\r
477 | class_attr K_RTSPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.RTSpecialName; }
\r
480 extends_clause : /* EMPTY */
\r
481 | K_EXTENDS class_ref
\r
487 impl_clause : /* EMPTY */
\r
488 | K_IMPLEMENTS class_refs
\r
494 typars_clause : /* EMPTY */
\r
495 | OPEN_ANGLE_BRACKET formal_typars CLOSE_ANGLE_BRACKET
\r
503 ArrayList typars_list = new ArrayList ();
\r
504 typars_list.Add ($1);
\r
507 | typars COMMA type
\r
509 ArrayList typars_list = (ArrayList) $1;
\r
510 typars_list.Add ($3);
\r
515 formal_typars : formal_typar
\r
517 ArrayList formal_list = new ArrayList ();
\r
518 formal_list.Add ($1);
\r
521 | formal_typars COMMA formal_typar
\r
523 ArrayList formal_list = (ArrayList) $1;
\r
524 formal_list.Add ($3);
\r
530 formal_typar : type { $$ = new DictionaryEntry ($1, null); }
\r
531 | type id { $$ = new DictionaryEntry ($1, $2); }
\r
534 class_refs : class_ref
\r
536 ArrayList class_list = new ArrayList ();
\r
537 class_list.Add ($1);
\r
540 | class_refs COMMA class_ref
\r
542 ArrayList class_list = (ArrayList) $1;
\r
543 class_list.Add ($3);
\r
547 slashed_name : comp_name
\r
548 | slashed_name SLASH comp_name
\r
550 $$ = String.Format ("{0}/{1}", $1, $3);
\r
554 class_ref : OPEN_BRACKET comp_name CLOSE_BRACKET slashed_name
\r
556 ClassRef klass = codegen.ExternTable.GetClass ((string) $2, (string)$4);
\r
557 $$ = new ExternTypeRef (klass, (string) $4);
\r
559 | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET slashed_name
\r
562 $$ = new TypeRef ((string) $1, null);
\r
566 class_decls : /* EMPTY */
\r
567 | class_decls class_decl
\r
570 class_decl : method_all
\r
584 | D_OVERRIDE type_spec DOUBLE_COLON method_name
\r
585 K_WITH call_conv type type_spec DOUBLE_COLON method_name
\r
586 OPEN_PARENS sig_args CLOSE_PARENS
\r
590 type : K_CLASS class_ref
\r
596 $$ = new PrimitiveTypeRef (PrimitiveType.Object, "System.Object");
\r
600 $$ = new PrimitiveTypeRef (PrimitiveType.String, "System.String");
\r
602 | K_VALUE K_CLASS class_ref
\r
606 | K_VALUETYPE class_ref
\r
610 | type OPEN_BRACKET CLOSE_BRACKET
\r
612 ITypeRef base_type = (ITypeRef) $1;
\r
613 base_type.MakeArray ();
\r
615 | type OPEN_BRACKET bounds CLOSE_BRACKET
\r
617 ITypeRef base_type = (ITypeRef) $1;
\r
618 ArrayList bound_list = (ArrayList) $3;
\r
619 base_type.MakeBoundArray (bound_list);
\r
623 ITypeRef base_type = (ITypeRef) $1;
\r
624 base_type.MakeManagedPointer ();
\r
628 ITypeRef base_type = (ITypeRef) $1;
\r
629 base_type.MakeUnmanagedPointer ();
\r
633 ITypeRef base_type = (ITypeRef) $1;
\r
634 base_type.MakePinned ();
\r
636 | type K_MODREQ OPEN_PARENS class_ref CLOSE_PARENS
\r
639 ITypeRef base_type = (ITypeRef) $1;
\r
640 ITypeRef class_ref = (ITypeRef) $4;
\r
642 $$ = new CustomModifiedType (base_type.Type,
\r
643 CustomModifier.modreq, (Class) class_ref.Type);
\r
646 | type K_MODOPT OPEN_PARENS class_ref CLOSE_PARENS
\r
649 TypeRef base_type = (TypeRef) $1;
\r
650 TypeRef class_ref = (TypeRef) $4;
\r
652 $$ = new CustomModifiedType (base_type.Type,
\r
653 CustomModifier.modopt, (Class) class_ref.Type);
\r
656 | K_METHOD call_conv type STAR OPEN_PARENS sig_args CLOSE_PARENS
\r
659 $$ = new PrimitiveTypeRef (PrimitiveType.TypedRef,
\r
660 "System.TypedReference");
\r
664 $$ = new PrimitiveTypeRef (PrimitiveType.Char, "System.Char");
\r
668 $$ = new PrimitiveTypeRef (PrimitiveType.Void, "System.Void");
\r
672 $$ = new PrimitiveTypeRef (PrimitiveType.Boolean, "System.Bool");
\r
676 $$ = new PrimitiveTypeRef (PrimitiveType.Int8, "System.Int8");
\r
680 $$ = new PrimitiveTypeRef (PrimitiveType.Int16, "System.Int16");
\r
684 $$ = new PrimitiveTypeRef (PrimitiveType.Int32, "System.Int32");
\r
688 $$ = new PrimitiveTypeRef (PrimitiveType.Int64, "System.Int64");
\r
692 $$ = new PrimitiveTypeRef (PrimitiveType.Float32, "System.Float32");
\r
696 $$ = new PrimitiveTypeRef (PrimitiveType.Float64, "System.Float64");
\r
698 | K_UNSIGNED K_INT8
\r
700 $$ = new PrimitiveTypeRef (PrimitiveType.UInt8, "System.UInt8");
\r
702 | K_UNSIGNED K_INT16
\r
704 $$ = new PrimitiveTypeRef (PrimitiveType.UInt16, "System.UInt16");
\r
706 | K_UNSIGNED K_INT32
\r
708 $$ = new PrimitiveTypeRef (PrimitiveType.UInt32, "System.UInt32");
\r
710 | K_UNSIGNED K_INT64
\r
712 $$ = new PrimitiveTypeRef (PrimitiveType.UInt64, "System.UInt64");
\r
716 // TODO: Is this the proper full name
\r
717 $$ = new PrimitiveTypeRef (PrimitiveType.NativeInt, "System.IntPtr");
\r
720 | K_NATIVE K_UNSIGNED K_INT
\r
722 $$ = new PrimitiveTypeRef (PrimitiveType.NativeUInt, "System.UIntPtr");
\r
726 // access class type parameter by number
\r
730 // access method type parameter by number
\r
736 ArrayList bound_list = new ArrayList ();
\r
737 bound_list.Add ($1);
\r
740 | bounds COMMA bound
\r
742 ArrayList bound_list = (ArrayList) $1;
\r
743 bound_list.Add ($3);
\r
747 bound : /* EMPTY */
\r
750 // No lower bound or size
\r
751 $$ = new DictionaryEntry (null,null);
\r
755 // ******** Not sure what this is?
\r
756 // For now I will say it is size because there
\r
757 // is allready a way to set lower
\r
758 $$ = new DictionaryEntry (null, $1);
\r
760 | int32 ELLIPSIS int32
\r
762 // lower bound and size
\r
763 $$ = new DictionaryEntry ($1, $3);
\r
767 // Just lower bound
\r
768 $$ = new DictionaryEntry ($1, null);
\r
772 call_conv : K_INSTANCE call_conv
\r
774 $$ = (CallConv) $2 | CallConv.Instance;
\r
776 | K_EXPLICIT call_conv
\r
778 $$ = (CallConv) $2 | CallConv.InstanceExplicit;
\r
783 call_kind : /* EMPTY */
\r
785 $$ = new CallConv ();
\r
789 $$ = CallConv.Default;
\r
793 $$ = CallConv.Vararg;
\r
795 | K_UNMANAGED K_CDECL
\r
797 $$ = CallConv.Cdecl;
\r
799 | K_UNMANAGED K_STDCALL
\r
801 $$ = CallConv.Stdcall;
\r
803 | K_UNMANAGED K_THISCALL
\r
805 $$ = CallConv.Thiscall;
\r
807 | K_UNMANAGED K_FASTCALL
\r
809 $$ = CallConv.Fastcall;
\r
813 native_type : /* EMPTY */
\r
814 | K_CUSTOM OPEN_PARENS comp_qstring COMMA comp_qstring CLOSE_PARENS
\r
815 | K_FIXED K_SYSSTRING OPEN_BRACKET int32 CLOSE_BRACKET
\r
817 $$ = NativeType.FixedSysString;
\r
819 | K_FIXED K_ARRAY OPEN_BRACKET int32 CLOSE_BRACKET
\r
823 $$ = NativeType.Currency;
\r
828 $$ = NativeType.Void;
\r
832 $$ = NativeType.Boolean;
\r
836 $$ = NativeType.Int8;
\r
840 $$ = NativeType.Int16;
\r
844 $$ = NativeType.Int32;
\r
848 $$ = NativeType.Int64;
\r
852 $$ = NativeType.Float32;
\r
856 $$ = NativeType.Float64;
\r
859 | K_UNSIGNED K_INT8
\r
861 $$ = NativeType.UInt8;
\r
863 | K_UNSIGNED K_INT16
\r
865 $$ = NativeType.UInt16;
\r
867 | K_UNSIGNED K_INT32
\r
869 $$ = NativeType.UInt32;
\r
871 | K_UNSIGNED K_INT64
\r
873 $$ = NativeType.UInt64;
\r
876 | native_type OPEN_BRACKET CLOSE_BRACKET
\r
877 | native_type OPEN_BRACKET int32 CLOSE_BRACKET
\r
878 | native_type OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET
\r
879 | native_type OPEN_BRACKET PLUS int32 CLOSE_BRACKET
\r
884 $$ = NativeType.BStr;
\r
888 $$ = NativeType.LPStr;
\r
892 $$ = NativeType.LPWStr;
\r
896 $$ = NativeType.LPTStr;
\r
901 $$ = NativeType.IUnknown;
\r
905 $$ = NativeType.IDispatch;
\r
909 $$ = NativeType.Struct;
\r
913 $$ = NativeType.Interface;
\r
915 | K_SAFEARRAY variant_type
\r
916 | K_SAFEARRAY variant_type COMMA comp_qstring
\r
919 $$ = NativeType.Int;
\r
923 $$ = NativeType.UInt;
\r
925 | K_NESTED K_STRUCT
\r
928 $$ = NativeType.ByValStr;
\r
932 $$ = NativeType.AnsiBStr;
\r
936 $$ = NativeType.TBstr;
\r
940 $$ = NativeType.VariantBool;
\r
945 $$ = NativeType.AsAny;
\r
950 variant_type : /* EMPTY */
\r
962 | K_UNSIGNED K_INT8
\r
963 | K_UNSIGNED K_INT16
\r
964 | K_UNSIGNED K_INT32
\r
965 | K_UNSIGNED K_INT64
\r
967 | variant_type OPEN_BRACKET CLOSE_BRACKET
\r
968 | variant_type K_VECTOR
\r
969 | variant_type AMPERSAND
\r
989 | K_STREAMED_OBJECT
\r
996 field_decl : D_FIELD repeat_opt field_attr type id at_opt init_opt
\r
998 FieldDef field_def = new FieldDef((FieldAttr) $3,
\r
999 (string) $5, (ITypeRef) $4);
\r
1000 codegen.AddFieldDef (field_def);
\r
1003 field_def.SetOffset ((uint) $2);
\r
1007 field_def.AddDataValue ((DataConstant) $6);
\r
1010 field_def.AddValue ((Constant) $7);
\r
1016 repeat_opt : /* EMPTY */
\r
1017 | OPEN_BRACKET int32 CLOSE_BRACKET
\r
1023 field_attr : /* EMPTY */
\r
1025 $$ = new FieldAttr ();
\r
1027 | field_attr K_PUBLIC
\r
1029 $$ = (FieldAttr) $1 | FieldAttr.Public;
\r
1031 | field_attr K_PRIVATE
\r
1033 $$ = (FieldAttr) $1 | FieldAttr.Private;
\r
1035 | field_attr K_FAMILY
\r
1037 $$ = (FieldAttr) $1 | FieldAttr.Family;
\r
1039 | field_attr K_ASSEMBLY
\r
1041 $$ = (FieldAttr) $1 | FieldAttr.Assembly;
\r
1043 | field_attr K_FAMANDASSEM
\r
1045 $$ = (FieldAttr) $1 | FieldAttr.FamAndAssem;
\r
1047 | field_attr K_FAMORASSEM
\r
1049 $$ = (FieldAttr) $1 | FieldAttr.FamOrAssem;
\r
1051 | field_attr K_PRIVATESCOPE
\r
1053 // This is just 0x0000
\r
1055 | field_attr K_STATIC
\r
1057 $$ = (FieldAttr) $1 | FieldAttr.Static;
\r
1059 | field_attr K_INITONLY
\r
1061 $$ = (FieldAttr) $1 | FieldAttr.Initonly;
\r
1063 | field_attr K_RTSPECIALNAME
\r
1065 $$ = (FieldAttr) $1 | FieldAttr.RTSpecialName;
\r
1067 | field_attr K_SPECIALNAME
\r
1069 $$ = (FieldAttr) $1 | FieldAttr.SpecialName;
\r
1071 | field_attr K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
\r
1075 | field_attr K_LITERAL
\r
1077 $$ = (FieldAttr) $1 | FieldAttr.Literal;
\r
1079 | field_attr K_NOTSERIALIZED
\r
1081 $$ = (FieldAttr) $1 | FieldAttr.Notserialized;
\r
1085 at_opt : /* EMPTY */
\r
1088 // TODO: Implement DataTable
\r
1089 // $$ = new DataConstant (DataTable.GetOffset ((string) $2));
\r
1093 init_opt : /* EMPTY */
\r
1094 | ASSIGN field_init
\r
1100 field_init : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
\r
1102 $$ = new FloatConst ((float) $3);
\r
1104 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS
\r
1106 $$ = new DoubleConst ((double) $3);
\r
1108 | K_FLOAT32 OPEN_PARENS int64 CLOSE_PARENS
\r
1110 $$ = new FloatConst ((float) $3);
\r
1112 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1114 $$ = new DoubleConst ((float) $3);
\r
1116 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1118 $$ = new IntConst ((long) $3);
\r
1120 | K_INT32 OPEN_PARENS int64 CLOSE_PARENS
\r
1122 $$ = new IntConst ((int) $3);
\r
1124 | K_INT16 OPEN_PARENS int64 CLOSE_PARENS
\r
1126 $$ = new IntConst ((short) $3);
\r
1128 | K_CHAR OPEN_PARENS int64 CLOSE_PARENS
\r
1130 $$ = new CharConst ((char) $3);
\r
1132 | K_INT8 OPEN_PARENS int64 CLOSE_PARENS
\r
1134 $$ = new IntConst ((sbyte) $3);
\r
1136 | K_BOOL OPEN_PARENS truefalse CLOSE_PARENS
\r
1138 $$ = new BoolConst ((bool) $3);
\r
1140 | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS
\r
1142 $$ = new ByteArrConst ((byte[]) $3);
\r
1146 // ******** THIS IS NOT IN THE DOCUMENTATION ******** //
\r
1147 $$ = new StringConst ((string) $1);
\r
1151 $$ = new NullConst ();
\r
1155 data_decl : data_head data_body
\r
1158 data_head : D_DATA tls id ASSIGN
\r
1166 data_body : OPEN_BRACE dataitem_list CLOSE_BRACE
\r
1170 dataitem_list : dataitem
\r
1171 | dataitem_list COMMA dataitem
\r
1174 dataitem : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
\r
1175 | AMPERSAND OPEN_PARENS id CLOSE_PARENS
\r
1176 | K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1178 $$ = new ByteArrConst ((byte[]) $4);
\r
1180 | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS
\r
1182 // ******** THIS IS NOT IN THE SPECIFICATION ******** //
\r
1183 $$ = new ByteArrConst ((byte[]) $4);
\r
1185 | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt
\r
1187 FloatConst float_const = new FloatConst ((float) $3);
\r
1188 $$ = new RepeatedConstant (float_const, (int) $5);
\r
1190 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS repeat_opt
\r
1192 DoubleConst double_const = new DoubleConst ((double) $3);
\r
1193 $$ = new RepeatedConstant (double_const, (int) $5);
\r
1195 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS repeat_opt
\r
1197 IntConst int_const = new IntConst ((long) $3);
\r
1198 $$ = new RepeatedConstant (int_const, (int) $5);
\r
1200 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
\r
1202 IntConst int_const = new IntConst ((int) $3);
\r
1203 $$ = new RepeatedConstant (int_const, (int) $5);
\r
1205 | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
\r
1207 IntConst int_const = new IntConst ((short) $3);
\r
1208 $$ = new RepeatedConstant (int_const, (int) $5);
\r
1210 | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
\r
1212 IntConst int_const = new IntConst ((sbyte) $3);
\r
1213 $$ = new RepeatedConstant (int_const, (int) $5);
\r
1215 | K_FLOAT32 repeat_opt
\r
1217 FloatConst float_const = new FloatConst (0F);
\r
1218 $$ = new RepeatedConstant (float_const, (int) $2);
\r
1220 | K_FLOAT64 repeat_opt
\r
1222 DoubleConst double_const = new DoubleConst (0);
\r
1223 $$ = new RepeatedConstant (double_const, (int) $2);
\r
1225 | K_INT64 repeat_opt
\r
1227 IntConst int_const = new IntConst ((long) 0);
\r
1228 $$ = new RepeatedConstant (int_const, (int) $2);
\r
1230 | K_INT32 repeat_opt
\r
1232 IntConst int_const = new IntConst ((int) 0);
\r
1233 $$ = new RepeatedConstant (int_const, (int) $2);
\r
1235 | K_INT16 repeat_opt
\r
1237 IntConst int_const = new IntConst ((short) 0);
\r
1238 $$ = new RepeatedConstant (int_const, (int) $2);
\r
1240 | K_INT8 repeat_opt
\r
1242 IntConst int_const = new IntConst ((sbyte) 0);
\r
1243 $$ = new RepeatedConstant (int_const, (int) $2);
\r
1247 method_all : method_head OPEN_BRACE method_decls CLOSE_BRACE
\r
1250 method_head : D_METHOD meth_attr call_conv param_attr type method_name
\r
1251 typars_clause OPEN_PARENS sig_args CLOSE_PARENS impl_attr
\r
1252 | D_METHOD meth_attr call_conv param_attr type
\r
1253 K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS method_name
\r
1254 OPEN_PARENS sig_args CLOSE_PARENS impl_attr
\r
1257 meth_attr : /* EMPTY */
\r
1258 | meth_attr K_STATIC
\r
1259 | meth_attr K_PUBLIC
\r
1260 | meth_attr K_PRIVATE
\r
1261 | meth_attr K_FAMILY
\r
1262 | meth_attr K_ASSEMBLY
\r
1263 | meth_attr K_FAMANDASSEM
\r
1264 | meth_attr K_FAMORASSEM
\r
1265 | meth_attr K_PRIVATESCOPE
\r
1266 | meth_attr K_FINAL
\r
1267 | meth_attr K_VIRTUAL
\r
1268 | meth_attr K_ABSTRACT
\r
1269 | meth_attr K_HIDEBYSIG
\r
1270 | meth_attr K_NEWSLOT
\r
1271 | meth_attr K_REQSECOBJ
\r
1272 | meth_attr K_SPECIALNAME
\r
1273 | meth_attr K_RTSPECIALNAME
\r
1274 | meth_attr K_UNMANAGEDEXP
\r
1275 | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring K_AS
\r
1276 comp_qstring pinv_attr CLOSE_PARENS
\r
1277 | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring pinv_attr CLOSE_PARENS
\r
1278 | meth_attr K_PINVOKEIMPL OPEN_PARENS pinv_attr CLOSE_PARENS
\r
1281 pinv_attr : /* EMPTY */
\r
1282 | pinv_attr K_NOMANGLE
\r
1283 | pinv_attr K_ANSI
\r
1284 | pinv_attr K_UNICODE
\r
1285 | pinv_attr K_AUTOCHAR
\r
1286 | pinv_attr K_LASTERR
\r
1287 | pinv_attr K_WINAPI
\r
1288 | pinv_attr K_CDECL
\r
1289 | pinv_attr K_STDCALL
\r
1290 | pinv_attr K_THISCALL
\r
1291 | pinv_attr K_FASTCALL
\r
1294 method_name : D_CTOR
\r
1299 param_attr : /* EMPTY */
\r
1300 | param_attr OPEN_BRACKET K_IN CLOSE_BRACKET
\r
1301 | param_attr OPEN_BRACKET K_OUT CLOSE_BRACKET
\r
1302 | param_attr OPEN_BRACKET K_OPT CLOSE_BRACKET
\r
1305 impl_attr : /* EMPTY */
\r
1306 | impl_attr K_NATIVE
\r
1308 | impl_attr K_OPTIL
\r
1309 | impl_attr K_MANAGED
\r
1310 | impl_attr K_UNMANAGED
\r
1311 | impl_attr K_FORWARDREF
\r
1312 | impl_attr K_PRESERVESIG
\r
1313 | impl_attr K_RUNTIME
\r
1314 | impl_attr K_INTERNALCALL
\r
1315 | impl_attr K_SYNCHRONIZED
\r
1316 | impl_attr K_NOINLINING
\r
1319 sig_args : /* EMPTY */
\r
1323 sig_arg_list : sig_arg
\r
1324 | sig_arg_list COMMA sig_arg
\r
1327 sig_arg : param_attr type
\r
1328 | param_attr type id
\r
1329 | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
\r
1330 | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id
\r
1333 method_decls : /* EMPTY */
\r
1334 | method_decls method_decl
\r
1337 method_decl : D_EMITBYTE int32
\r
1338 | D_MAXSTACK int32
\r
1339 | D_LOCALS OPEN_PARENS sig_args CLOSE_PARENS
\r
1340 | D_LOCALS K_INIT OPEN_PARENS sig_args CLOSE_PARENS
\r
1343 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET
\r
1344 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id
\r
1345 | D_VTENTRY int32 COLON int32
\r
1346 | D_OVERRIDE type_spec DOUBLE_COLON method_name
\r
1348 | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt
\r
1359 type_spec : class_ref
\r
1360 | OPEN_BRACKET comp_name CLOSE_BRACKET
\r
1361 | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET
\r
1365 scope_block : OPEN_BRACE method_decls CLOSE_BRACE
\r
1368 seh_block : try_block seh_clauses
\r
1371 try_block : D_TRY scope_block
\r
1372 | D_TRY id K_TO id
\r
1373 | D_TRY int32 K_TO int32
\r
1376 seh_clauses : seh_clause
\r
1377 | seh_clauses seh_clause
\r
1380 seh_clause : K_CATCH class_ref handler_block
\r
1381 | K_FINALLY handler_block
\r
1382 | K_FAULT handler_block
\r
1383 | filter_clause handler_block
\r
1386 filter_clause : K_FILTER scope_block
\r
1391 handler_block : scope_block
\r
1392 | K_HANDLER id K_TO id
\r
1393 | K_HANDLER int32 K_TO int32
\r
1396 instr : INSTR_NONE
\r
1399 | INSTR_I id /* Allow variable names :p */
\r
1403 | INSTR_R OPEN_PARENS bytes CLOSE_PARENS
\r
1404 | INSTR_BRTARGET int32
\r
1405 | INSTR_BRTARGET id
\r
1406 | INSTR_METHOD method_ref
\r
1407 | INSTR_FIELD type type_spec DOUBLE_COLON id
\r
1408 | INSTR_FIELD type id
\r
1409 | INSTR_TYPE K_FIELD type type_spec DOUBLE_COLON id // ****** ADDED
\r
1410 | INSTR_TYPE K_FIELD type id // ****** ADDED
\r
1411 | INSTR_TYPE type_spec
\r
1412 | INSTR_STRING comp_qstring
\r
1413 | INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1414 | INSTR_STRING K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS // ****** ADDED
\r
1415 | INSTR_SIG call_conv type OPEN_PARENS sig_args CLOSE_PARENS
\r
1416 | INSTR_TOK owner_type
\r
1417 | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS
\r
1420 method_ref : call_conv type type_spec DOUBLE_COLON method_name
\r
1421 OPEN_PARENS sig_args CLOSE_PARENS
\r
1422 | call_conv type method_name
\r
1423 OPEN_PARENS sig_args CLOSE_PARENS
\r
1426 labels : /* EMPTY */
\r
1430 | labels COMMA int32
\r
1433 owner_type : type_spec
\r
1437 member_ref : K_METHOD member_ref
\r
1438 | K_FIELD type type_spec DOUBLE_COLON id
\r
1442 event_all : event_head OPEN_BRACE event_decls CLOSE_BRACE
\r
1445 event_head : D_EVENT event_attr type_spec id
\r
1446 | D_EVENT event_attr id
\r
1449 event_attr : /* EMPTY */
\r
1450 | event_attr K_RTSPECIALNAME
\r
1451 | event_attr K_SPECIALNAME
\r
1454 event_decls : /* EMPTY */
\r
1455 | event_decls event_decl
\r
1458 event_decl : D_ADDON method_ref
\r
1459 | D_REMOVEON method_ref
\r
1460 | D_FIRE method_ref
\r
1461 | D_OTHER method_ref
\r
1467 prop_all : prop_head OPEN_BRACE prop_decls CLOSE_BRACE
\r
1470 prop_head : D_PROPERTY prop_attr type id OPEN_PARENS sig_args CLOSE_PARENS init_opt
\r
1473 prop_attr : /* EMPTY */
\r
1474 | prop_attr K_RTSPECIALNAME
\r
1475 | prop_attr K_SPECIALNAME
\r
1478 prop_decls : /* EMPTY */
\r
1479 | prop_decls prop_decl
\r
1482 prop_decl : D_SET method_ref
\r
1483 | D_GET method_ref
\r
1484 | D_OTHER method_ref
\r
1490 customattr_decl : D_CUSTOM custom_type
\r
1491 | D_CUSTOM custom_type ASSIGN comp_qstring
\r
1492 | D_CUSTOM custom_type ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1493 | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type
\r
1494 | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN comp_qstring
\r
1495 | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN
\r
1496 OPEN_PARENS bytes CLOSE_PARENS
\r
1499 custom_type : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS sig_args CLOSE_PARENS
\r
1500 | call_conv type D_CTOR OPEN_PARENS sig_args CLOSE_PARENS
\r
1503 sec_decl : D_PERMISSION sec_action type_spec OPEN_PARENS nameval_pairs CLOSE_PARENS
\r
1504 | D_PERMISSION sec_action type_spec
\r
1505 | D_PERMISSIONSET sec_action ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1508 nameval_pairs : nameval_pair
\r
1509 | nameval_pairs COMMA nameval_pair
\r
1512 nameval_pair : comp_qstring ASSIGN cavalue
\r
1515 cavalue : truefalse
\r
1517 | int32 OPEN_PARENS int32 CLOSE_PARENS
\r
1519 | class_ref OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS
\r
1520 | class_ref OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS
\r
1521 | class_ref OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS
\r
1522 | class_ref OPEN_PARENS int32 CLOSE_PARENS
\r
1525 sec_action : K_REQUEST
\r
1538 | K_NONCASLINKDEMAND
\r
1539 | K_NONCASINHERITANCE
\r
1542 module_head : D_MODULE
\r
1543 | D_MODULE comp_name
\r
1544 | D_MODULE K_EXTERN comp_name
\r
1547 file_decl : D_FILE file_attr comp_name file_entry D_HASH ASSIGN
\r
1548 OPEN_PARENS bytes CLOSE_PARENS file_entry
\r
1549 | D_FILE file_attr comp_name file_entry
\r
1552 file_attr : /* EMPTY */
\r
1553 | file_attr K_NOMETADATA
\r
1556 file_entry : /* EMPTY */
\r
1560 assembly_all : assembly_head OPEN_BRACE assembly_decls CLOSE_BRACE
\r
1563 assembly_head : D_ASSEMBLY asm_attr comp_name
\r
1566 asm_attr : /* EMPTY */
\r
1567 | asm_attr K_NOAPPDOMAIN
\r
1568 | asm_attr K_NOPROCESS
\r
1569 | asm_attr K_NOMACHINE
\r
1572 assembly_decls : /* EMPTY */
\r
1573 | assembly_decls assembly_decl
\r
1576 assembly_decl : D_HASH K_ALGORITHM int32
\r
1581 asm_or_ref_decl : D_PUBLICKEY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1582 | D_VER int32 COLON int32 COLON int32 COLON int32
\r
1583 | D_LOCALE comp_qstring
\r
1584 | D_LOCALE ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1588 assemblyref_all : assemblyref_head OPEN_BRACE assemblyref_decls CLOSE_BRACE
\r
1591 assemblyref_head : D_ASSEMBLY K_EXTERN comp_name
\r
1593 System.Reflection.AssemblyName asmb_name =
\r
1594 new System.Reflection.AssemblyName ();
\r
1595 asmb_name.Name = (string) $3;
\r
1596 codegen.ExternTable.AddAssembly ((string) $3, asmb_name);
\r
1598 | D_ASSEMBLY K_EXTERN comp_name K_AS comp_name
\r
1600 System.Reflection.AssemblyName asmb_name =
\r
1601 new System.Reflection.AssemblyName ();
\r
1602 asmb_name.Name = (string) $3;
\r
1603 codegen.ExternTable.AddAssembly ((string) $5, asmb_name);
\r
1607 assemblyref_decls : /* EMPTY */
\r
1608 | assemblyref_decls assemblyref_decl
\r
1611 assemblyref_decl : D_HASH ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1613 | D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1616 exptype_all : exptype_head OPEN_BRACE exptype_decls CLOSE_BRACE
\r
1619 exptype_head : D_CLASS K_EXTERN expt_attr comp_name
\r
1622 expt_attr : /* EMPTY */
\r
1623 | expt_attr K_PRIVATE
\r
1624 | expt_attr K_PUBLIC
\r
1625 | expt_attr K_NESTED K_PUBLIC
\r
1626 | expt_attr K_NESTED K_PRIVATE
\r
1627 | expt_attr K_NESTED K_FAMILY
\r
1628 | expt_attr K_NESTED K_ASSEMBLY
\r
1629 | expt_attr K_NESTED K_FAMANDASSEM
\r
1630 | expt_attr K_NESTED K_FAMORASSEM
\r
1633 exptype_decls : /* EMPTY */
\r
1634 | exptype_decls exptype_decl
\r
1637 exptype_decl : D_FILE comp_name
\r
1638 | D_CLASS K_EXTERN comp_name
\r
1643 manifestres_all : manifestres_head OPEN_BRACE manifestres_decls CLOSE_BRACE
\r
1646 manifestres_head : D_MRESOURCE manres_attr comp_name
\r
1649 manres_attr : /* EMPTY */
\r
1650 | manres_attr K_PUBLIC
\r
1651 | manres_attr K_PRIVATE
\r
1654 manifestres_decls : /* EMPTY */
\r
1655 | manifestres_decls manifestres_decl
\r
1658 manifestres_decl : D_FILE comp_name K_AT int32
\r
1659 | D_ASSEMBLY K_EXTERN comp_name
\r
1664 | dotted_name DOT id { $$ = String.Format ("{0}.{1}", $1, $3); }
\r
1667 comp_qstring : QSTRING
\r
1668 | comp_qstring PLUS QSTRING { $$ = String.Format ("{0}{1}", $1, $3); }
\r
1680 | K_FLOAT32 OPEN_PARENS int32 CLOSE_PARENS
\r
1681 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1685 | INT32 // ******** ADDED
\r
1686 | ID // ******** ADDED
\r
1689 bytes : /* EMPTY */
\r
1693 hexbytes : hexbyte
\r
1694 | hexbytes hexbyte
\r
1697 truefalse : K_TRUE
\r
1710 | dotted_name DOT id
\r