示例#1
0
	void MemberModifier(ModifierList m) {
		switch (la.kind) {
		case 156: {
			Get();
			m.Add(Modifiers.Abstract, t.Location);
			break;
		}
		case 102: {
			Get();
			m.Add(Modifiers.Default, t.Location);
			break;
		}
		case 125: {
			Get();
			m.Add(Modifiers.Internal, t.Location);
			break;
		}
		case 199: {
			Get();
			m.Add(Modifiers.New, t.Location);
			break;
		}
		case 181: {
			Get();
			m.Add(Modifiers.Override, t.Location);
			break;
		}
		case 157: {
			Get();
			m.Add(Modifiers.Abstract, t.Location);
			break;
		}
		case 185: {
			Get();
			m.Add(Modifiers.Private, t.Location);
			break;
		}
		case 187: {
			Get();
			m.Add(Modifiers.Protected, t.Location);
			break;
		}
		case 188: {
			Get();
			m.Add(Modifiers.Public, t.Location);
			break;
		}
		case 166: {
			Get();
			m.Add(Modifiers.Sealed, t.Location);
			break;
		}
		case 167: {
			Get();
			m.Add(Modifiers.Sealed, t.Location);
			break;
		}
		case 200: {
			Get();
			m.Add(Modifiers.Static, t.Location);
			break;
		}
		case 180: {
			Get();
			m.Add(Modifiers.Virtual, t.Location);
			break;
		}
		case 179: {
			Get();
			m.Add(Modifiers.Overloads, t.Location);
			break;
		}
		case 190: {
			Get();
			m.Add(Modifiers.ReadOnly, t.Location);
			break;
		}
		case 235: {
			Get();
			m.Add(Modifiers.WriteOnly, t.Location);
			break;
		}
		case 234: {
			Get();
			m.Add(Modifiers.WithEvents, t.Location);
			break;
		}
		case 105: {
			Get();
			m.Add(Modifiers.Dim, t.Location);
			break;
		}
		case 183: {
			Get();
			m.Add(Modifiers.Partial, t.Location);
			break;
		}
		default: SynErr(256); break;
		}
	}
示例#2
0
 static bool IsMustOverride(ModifierList m)
 {
     return(m.Contains(Modifiers.Abstract));
 }
示例#3
0
	void ClassBody(TypeDeclaration newType) {
		AttributeSection section;
		while (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
		}
		while (StartOf(10)) {
			List<AttributeSection> attributes = new List<AttributeSection>();
				ModifierList m = new ModifierList();

			while (la.kind == 40) {
				AttributeSection(out section);
				attributes.Add(section);
			}
			while (StartOf(11)) {
				MemberModifier(m);
			}
			ClassMemberDecl(m, attributes);
			while (la.kind == 1 || la.kind == 21) {
				EndOfStmt();
			}
		}
	}
示例#4
0
	void StructureBody(TypeDeclaration newType) {
		AttributeSection section;
		while (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
		}
		while (StartOf(10)) {
			List<AttributeSection> attributes = new List<AttributeSection>();
				ModifierList m = new ModifierList();

			while (la.kind == 40) {
				AttributeSection(out section);
				attributes.Add(section);
			}
			while (StartOf(11)) {
				MemberModifier(m);
			}
			StructureMemberDecl(m, attributes);
			while (la.kind == 1 || la.kind == 21) {
				EndOfStmt();
			}
		}
		Expect(113);
		Expect(209);
		newType.EndLocation = t.EndLocation;
		EndOfStmt();
	}
