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.CompleteClass ();
\r
429 class_head : D_CLASS class_attr id typars_clause extends_clause
\r
433 codegen.AddClass ((TypeAttr) $2, (string) $3,
\r
434 ((TypeRef)$5).Type as Class, null);
\r
436 codegen.AddClass ((TypeAttr)$2, (string) $3, null);
\r
439 ArrayList impl_list = (ArrayList) $6;
\r
440 if (impl_list != null) {
\r
441 foreach (TypeRef type_ref in impl_list)
\r
442 codegen.CurrentClass.AddImplementedInterface (type_ref.Type as Class);
\r
446 ArrayList typars_list = (ArrayList) $4;
\r
448 foreach (DictionaryEntry entry in typars_list) {
\r
449 TypeRef type = (TypeRef) entry.Key;
\r
450 string name = (string) entry.Value;
\r
451 codegen.CurrentClass.AddGenericParameter ((short) index++, type.Type, name);
\r
457 class_attrs : class_attrs class_attr
\r
460 class_attr : /* EMPTY */ { $$ = new TypeAttr (); }
\r
461 | class_attr K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.Public; }
\r
462 | class_attr K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.Private; }
\r
463 | class_attr K_NESTED K_PRIVATE { $$ = (TypeAttr)$1 | TypeAttr.NestedPrivate; }
\r
464 | class_attr K_NESTED K_PUBLIC { $$ = (TypeAttr)$1 | TypeAttr.NestedPublic; }
\r
465 | class_attr K_NESTED K_FAMILY { $$ = (TypeAttr)$1 | TypeAttr.NestedFamily; }
\r
466 | class_attr K_NESTED K_ASSEMBLY { $$ = (TypeAttr)$1 | TypeAttr.NestedAssembly;}
\r
467 | class_attr K_NESTED K_FAMANDASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamAndAssem; }
\r
468 | class_attr K_NESTED K_FAMORASSEM { $$ = (TypeAttr)$1 | TypeAttr.NestedFamOrAssem; }
\r
469 | class_attr K_VALUE { }
\r
470 | class_attr K_ENUM { }
\r
471 | class_attr K_INTERFACE { $$ = (TypeAttr)$1 | TypeAttr.Interface; }
\r
472 | class_attr K_SEALED { $$ = (TypeAttr)$1 | TypeAttr.Sealed; }
\r
473 | class_attr K_ABSTRACT { $$ = (TypeAttr)$1 | TypeAttr.Abstract; }
\r
474 | class_attr K_AUTO { }
\r
475 | class_attr K_SEQUENTIAL { $$ = (TypeAttr)$1 | TypeAttr.SequentialLayout; }
\r
476 | class_attr K_EXPLICIT { $$ = (TypeAttr)$1 | TypeAttr.ExplicitLayout; }
\r
477 | class_attr K_ANSI { }
\r
478 | class_attr K_UNICODE { $$ = (TypeAttr)$1 | TypeAttr.UnicodeClass; }
\r
479 | class_attr K_AUTOCHAR { $$ = (TypeAttr)$1 | TypeAttr.AutoClass; }
\r
480 | class_attr K_IMPORT { $$ = (TypeAttr)$1 | TypeAttr.Import; }
\r
481 | class_attr K_SERIALIZABLE { $$ = (TypeAttr)$1 | TypeAttr.Serializable; }
\r
482 | class_attr K_BEFOREFIELDINIT { $$ = (TypeAttr)$1 | TypeAttr.BeforeFieldInit; }
\r
483 | class_attr K_SPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.SpecialName; }
\r
484 | class_attr K_RTSPECIALNAME { $$ = (TypeAttr)$1 | TypeAttr.RTSpecialName; }
\r
487 extends_clause : /* EMPTY */
\r
488 | K_EXTENDS class_ref
\r
494 impl_clause : /* EMPTY */
\r
495 | K_IMPLEMENTS class_refs
\r
501 typars_clause : /* EMPTY */
\r
502 | OPEN_ANGLE_BRACKET formal_typars CLOSE_ANGLE_BRACKET
\r
510 ArrayList typars_list = new ArrayList ();
\r
511 typars_list.Add ($1);
\r
514 | typars COMMA type
\r
516 ArrayList typars_list = (ArrayList) $1;
\r
517 typars_list.Add ($3);
\r
522 formal_typars : formal_typar
\r
524 ArrayList formal_list = new ArrayList ();
\r
525 formal_list.Add ($1);
\r
528 | formal_typars COMMA formal_typar
\r
530 ArrayList formal_list = (ArrayList) $1;
\r
531 formal_list.Add ($3);
\r
537 formal_typar : type { $$ = new DictionaryEntry ($1, null); }
\r
538 | type id { $$ = new DictionaryEntry ($1, $2); }
\r
541 class_refs : class_ref
\r
543 ArrayList class_list = new ArrayList ();
\r
544 class_list.Add ($1);
\r
547 | class_refs COMMA class_ref
\r
549 ArrayList class_list = (ArrayList) $1;
\r
550 class_list.Add ($3);
\r
554 slashed_name : comp_name
\r
555 | slashed_name SLASH comp_name
\r
557 $$ = String.Format ("{0}/{1}", $1, $3);
\r
561 class_ref : OPEN_BRACKET comp_name CLOSE_BRACKET slashed_name
\r
563 Class klass = codegen.ExternTable.GetClass ((string) $2, (string)$4);
\r
564 $$ = new TypeRef (klass, (string) $4);
\r
566 | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET slashed_name
\r
569 $$ = new TypeRef (codegen.ClassTable.GetReference ((string) $1, null),
\r
574 class_decls : /* EMPTY */
\r
575 | class_decls class_decl
\r
578 class_decl : method_all
\r
592 | D_OVERRIDE type_spec DOUBLE_COLON method_name
\r
593 K_WITH call_conv type type_spec DOUBLE_COLON method_name
\r
594 OPEN_PARENS sig_args CLOSE_PARENS
\r
598 type : K_CLASS class_ref
\r
604 $$ = new TypeRef (PrimitiveType.Object, "System.Object");
\r
608 $$ = new TypeRef (PrimitiveType.String, "System.String");
\r
610 | K_VALUE K_CLASS class_ref
\r
614 | K_VALUETYPE class_ref
\r
618 | type OPEN_BRACKET CLOSE_BRACKET
\r
620 TypeRef base_type = (TypeRef) $1;
\r
621 PEAPI.Type arr_type = new ZeroBasedArray (base_type.Type);
\r
622 $$ = new TypeRef (arr_type, base_type.FullName + "[]");
\r
624 | type OPEN_BRACKET bounds CLOSE_BRACKET
\r
626 TypeRef base_type = (TypeRef) $1;
\r
627 ArrayList bound_list = (ArrayList) $3;
\r
628 int dimen = bound_list.Count;
\r
629 int[] lower_array = new int[dimen];
\r
630 int[] size_array = new int[dimen];
\r
631 bool lower_set = false;
\r
632 bool size_set = false;
\r
633 bool prev_lower_set = true;
\r
634 bool prev_size_set = true;
\r
636 // TODO: There should probably be an error reported if
\r
637 // something like [3...,3...5] is done
\r
638 for (int i=0; i<dimen; i++) {
\r
639 DictionaryEntry bound = (DictionaryEntry) bound_list[i];
\r
641 if (bound.Key != null && prev_lower_set) {
\r
642 lower_array[i] = (int) bound.Key;
\r
645 prev_lower_set = false;
\r
647 if (bound.Value != null && prev_size_set) {
\r
648 size_array[i] = (int) bound.Value;
\r
651 prev_size_set = false;
\r
654 if (lower_set && size_set) {
\r
655 $$ = new BoundArray (base_type.Type,
\r
656 (uint) dimen, lower_array, size_array);
\r
657 } else if (size_set) {
\r
658 $$ = new BoundArray (base_type.Type,
\r
659 (uint) dimen, size_array);
\r
661 $$ = new BoundArray (base_type.Type, (uint) dimen);
\r
666 TypeRef base_type = $1 as TypeRef;
\r
667 PEAPI.Type ref_type = new ManagedPointer (base_type.Type);
\r
668 $$ = new TypeRef (ref_type, base_type.FullName + '&');
\r
672 TypeRef base_type = (TypeRef) $1;
\r
673 PEAPI.Type ptr_type = new UnmanagedPointer (base_type.Type);
\r
674 $$ = new TypeRef (ptr_type, base_type.FullName + '&');
\r
678 TypeRef type = (TypeRef) $1;
\r
679 type.Pinned = true;
\r
681 | type K_MODREQ OPEN_PARENS class_ref CLOSE_PARENS
\r
683 TypeRef base_type = (TypeRef) $1;
\r
684 TypeRef class_ref = (TypeRef) $4;
\r
686 $$ = new CustomModifiedType (base_type.Type,
\r
687 CustomModifier.modreq, (Class) class_ref.Type);
\r
689 | type K_MODOPT OPEN_PARENS class_ref CLOSE_PARENS
\r
691 TypeRef base_type = (TypeRef) $1;
\r
692 TypeRef class_ref = (TypeRef) $4;
\r
694 $$ = new CustomModifiedType (base_type.Type,
\r
695 CustomModifier.modopt, (Class) class_ref.Type);
\r
697 | K_METHOD call_conv type STAR OPEN_PARENS sig_args CLOSE_PARENS
\r
700 $$ = new TypeRef (PrimitiveType.TypedRef,
\r
701 "System.TypedReference");
\r
705 $$ = new TypeRef (PrimitiveType.Char, "System.Char");
\r
709 $$ = new TypeRef (PrimitiveType.Void, "System.Void");
\r
713 $$ = new TypeRef (PrimitiveType.Boolean, "System.Bool");
\r
717 $$ = new TypeRef (PrimitiveType.Int8, "System.Int8");
\r
721 $$ = new TypeRef (PrimitiveType.Int16, "System.Int16");
\r
725 $$ = new TypeRef (PrimitiveType.Int32, "System.Int32");
\r
729 $$ = new TypeRef (PrimitiveType.Int64, "System.Int64");
\r
733 $$ = new TypeRef (PrimitiveType.Float32, "System.Float32");
\r
737 $$ = new TypeRef (PrimitiveType.Float64, "System.Float64");
\r
739 | K_UNSIGNED K_INT8
\r
741 $$ = new TypeRef (PrimitiveType.UInt8, "System.UInt8");
\r
743 | K_UNSIGNED K_INT16
\r
745 $$ = new TypeRef (PrimitiveType.UInt16, "System.UInt16");
\r
747 | K_UNSIGNED K_INT32
\r
749 $$ = new TypeRef (PrimitiveType.UInt32, "System.UInt32");
\r
751 | K_UNSIGNED K_INT64
\r
753 $$ = new TypeRef (PrimitiveType.UInt64, "System.UInt64");
\r
757 // TODO: Is this the proper full name
\r
758 $$ = new TypeRef (PrimitiveType.NativeInt, "System.IntPtr");
\r
761 | K_NATIVE K_UNSIGNED K_INT
\r
763 // TODO: Is this the proper full name
\r
764 $$ = new TypeRef (PrimitiveType.NativeUInt, "System.UIntPtr");
\r
768 // access class type parameter by number
\r
772 // access method type parameter by number
\r
778 ArrayList bound_list = new ArrayList ();
\r
779 bound_list.Add ($1);
\r
782 | bounds COMMA bound
\r
784 ArrayList bound_list = (ArrayList) $1;
\r
785 bound_list.Add ($3);
\r
789 bound : /* EMPTY */
\r
792 // No lower bound or size
\r
793 $$ = new DictionaryEntry (null,null);
\r
797 // ******** Not sure what this is?
\r
798 // For now I will say it is size because there
\r
799 // is allready a way to set lower
\r
800 $$ = new DictionaryEntry (null, $1);
\r
802 | int32 ELLIPSIS int32
\r
804 // lower bound and size
\r
805 $$ = new DictionaryEntry ($1, $3);
\r
809 // Just lower bound
\r
810 $$ = new DictionaryEntry ($1, null);
\r
814 call_conv : K_INSTANCE call_conv
\r
816 $$ = (CallConv) $2 | CallConv.Instance;
\r
818 | K_EXPLICIT call_conv
\r
820 $$ = (CallConv) $2 | CallConv.InstanceExplicit;
\r
825 call_kind : /* EMPTY */
\r
827 $$ = new CallConv ();
\r
831 $$ = CallConv.Default;
\r
835 $$ = CallConv.Vararg;
\r
837 | K_UNMANAGED K_CDECL
\r
839 $$ = CallConv.Cdecl;
\r
841 | K_UNMANAGED K_STDCALL
\r
843 $$ = CallConv.Stdcall;
\r
845 | K_UNMANAGED K_THISCALL
\r
847 $$ = CallConv.Thiscall;
\r
849 | K_UNMANAGED K_FASTCALL
\r
851 $$ = CallConv.Fastcall;
\r
855 native_type : /* EMPTY */
\r
856 | K_CUSTOM OPEN_PARENS comp_qstring COMMA comp_qstring CLOSE_PARENS
\r
857 | K_FIXED K_SYSSTRING OPEN_BRACKET int32 CLOSE_BRACKET
\r
859 $$ = NativeType.FixedSysString;
\r
861 | K_FIXED K_ARRAY OPEN_BRACKET int32 CLOSE_BRACKET
\r
865 $$ = NativeType.Currency;
\r
870 $$ = NativeType.Void;
\r
874 $$ = NativeType.Boolean;
\r
878 $$ = NativeType.Int8;
\r
882 $$ = NativeType.Int16;
\r
886 $$ = NativeType.Int32;
\r
890 $$ = NativeType.Int64;
\r
894 $$ = NativeType.Float32;
\r
898 $$ = NativeType.Float64;
\r
901 | K_UNSIGNED K_INT8
\r
903 $$ = NativeType.UInt8;
\r
905 | K_UNSIGNED K_INT16
\r
907 $$ = NativeType.UInt16;
\r
909 | K_UNSIGNED K_INT32
\r
911 $$ = NativeType.UInt32;
\r
913 | K_UNSIGNED K_INT64
\r
915 $$ = NativeType.UInt64;
\r
918 | native_type OPEN_BRACKET CLOSE_BRACKET
\r
919 | native_type OPEN_BRACKET int32 CLOSE_BRACKET
\r
920 | native_type OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET
\r
921 | native_type OPEN_BRACKET PLUS int32 CLOSE_BRACKET
\r
926 $$ = NativeType.BStr;
\r
930 $$ = NativeType.LPStr;
\r
934 $$ = NativeType.LPWStr;
\r
938 $$ = NativeType.LPTStr;
\r
943 $$ = NativeType.IUnknown;
\r
947 $$ = NativeType.IDispatch;
\r
951 $$ = NativeType.Struct;
\r
955 $$ = NativeType.Interface;
\r
957 | K_SAFEARRAY variant_type
\r
958 | K_SAFEARRAY variant_type COMMA comp_qstring
\r
961 $$ = NativeType.Int;
\r
965 $$ = NativeType.UInt;
\r
967 | K_NESTED K_STRUCT
\r
970 $$ = NativeType.ByValStr;
\r
974 $$ = NativeType.AnsiBStr;
\r
978 $$ = NativeType.TBstr;
\r
982 $$ = NativeType.VariantBool;
\r
987 $$ = NativeType.AsAny;
\r
992 variant_type : /* EMPTY */
\r
1004 | K_UNSIGNED K_INT8
\r
1005 | K_UNSIGNED K_INT16
\r
1006 | K_UNSIGNED K_INT32
\r
1007 | K_UNSIGNED K_INT64
\r
1009 | variant_type OPEN_BRACKET CLOSE_BRACKET
\r
1010 | variant_type K_VECTOR
\r
1011 | variant_type AMPERSAND
\r
1021 | K_UNSIGNED K_INT
\r
1031 | K_STREAMED_OBJECT
\r
1038 field_decl : D_FIELD repeat_opt field_attr type id at_opt init_opt
\r
1040 FieldDef field_def = codegen.AddField ((FieldAttr) $3,
\r
1041 (string) $5, (TypeRef) $4, null);
\r
1042 codegen.AddField (0, "test_field", (TypeRef) $4, null);
\r
1044 field_def.SetOffset ((uint) $2);
\r
1047 field_def.AddDataValue ((DataConstant) $6);
\r
1050 field_def.AddValue ((Constant) $7);
\r
1055 repeat_opt : /* EMPTY */
\r
1056 | OPEN_BRACKET int32 CLOSE_BRACKET
\r
1062 field_attr : /* EMPTY */
\r
1064 $$ = new FieldAttr ();
\r
1066 | field_attr K_PUBLIC
\r
1068 $$ = (FieldAttr) $1 | FieldAttr.Public;
\r
1070 | field_attr K_PRIVATE
\r
1072 $$ = (FieldAttr) $1 | FieldAttr.Private;
\r
1074 | field_attr K_FAMILY
\r
1076 $$ = (FieldAttr) $1 | FieldAttr.Family;
\r
1078 | field_attr K_ASSEMBLY
\r
1080 $$ = (FieldAttr) $1 | FieldAttr.Assembly;
\r
1082 | field_attr K_FAMANDASSEM
\r
1084 $$ = (FieldAttr) $1 | FieldAttr.FamAndAssem;
\r
1086 | field_attr K_FAMORASSEM
\r
1088 $$ = (FieldAttr) $1 | FieldAttr.FamOrAssem;
\r
1090 | field_attr K_PRIVATESCOPE
\r
1092 // This is just 0x0000
\r
1094 | field_attr K_STATIC
\r
1096 $$ = (FieldAttr) $1 | FieldAttr.Static;
\r
1098 | field_attr K_INITONLY
\r
1100 $$ = (FieldAttr) $1 | FieldAttr.Initonly;
\r
1102 | field_attr K_RTSPECIALNAME
\r
1104 $$ = (FieldAttr) $1 | FieldAttr.RTSpecialName;
\r
1106 | field_attr K_SPECIALNAME
\r
1108 $$ = (FieldAttr) $1 | FieldAttr.SpecialName;
\r
1110 | field_attr K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
\r
1114 | field_attr K_LITERAL
\r
1116 $$ = (FieldAttr) $1 | FieldAttr.Literal;
\r
1118 | field_attr K_NOTSERIALIZED
\r
1120 $$ = (FieldAttr) $1 | FieldAttr.Notserialized;
\r
1124 at_opt : /* EMPTY */
\r
1127 // TODO: Implement DataTable
\r
1128 // $$ = new DataConstant (DataTable.GetOffset ((string) $2));
\r
1132 init_opt : /* EMPTY */
\r
1133 | ASSIGN field_init
\r
1139 field_init : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
\r
1141 $$ = new FloatConst ((float) $3);
\r
1143 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS
\r
1145 $$ = new DoubleConst ((double) $3);
\r
1147 | K_FLOAT32 OPEN_PARENS int64 CLOSE_PARENS
\r
1149 $$ = new FloatConst ((float) $3);
\r
1151 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1153 $$ = new DoubleConst ((float) $3);
\r
1155 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1157 $$ = new IntConst ((long) $3);
\r
1159 | K_INT32 OPEN_PARENS int64 CLOSE_PARENS
\r
1161 $$ = new IntConst ((int) $3);
\r
1163 | K_INT16 OPEN_PARENS int64 CLOSE_PARENS
\r
1165 $$ = new IntConst ((short) $3);
\r
1167 | K_CHAR OPEN_PARENS int64 CLOSE_PARENS
\r
1169 $$ = new CharConst ((char) $3);
\r
1171 | K_INT8 OPEN_PARENS int64 CLOSE_PARENS
\r
1173 $$ = new IntConst ((sbyte) $3);
\r
1175 | K_BOOL OPEN_PARENS truefalse CLOSE_PARENS
\r
1177 $$ = new BoolConst ((bool) $3);
\r
1179 | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS
\r
1181 $$ = new ByteArrConst ((byte[]) $3);
\r
1185 // ******** THIS IS NOT IN THE DOCUMENTATION ******** //
\r
1186 $$ = new StringConst ((string) $1);
\r
1190 $$ = new NullConst ();
\r
1194 data_decl : data_head data_body
\r
1197 data_head : D_DATA tls id ASSIGN
\r
1205 data_body : OPEN_BRACE dataitem_list CLOSE_BRACE
\r
1209 dataitem_list : dataitem
\r
1210 | dataitem_list COMMA dataitem
\r
1213 dataitem : K_CHAR STAR OPEN_PARENS comp_qstring CLOSE_PARENS
\r
1214 | AMPERSAND OPEN_PARENS id CLOSE_PARENS
\r
1215 | K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1216 | K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS // ******** ADDED
\r
1217 | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS repeat_opt
\r
1218 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS repeat_opt
\r
1219 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS repeat_opt
\r
1220 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
\r
1221 | K_INT16 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
\r
1222 | K_INT8 OPEN_PARENS int32 CLOSE_PARENS repeat_opt
\r
1223 | K_FLOAT32 repeat_opt
\r
1224 | K_FLOAT64 repeat_opt
\r
1225 | K_INT64 repeat_opt
\r
1226 | K_INT32 repeat_opt
\r
1227 | K_INT16 repeat_opt
\r
1228 | K_INT8 repeat_opt
\r
1231 method_all : method_head OPEN_BRACE method_decls CLOSE_BRACE
\r
1234 method_head : D_METHOD meth_attr call_conv param_attr type method_name
\r
1235 typars_clause OPEN_PARENS sig_args CLOSE_PARENS impl_attr
\r
1236 | D_METHOD meth_attr call_conv param_attr type
\r
1237 K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS method_name
\r
1238 OPEN_PARENS sig_args CLOSE_PARENS impl_attr
\r
1241 meth_attr : /* EMPTY */
\r
1242 | meth_attr K_STATIC
\r
1243 | meth_attr K_PUBLIC
\r
1244 | meth_attr K_PRIVATE
\r
1245 | meth_attr K_FAMILY
\r
1246 | meth_attr K_ASSEMBLY
\r
1247 | meth_attr K_FAMANDASSEM
\r
1248 | meth_attr K_FAMORASSEM
\r
1249 | meth_attr K_PRIVATESCOPE
\r
1250 | meth_attr K_FINAL
\r
1251 | meth_attr K_VIRTUAL
\r
1252 | meth_attr K_ABSTRACT
\r
1253 | meth_attr K_HIDEBYSIG
\r
1254 | meth_attr K_NEWSLOT
\r
1255 | meth_attr K_REQSECOBJ
\r
1256 | meth_attr K_SPECIALNAME
\r
1257 | meth_attr K_RTSPECIALNAME
\r
1258 | meth_attr K_UNMANAGEDEXP
\r
1259 | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring K_AS
\r
1260 comp_qstring pinv_attr CLOSE_PARENS
\r
1261 | meth_attr K_PINVOKEIMPL OPEN_PARENS comp_qstring pinv_attr CLOSE_PARENS
\r
1262 | meth_attr K_PINVOKEIMPL OPEN_PARENS pinv_attr CLOSE_PARENS
\r
1265 pinv_attr : /* EMPTY */
\r
1266 | pinv_attr K_NOMANGLE
\r
1267 | pinv_attr K_ANSI
\r
1268 | pinv_attr K_UNICODE
\r
1269 | pinv_attr K_AUTOCHAR
\r
1270 | pinv_attr K_LASTERR
\r
1271 | pinv_attr K_WINAPI
\r
1272 | pinv_attr K_CDECL
\r
1273 | pinv_attr K_STDCALL
\r
1274 | pinv_attr K_THISCALL
\r
1275 | pinv_attr K_FASTCALL
\r
1278 method_name : D_CTOR
\r
1283 param_attr : /* EMPTY */
\r
1284 | param_attr OPEN_BRACKET K_IN CLOSE_BRACKET
\r
1285 | param_attr OPEN_BRACKET K_OUT CLOSE_BRACKET
\r
1286 | param_attr OPEN_BRACKET K_OPT CLOSE_BRACKET
\r
1289 impl_attr : /* EMPTY */
\r
1290 | impl_attr K_NATIVE
\r
1292 | impl_attr K_OPTIL
\r
1293 | impl_attr K_MANAGED
\r
1294 | impl_attr K_UNMANAGED
\r
1295 | impl_attr K_FORWARDREF
\r
1296 | impl_attr K_PRESERVESIG
\r
1297 | impl_attr K_RUNTIME
\r
1298 | impl_attr K_INTERNALCALL
\r
1299 | impl_attr K_SYNCHRONIZED
\r
1300 | impl_attr K_NOINLINING
\r
1303 sig_args : /* EMPTY */
\r
1307 sig_arg_list : sig_arg
\r
1308 | sig_arg_list COMMA sig_arg
\r
1311 sig_arg : param_attr type
\r
1312 | param_attr type id
\r
1313 | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
\r
1314 | param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id
\r
1317 method_decls : /* EMPTY */
\r
1318 | method_decls method_decl
\r
1321 method_decl : D_EMITBYTE int32
\r
1322 | D_MAXSTACK int32
\r
1323 | D_LOCALS OPEN_PARENS sig_args CLOSE_PARENS
\r
1324 | D_LOCALS K_INIT OPEN_PARENS sig_args CLOSE_PARENS
\r
1327 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET
\r
1328 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id
\r
1329 | D_VTENTRY int32 COLON int32
\r
1330 | D_OVERRIDE type_spec DOUBLE_COLON method_name
\r
1332 | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt
\r
1343 type_spec : class_ref
\r
1344 | OPEN_BRACKET comp_name CLOSE_BRACKET
\r
1345 | OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET
\r
1349 scope_block : OPEN_BRACE method_decls CLOSE_BRACE
\r
1352 seh_block : try_block seh_clauses
\r
1355 try_block : D_TRY scope_block
\r
1356 | D_TRY id K_TO id
\r
1357 | D_TRY int32 K_TO int32
\r
1360 seh_clauses : seh_clause
\r
1361 | seh_clauses seh_clause
\r
1364 seh_clause : K_CATCH class_ref handler_block
\r
1365 | K_FINALLY handler_block
\r
1366 | K_FAULT handler_block
\r
1367 | filter_clause handler_block
\r
1370 filter_clause : K_FILTER scope_block
\r
1375 handler_block : scope_block
\r
1376 | K_HANDLER id K_TO id
\r
1377 | K_HANDLER int32 K_TO int32
\r
1380 instr : INSTR_NONE
\r
1383 | INSTR_I id /* Allow variable names :p */
\r
1387 | INSTR_R OPEN_PARENS bytes CLOSE_PARENS
\r
1388 | INSTR_BRTARGET int32
\r
1389 | INSTR_BRTARGET id
\r
1390 | INSTR_METHOD method_ref
\r
1391 | INSTR_FIELD type type_spec DOUBLE_COLON id
\r
1392 | INSTR_FIELD type id
\r
1393 | INSTR_TYPE K_FIELD type type_spec DOUBLE_COLON id // ****** ADDED
\r
1394 | INSTR_TYPE K_FIELD type id // ****** ADDED
\r
1395 | INSTR_TYPE type_spec
\r
1396 | INSTR_STRING comp_qstring
\r
1397 | INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1398 | INSTR_STRING K_BYTEARRAY OPEN_PARENS bytes CLOSE_PARENS // ****** ADDED
\r
1399 | INSTR_SIG call_conv type OPEN_PARENS sig_args CLOSE_PARENS
\r
1400 | INSTR_TOK owner_type
\r
1401 | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS
\r
1404 method_ref : call_conv type type_spec DOUBLE_COLON method_name
\r
1405 OPEN_PARENS sig_args CLOSE_PARENS
\r
1406 | call_conv type method_name
\r
1407 OPEN_PARENS sig_args CLOSE_PARENS
\r
1410 labels : /* EMPTY */
\r
1414 | labels COMMA int32
\r
1417 owner_type : type_spec
\r
1421 member_ref : K_METHOD member_ref
\r
1422 | K_FIELD type type_spec DOUBLE_COLON id
\r
1426 event_all : event_head OPEN_BRACE event_decls CLOSE_BRACE
\r
1429 event_head : D_EVENT event_attr type_spec id
\r
1430 | D_EVENT event_attr id
\r
1433 event_attr : /* EMPTY */
\r
1434 | event_attr K_RTSPECIALNAME
\r
1435 | event_attr K_SPECIALNAME
\r
1438 event_decls : /* EMPTY */
\r
1439 | event_decls event_decl
\r
1442 event_decl : D_ADDON method_ref
\r
1443 | D_REMOVEON method_ref
\r
1444 | D_FIRE method_ref
\r
1445 | D_OTHER method_ref
\r
1451 prop_all : prop_head OPEN_BRACE prop_decls CLOSE_BRACE
\r
1454 prop_head : D_PROPERTY prop_attr type id OPEN_PARENS sig_args CLOSE_PARENS init_opt
\r
1457 prop_attr : /* EMPTY */
\r
1458 | prop_attr K_RTSPECIALNAME
\r
1459 | prop_attr K_SPECIALNAME
\r
1462 prop_decls : /* EMPTY */
\r
1463 | prop_decls prop_decl
\r
1466 prop_decl : D_SET method_ref
\r
1467 | D_GET method_ref
\r
1468 | D_OTHER method_ref
\r
1474 customattr_decl : D_CUSTOM custom_type
\r
1475 | D_CUSTOM custom_type ASSIGN comp_qstring
\r
1476 | D_CUSTOM custom_type ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1477 | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type
\r
1478 | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN comp_qstring
\r
1479 | D_CUSTOM OPEN_PARENS owner_type CLOSE_PARENS custom_type ASSIGN
\r
1480 OPEN_PARENS bytes CLOSE_PARENS
\r
1483 custom_type : call_conv type type_spec DOUBLE_COLON D_CTOR OPEN_PARENS sig_args CLOSE_PARENS
\r
1484 | call_conv type D_CTOR OPEN_PARENS sig_args CLOSE_PARENS
\r
1487 sec_decl : D_PERMISSION sec_action type_spec OPEN_PARENS nameval_pairs CLOSE_PARENS
\r
1488 | D_PERMISSION sec_action type_spec
\r
1489 | D_PERMISSIONSET sec_action ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1492 nameval_pairs : nameval_pair
\r
1493 | nameval_pairs COMMA nameval_pair
\r
1496 nameval_pair : comp_qstring ASSIGN cavalue
\r
1499 cavalue : truefalse
\r
1501 | int32 OPEN_PARENS int32 CLOSE_PARENS
\r
1503 | class_ref OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS
\r
1504 | class_ref OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS
\r
1505 | class_ref OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS
\r
1506 | class_ref OPEN_PARENS int32 CLOSE_PARENS
\r
1509 sec_action : K_REQUEST
\r
1522 | K_NONCASLINKDEMAND
\r
1523 | K_NONCASINHERITANCE
\r
1526 module_head : D_MODULE
\r
1527 | D_MODULE comp_name
\r
1528 | D_MODULE K_EXTERN comp_name
\r
1531 file_decl : D_FILE file_attr comp_name file_entry D_HASH ASSIGN
\r
1532 OPEN_PARENS bytes CLOSE_PARENS file_entry
\r
1533 | D_FILE file_attr comp_name file_entry
\r
1536 file_attr : /* EMPTY */
\r
1537 | file_attr K_NOMETADATA
\r
1540 file_entry : /* EMPTY */
\r
1544 assembly_all : assembly_head OPEN_BRACE assembly_decls CLOSE_BRACE
\r
1547 assembly_head : D_ASSEMBLY asm_attr comp_name
\r
1550 asm_attr : /* EMPTY */
\r
1551 | asm_attr K_NOAPPDOMAIN
\r
1552 | asm_attr K_NOPROCESS
\r
1553 | asm_attr K_NOMACHINE
\r
1556 assembly_decls : /* EMPTY */
\r
1557 | assembly_decls assembly_decl
\r
1560 assembly_decl : D_HASH K_ALGORITHM int32
\r
1565 asm_or_ref_decl : D_PUBLICKEY ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1566 | D_VER int32 COLON int32 COLON int32 COLON int32
\r
1567 | D_LOCALE comp_qstring
\r
1568 | D_LOCALE ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1572 assemblyref_all : assemblyref_head OPEN_BRACE assemblyref_decls CLOSE_BRACE
\r
1575 assemblyref_head : D_ASSEMBLY K_EXTERN comp_name
\r
1576 | D_ASSEMBLY K_EXTERN comp_name K_AS comp_name
\r
1579 assemblyref_decls : /* EMPTY */
\r
1580 | assemblyref_decls assemblyref_decl
\r
1583 assemblyref_decl : D_HASH ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1585 | D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS bytes CLOSE_PARENS
\r
1588 exptype_all : exptype_head OPEN_BRACE exptype_decls CLOSE_BRACE
\r
1591 exptype_head : D_CLASS K_EXTERN expt_attr comp_name
\r
1594 expt_attr : /* EMPTY */
\r
1595 | expt_attr K_PRIVATE
\r
1596 | expt_attr K_PUBLIC
\r
1597 | expt_attr K_NESTED K_PUBLIC
\r
1598 | expt_attr K_NESTED K_PRIVATE
\r
1599 | expt_attr K_NESTED K_FAMILY
\r
1600 | expt_attr K_NESTED K_ASSEMBLY
\r
1601 | expt_attr K_NESTED K_FAMANDASSEM
\r
1602 | expt_attr K_NESTED K_FAMORASSEM
\r
1605 exptype_decls : /* EMPTY */
\r
1606 | exptype_decls exptype_decl
\r
1609 exptype_decl : D_FILE comp_name
\r
1610 | D_CLASS K_EXTERN comp_name
\r
1615 manifestres_all : manifestres_head OPEN_BRACE manifestres_decls CLOSE_BRACE
\r
1618 manifestres_head : D_MRESOURCE manres_attr comp_name
\r
1621 manres_attr : /* EMPTY */
\r
1622 | manres_attr K_PUBLIC
\r
1623 | manres_attr K_PRIVATE
\r
1626 manifestres_decls : /* EMPTY */
\r
1627 | manifestres_decls manifestres_decl
\r
1630 manifestres_decl : D_FILE comp_name K_AT int32
\r
1631 | D_ASSEMBLY K_EXTERN comp_name
\r
1636 | dotted_name DOT id { $$ = String.Format ("{0}.{1}", $1, $3); }
\r
1639 comp_qstring : QSTRING
\r
1640 | comp_qstring PLUS QSTRING { $$ = String.Format ("{0}{1}", $1, $3); }
\r
1652 | K_FLOAT32 OPEN_PARENS int32 CLOSE_PARENS
\r
1653 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1657 | INT32 // ******** ADDED
\r
1658 | ID // ******** ADDED
\r
1661 bytes : /* EMPTY */
\r
1665 hexbytes : hexbyte
\r
1666 | hexbytes hexbyte
\r
1669 truefalse : K_TRUE
\r
1682 | dotted_name DOT id
\r