示例#5
0
	void LocalDeclarationStatement(out Statement statement) {
		ModifierList m = new ModifierList();
		LocalVariableDeclaration localVariableDeclaration;
		bool dimfound = false;

		while (la.kind == 88 || la.kind == 105 || la.kind == 204) {
			if (la.kind == 88) {
				Get();
				m.Add(Modifiers.Const, t.Location);
			} else if (la.kind == 204) {
				Get();
				m.Add(Modifiers.Static, t.Location);
			} else {
				Get();
				dimfound = true;
			}
		}
		if(dimfound && (m.Modifier & Modifiers.Const) != 0) {
				Error("Dim is not allowed on constants.");
			}
			
			if(m.isNone && dimfound == false) {
				Error("Const, Dim or Static expected");
			}
			
			localVariableDeclaration = new LocalVariableDeclaration(m.Modifier);
			localVariableDeclaration.StartLocation = t.Location;

		VariableDeclarator(localVariableDeclaration.Variables);
		while (la.kind == 22) {
			Get();
			VariableDeclarator(localVariableDeclaration.Variables);
		}
		statement = localVariableDeclaration;

	}
示例#6
0
	void NonModuleDeclaration(ModifierList m, List<AttributeSection> attributes) {
		TypeReference typeRef = null;
		List<TypeReference> baseInterfaces = null;

		switch (la.kind) {
		case 84: {
			m.Check(Modifiers.Classes);
			Get();
			TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				newType.StartLocation = t.Location;
				AddChild(newType);
				BlockStart(newType);
				
				newType.Type       = ClassType.Class;

			Identifier();
			newType.Name = t.val;
			TypeParameterList(newType.Templates);
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			if (la.kind == 140) {
				ClassBaseType(out typeRef);
				SafeAdd(newType, newType.BaseTypes, typeRef);
			}
			while (la.kind == 136) {
				TypeImplementsClause(out baseInterfaces);
				newType.BaseTypes.AddRange(baseInterfaces);
			}
			ClassBody(newType);
			Expect(113);
			Expect(84);
			newType.EndLocation = t.EndLocation;
			EndOfStmt();
			BlockEnd();

			break;
		}
		case 155: {
			Get();
			m.Check(Modifiers.VBModules);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				AddChild(newType);
				BlockStart(newType);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				newType.Type = ClassType.Module;

			Identifier();
			newType.Name = t.val;
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			ModuleBody(newType);
			BlockEnd();

			break;
		}
		case 209: {
			Get();
			m.Check(Modifiers.VBStructures);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				AddChild(newType);
				BlockStart(newType);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				newType.Type = ClassType.Struct;

			Identifier();
			newType.Name = t.val;
			TypeParameterList(newType.Templates);
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			while (la.kind == 136) {
				TypeImplementsClause(out baseInterfaces);
				newType.BaseTypes.AddRange(baseInterfaces);
			}
			StructureBody(newType);
			BlockEnd();

			break;
		}
		case 115: {
			Get();
			m.Check(Modifiers.VBEnums);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				AddChild(newType);
				BlockStart(newType);
				
				newType.Type = ClassType.Enum;

			Identifier();
			newType.Name = t.val;
			if (la.kind == 63) {
				Get();
				NonArrayTypeName(out typeRef, false);
				SafeAdd(newType, newType.BaseTypes, typeRef);
			}
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			EnumBody(newType);
			BlockEnd();

			break;
		}
		case 142: {
			Get();
			m.Check(Modifiers.VBInterfacs);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				AddChild(newType);
				BlockStart(newType);
				newType.Type = ClassType.Interface;

			Identifier();
			newType.Name = t.val;
			TypeParameterList(newType.Templates);
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			while (la.kind == 140) {
				InterfaceBase(out baseInterfaces);
				newType.BaseTypes.AddRange(baseInterfaces);
			}
			InterfaceBody(newType);
			BlockEnd();

			break;
		}
		case 103: {
			Get();
			m.Check(Modifiers.VBDelegates);
				DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
				delegateDeclr.ReturnType = new TypeReference("System.Void", true);
				delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
				List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();

			if (la.kind == 210) {
				Get();
				Identifier();
				delegateDeclr.Name = t.val;
				TypeParameterList(delegateDeclr.Templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
					delegateDeclr.Parameters = p;
				}
			} else if (la.kind == 127) {
				Get();
				Identifier();
				delegateDeclr.Name = t.val;
				TypeParameterList(delegateDeclr.Templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
					delegateDeclr.Parameters = p;
				}
				if (la.kind == 63) {
					Get();
					TypeReference type;
					TypeName(out type);
					delegateDeclr.ReturnType = type;
				}
			} else SynErr(251);
			delegateDeclr.EndLocation = t.EndLocation;
			EndOfStmt();
			AddChild(delegateDeclr);

			break;
		}
		default: SynErr(252); break;
		}
	}
示例#7
0
	void TypeModifier(ModifierList m) {
		switch (la.kind) {
		case 188: {
			Get();
			m.Add(Modifiers.Public, t.Location);
			break;
		}
		case 187: {
			Get();
			m.Add(Modifiers.Protected, t.Location);
			break;
		}
		case 125: {
			Get();
			m.Add(Modifiers.Internal, t.Location);
			break;
		}
		case 185: {
			Get();
			m.Add(Modifiers.Private, t.Location);
			break;
		}
		case 200: {
			Get();
			m.Add(Modifiers.Static, t.Location);
			break;
		}
		case 199: {
			Get();
			m.Add(Modifiers.New, t.Location);
			break;
		}
		case 156: {
			Get();
			m.Add(Modifiers.Abstract, t.Location);
			break;
		}
		case 166: {
			Get();
			m.Add(Modifiers.Sealed, t.Location);
			break;
		}
		case 183: {
			Get();
			m.Add(Modifiers.Partial, t.Location);
			break;
		}
		default: SynErr(250); break;
		}
	}
示例#8
0
	void NamespaceMemberDecl() {
		ModifierList m = new ModifierList();
		AttributeSection section;
		List<AttributeSection> attributes = new List<AttributeSection>();
		string qualident;

		if (la.kind == 160) {
			Get();
			Location startPos = t.Location;

			Qualident(out qualident);
			INode node =  new NamespaceDeclaration(qualident);
				node.StartLocation = startPos;
				AddChild(node);
				BlockStart(node);

			EndOfStmt();
			NamespaceBody();
			node.EndLocation = t.Location;
				BlockEnd();

		} else if (StartOf(3)) {
			while (la.kind == 40) {
				AttributeSection(out section);
				attributes.Add(section);
			}
			while (StartOf(4)) {
				TypeModifier(m);
			}
			NonModuleDeclaration(m, attributes);
		} else SynErr(245);
	}
示例#9
0
	void InterfaceMemberDecl() {
		TypeReference type =null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		AttributeSection section, returnTypeAttributeSection = null;
		ModifierList mod = new ModifierList();
		List<AttributeSection> attributes = new List<AttributeSection>();
		string name;

		if (StartOf(20)) {
			while (la.kind == 40) {
				AttributeSection(out section);
				attributes.Add(section);
			}
			while (StartOf(11)) {
				MemberModifier(mod);
			}
			if (la.kind == 119) {
				Get();
				mod.Check(Modifiers.VBInterfaceEvents);
					Location startLocation = t.Location;

				Identifier();
				name = t.val;
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					Get();
					TypeName(out type);
				}
				EndOfStmt();
				EventDeclaration ed = new EventDeclaration {
						Name = name, TypeReference = type, Modifier = mod.Modifier,
						Parameters = p, Attributes = attributes,
						StartLocation = startLocation, EndLocation = t.EndLocation
					};
					AddChild(ed);

			} else if (la.kind == 210) {
				Get();
				Location startLocation =  t.Location;
					mod.Check(Modifiers.VBInterfaceMethods);

				Identifier();
				name = t.val;
				TypeParameterList(templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				EndOfStmt();
				MethodDeclaration md = new MethodDeclaration {
						Name = name, 
						Modifier = mod.Modifier, 
						Parameters = p,
						Attributes = attributes,
						TypeReference = new TypeReference("System.Void", true),
						StartLocation = startLocation,
						EndLocation = t.EndLocation,
						Templates = templates
					};
					AddChild(md);

			} else if (la.kind == 127) {
				Get();
				mod.Check(Modifiers.VBInterfaceMethods);
					Location startLocation = t.Location;

				Identifier();
				name = t.val;
				TypeParameterList(templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					Get();
					while (la.kind == 40) {
						AttributeSection(out returnTypeAttributeSection);
					}
					TypeName(out type);
				}
				if(type == null) {
						type = new TypeReference("System.Object", true);
					}
					MethodDeclaration md = new MethodDeclaration {
						Name = name, Modifier = mod.Modifier, 
						TypeReference = type, Parameters = p, Attributes = attributes
					};
					if (returnTypeAttributeSection != null) {
						returnTypeAttributeSection.AttributeTarget = "return";
						md.Attributes.Add(returnTypeAttributeSection);
					}
					md.StartLocation = startLocation;
					md.EndLocation = t.EndLocation;
					md.Templates = templates;
					AddChild(md);

				EndOfStmt();
			} else if (la.kind == 186) {
				Get();
				Location startLocation = t.Location;
					mod.Check(Modifiers.VBInterfaceProperties);

				Identifier();
				name = t.val; 
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					Get();
					TypeName(out type);
				}
				if(type == null) {
						type = new TypeReference("System.Object", true);
					}

				EndOfStmt();
				PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
					pd.Parameters = p;
					pd.EndLocation = t.EndLocation;
					pd.StartLocation = startLocation;
					AddChild(pd);

			} else SynErr(265);
		} else if (StartOf(21)) {
			NonModuleDeclaration(mod, attributes);
		} else SynErr(266);
	}
示例#10
0
	void StructureMemberDecl(ModifierList m, List<AttributeSection> attributes) {
		TypeReference type = null;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		Statement stmt = null;
		List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();

		switch (la.kind) {
		case 84: case 103: case 115: case 142: case 155: case 209: {
			NonModuleDeclaration(m, attributes);
			break;
		}
		case 210: {
			Get();
			Location startPos = t.Location;

			if (StartOf(5)) {
				string name = String.Empty;
					MethodDeclaration methodDeclaration; List<string> handlesClause = null;
					List<InterfaceImplementation> implementsClause = null;

				Identifier();
				name = t.val;
					m.Check(Modifiers.VBMethods);

				TypeParameterList(templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				if (la.kind == 134 || la.kind == 136) {
					if (la.kind == 136) {
						ImplementsClause(out implementsClause);
					} else {
						HandlesClause(out handlesClause);
					}
				}
				Location endLocation = t.EndLocation;
				if (IsMustOverride(m)) {
					EndOfStmt();
					methodDeclaration = new MethodDeclaration {
							Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
							StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
							TypeReference = new TypeReference("System.Void", true),
							Templates = templates,
							HandlesClause = handlesClause,
							InterfaceImplementations = implementsClause
						};
						AddChild(methodDeclaration);

				} else if (la.kind == 1) {
					Get();
					methodDeclaration = new MethodDeclaration {
							Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
							StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
							TypeReference = new TypeReference("System.Void", true),
							Templates = templates,
							HandlesClause = handlesClause,
							InterfaceImplementations = implementsClause
						};
						AddChild(methodDeclaration);

					if (ParseMethodBodies) {
					Block(out stmt);
					Expect(113);
					Expect(210);
					} else {
						// don't parse method body
						lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
					   }

					methodDeclaration.Body  = (BlockStatement)stmt;
					methodDeclaration.Body.EndLocation = t.EndLocation;
					EndOfStmt();
				} else SynErr(257);
			} else if (la.kind == 162) {
				Get();
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				m.Check(Modifiers.Constructors);
				Location constructorEndLocation = t.EndLocation;
				Expect(1);
				if (ParseMethodBodies) {
				Block(out stmt);
				Expect(113);
				Expect(210);
				} else {
					// don't parse method body
					lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
				   }

				Location endLocation = t.EndLocation;
				EndOfStmt();
				ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
					cd.StartLocation = m.GetDeclarationLocation(startPos);
					cd.EndLocation   = constructorEndLocation;
					cd.Body = (BlockStatement)stmt;
					cd.Body.EndLocation   = endLocation;
					AddChild(cd);

			} else SynErr(258);
			break;
		}
		case 127: {
			Get();
			m.Check(Modifiers.VBMethods);
				string name = String.Empty;
				Location startPos = t.Location;
				MethodDeclaration methodDeclaration;List<string> handlesClause = null;
				List<InterfaceImplementation> implementsClause = null;
				AttributeSection returnTypeAttributeSection = null;

			Identifier();
			name = t.val;
			TypeParameterList(templates);
			if (la.kind == 37) {
				Get();
				if (StartOf(7)) {
					FormalParameterList(p);
				}
				Expect(38);
			}
			if (la.kind == 63) {
				Get();
				while (la.kind == 40) {
					AttributeSection(out returnTypeAttributeSection);
					if (returnTypeAttributeSection != null) {
							returnTypeAttributeSection.AttributeTarget = "return";
							attributes.Add(returnTypeAttributeSection);
						}

				}
				TypeName(out type);
			}
			if(type == null) {
					type = new TypeReference("System.Object", true);
				}

			if (la.kind == 134 || la.kind == 136) {
				if (la.kind == 136) {
					ImplementsClause(out implementsClause);
				} else {
					HandlesClause(out handlesClause);
				}
			}
			Location endLocation = t.EndLocation;
			if (IsMustOverride(m)) {
				EndOfStmt();
				methodDeclaration = new MethodDeclaration {
						Name = name, Modifier = m.Modifier, TypeReference = type,
						Parameters = p, Attributes = attributes,
						StartLocation = m.GetDeclarationLocation(startPos),
						EndLocation   = endLocation,
						HandlesClause = handlesClause,
						Templates     = templates,
						InterfaceImplementations = implementsClause
					};
					
					AddChild(methodDeclaration);

			} else if (la.kind == 1) {
				Get();
				methodDeclaration = new MethodDeclaration {
						Name = name, Modifier = m.Modifier, TypeReference = type,
						Parameters = p, Attributes = attributes,
						StartLocation = m.GetDeclarationLocation(startPos),
						EndLocation   = endLocation,
						Templates     = templates,
						HandlesClause = handlesClause,
						InterfaceImplementations = implementsClause
					};
					
					AddChild(methodDeclaration);

					if (ParseMethodBodies) {
				Block(out stmt);
				Expect(113);
				Expect(127);
				} else {
						// don't parse method body
						lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
					}
					methodDeclaration.Body = (BlockStatement)stmt;
					methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
					methodDeclaration.Body.EndLocation   = t.EndLocation;

				EndOfStmt();
			} else SynErr(259);
			break;
		}
		case 101: {
			Get();
			m.Check(Modifiers.VBExternalMethods);
				Location startPos = t.Location;
				CharsetModifier charsetModifer = CharsetModifier.None;
				string library = String.Empty;
				string alias = null;
				string name = String.Empty;

			if (StartOf(16)) {
				Charset(out charsetModifer);
			}
			if (la.kind == 210) {
				Get();
				Identifier();
				name = t.val;
				Expect(149);
				Expect(3);
				library = t.literalValue as string;
				if (la.kind == 59) {
					Get();
					Expect(3);
					alias = t.literalValue as string;
				}
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				EndOfStmt();
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
					declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
					declareDeclaration.EndLocation   = t.EndLocation;
					AddChild(declareDeclaration);

			} else if (la.kind == 127) {
				Get();
				Identifier();
				name = t.val;
				Expect(149);
				Expect(3);
				library = t.literalValue as string;
				if (la.kind == 59) {
					Get();
					Expect(3);
					alias = t.literalValue as string;
				}
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
				if (la.kind == 63) {
					Get();
					TypeName(out type);
				}
				EndOfStmt();
				DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
					declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
					declareDeclaration.EndLocation   = t.EndLocation;
					AddChild(declareDeclaration);

			} else SynErr(260);
			break;
		}
		case 119: {
			Get();
			m.Check(Modifiers.VBEvents);
				Location startPos = t.Location;
				EventDeclaration eventDeclaration;
				string name = String.Empty;
				List<InterfaceImplementation> implementsClause = null;

			Identifier();
			name= t.val;
			if (la.kind == 63) {
				Get();
				TypeName(out type);
			} else if (StartOf(17)) {
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
				}
			} else SynErr(261);
			if (la.kind == 136) {
				ImplementsClause(out implementsClause);
			}
			eventDeclaration = new EventDeclaration {
					Name = name, TypeReference = type, Modifier = m.Modifier, 
					Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
					StartLocation = m.GetDeclarationLocation(startPos),
					EndLocation = t.EndLocation
				};
				AddChild(eventDeclaration);

			EndOfStmt();
			break;
		}
		case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
			m.Check(Modifiers.Fields);
				FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);

			IdentifierForFieldDeclaration();
			string name = t.val;
			fd.StartLocation = m.GetDeclarationLocation(t.Location);
			VariableDeclaratorPartAfterIdentifier(variableDeclarators, name);
			while (la.kind == 22) {
				Get();
				VariableDeclarator(variableDeclarators);
			}
			EndOfStmt();
			fd.EndLocation = t.EndLocation;
				fd.Fields = variableDeclarators;
				AddChild(fd);

			break;
		}
		case 88: {
			m.Check(Modifiers.Fields);
			Get();
			m.Add(Modifiers.Const, t.Location); 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
				fd.StartLocation = m.GetDeclarationLocation(t.Location);
				List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();

			ConstantDeclarator(constantDeclarators);
			while (la.kind == 22) {
				Get();
				ConstantDeclarator(constantDeclarators);
			}
			fd.Fields = constantDeclarators;
				fd.EndLocation = t.Location;

			EndOfStmt();
			fd.EndLocation = t.EndLocation;
				AddChild(fd);

			break;
		}
		case 186: {
			Get();
			m.Check(Modifiers.VBProperties);
				Location startPos = t.Location;
				List<InterfaceImplementation> implementsClause = null;
				AttributeSection returnTypeAttributeSection = null;
				Expression initializer = null;

			Identifier();
			string propertyName = t.val;
			if (la.kind == 37) {
				Get();
				if (StartOf(7)) {
					FormalParameterList(p);
				}
				Expect(38);
			}
			if (la.kind == 63) {
				Get();
				while (la.kind == 40) {
					AttributeSection(out returnTypeAttributeSection);
					if (returnTypeAttributeSection != null) {
							returnTypeAttributeSection.AttributeTarget = "return";
							attributes.Add(returnTypeAttributeSection);
						}

				}
				if (IsNewExpression()) {
					ObjectCreateExpression(out initializer);
					if (initializer is ObjectCreateExpression) {
							type = ((ObjectCreateExpression)initializer).CreateType.Clone();
						} else {
							type = ((ArrayCreateExpression)initializer).CreateType.Clone();
						}

				} else if (StartOf(9)) {
					TypeName(out type);
				} else SynErr(262);
			}
			if (la.kind == 20) {
				Get();
				Expr(out initializer);
			}
			if (la.kind == 136) {
				ImplementsClause(out implementsClause);
			}
			EndOfStmt();
			if (IsMustOverride(m) || IsAutomaticProperty()) {
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
					pDecl.StartLocation = m.GetDeclarationLocation(startPos);
					pDecl.EndLocation   = t.Location;
					pDecl.TypeReference = type;
					pDecl.InterfaceImplementations = implementsClause;
					pDecl.Parameters = p;
					if (initializer != null)
						pDecl.Initializer = initializer;
					AddChild(pDecl);

			} else if (StartOf(18)) {
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
					pDecl.StartLocation = m.GetDeclarationLocation(startPos);
					pDecl.EndLocation   = t.Location;
					pDecl.BodyStart   = t.Location;
					pDecl.TypeReference = type;
					pDecl.InterfaceImplementations = implementsClause;
					pDecl.Parameters = p;
					PropertyGetRegion getRegion;
					PropertySetRegion setRegion;

				AccessorDecls(out getRegion, out setRegion);
				Expect(113);
				Expect(186);
				EndOfStmt();
				pDecl.GetRegion = getRegion;
					pDecl.SetRegion = setRegion;
					pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property"
					AddChild(pDecl);

			} else SynErr(263);
			break;
		}
		case 98: {
			Get();
			Location startPos = t.Location;
			Expect(119);
			m.Check(Modifiers.VBCustomEvents);
				EventAddRemoveRegion eventAccessorDeclaration;
				EventAddRegion addHandlerAccessorDeclaration = null;
				EventRemoveRegion removeHandlerAccessorDeclaration = null;
				EventRaiseRegion raiseEventAccessorDeclaration = null;
				List<InterfaceImplementation> implementsClause = null;

			Identifier();
			string customEventName = t.val;
			Expect(63);
			TypeName(out type);
			if (la.kind == 136) {
				ImplementsClause(out implementsClause);
			}
			EndOfStmt();
			while (StartOf(19)) {
				EventAccessorDeclaration(out eventAccessorDeclaration);
				if(eventAccessorDeclaration is EventAddRegion)
					{
						addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
					}
					else if(eventAccessorDeclaration is EventRemoveRegion)
					{
						removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
					}
					else if(eventAccessorDeclaration is EventRaiseRegion)
					{
						raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
					}

			}
			Expect(113);
			Expect(119);
			EndOfStmt();
			if(addHandlerAccessorDeclaration == null)
				{
					Error("Need to provide AddHandler accessor.");
				}
				
				if(removeHandlerAccessorDeclaration == null)
				{
					Error("Need to provide RemoveHandler accessor.");
				}
				
				if(raiseEventAccessorDeclaration == null)
				{
					Error("Need to provide RaiseEvent accessor.");
				}

				EventDeclaration decl = new EventDeclaration {
					TypeReference = type, Name = customEventName, Modifier = m.Modifier,
					Attributes = attributes,
					StartLocation = m.GetDeclarationLocation(startPos),
					EndLocation = t.EndLocation,
					AddRegion = addHandlerAccessorDeclaration,
					RemoveRegion = removeHandlerAccessorDeclaration,
					RaiseRegion = raiseEventAccessorDeclaration
				};
				AddChild(decl);

			break;
		}
		case 161: case 172: case 232: {
			ConversionType opConversionType = ConversionType.None;
			if (la.kind == 161 || la.kind == 232) {
				if (la.kind == 232) {
					Get();
					opConversionType = ConversionType.Implicit;
				} else {
					Get();
					opConversionType = ConversionType.Explicit;
				}
			}
			Expect(172);
			m.Check(Modifiers.VBOperators);
				Location startPos = t.Location;
				TypeReference returnType = NullTypeReference.Instance;
				TypeReference operandType = NullTypeReference.Instance;
				OverloadableOperatorType operatorType;
				AttributeSection section;
				ParameterDeclarationExpression param;
				List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();

			OverloadableOperator(out operatorType);
			Expect(37);
			FormalParameter(out param);
			if (param != null) parameters.Add(param);
			if (la.kind == 22) {
				Get();
				FormalParameter(out param);
				if (param != null) parameters.Add(param);
			}
			Expect(38);
			Location endPos = t.EndLocation;
			if (la.kind == 63) {
				Get();
				while (la.kind == 40) {
					AttributeSection(out section);
					if (section != null) {
						section.AttributeTarget = "return";
						attributes.Add(section);
					}
				}
				TypeName(out returnType);
				endPos = t.EndLocation;
			}
			Expect(1);
			Block(out stmt);
			Expect(113);
			Expect(172);
			EndOfStmt();
			OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
					Modifier = m.Modifier,
					Attributes = attributes,
					Parameters = parameters,
					TypeReference = returnType,
					OverloadableOperator = operatorType,
					ConversionType = opConversionType,
					Body = (BlockStatement)stmt,
					StartLocation = m.GetDeclarationLocation(startPos),
					EndLocation = endPos
				};
				operatorDeclaration.Body.StartLocation = startPos;
				operatorDeclaration.Body.EndLocation = t.Location;
				AddChild(operatorDeclaration);

			break;
		}
		default: SynErr(264); break;
		}
	}
示例#11
0
	void ClassMemberDecl(ModifierList m, List<AttributeSection> attributes) {
		StructureMemberDecl(m, attributes);
	}