⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.cs

📁 SharpDevelop2.0.0 c#开发免费工具
💻 CS
📖 第 1 页 / 共 5 页
字号:

	void Type(
#line  1003 "cs.ATG" 
out TypeReference type) {
		TypeWithRestriction(
#line  1005 "cs.ATG" 
out type, true, false);
	}

	void FormalParameterList(
#line  1066 "cs.ATG" 
List<ParameterDeclarationExpression> parameter) {

#line  1069 "cs.ATG" 
		ParameterDeclarationExpression p;
		AttributeSection section;
		List<AttributeSection> attributes = new List<AttributeSection>();
		
		while (la.kind == 18) {
			AttributeSection(
#line  1074 "cs.ATG" 
out section);

#line  1074 "cs.ATG" 
			attributes.Add(section); 
		}
		if (StartOf(14)) {
			FixedParameter(
#line  1076 "cs.ATG" 
out p);

#line  1076 "cs.ATG" 
			bool paramsFound = false;
			p.Attributes = attributes;
			parameter.Add(p);
			
			while (la.kind == 14) {
				lexer.NextToken();

#line  1081 "cs.ATG" 
				attributes = new List<AttributeSection>(); if (paramsFound) Error("params array must be at end of parameter list"); 
				while (la.kind == 18) {
					AttributeSection(
#line  1082 "cs.ATG" 
out section);

#line  1082 "cs.ATG" 
					attributes.Add(section); 
				}
				if (StartOf(14)) {
					FixedParameter(
#line  1084 "cs.ATG" 
out p);

#line  1084 "cs.ATG" 
					p.Attributes = attributes; parameter.Add(p); 
				} else if (la.kind == 94) {
					ParameterArray(
#line  1085 "cs.ATG" 
out p);

#line  1085 "cs.ATG" 
					paramsFound = true; p.Attributes = attributes; parameter.Add(p); 
				} else SynErr(134);
			}
		} else if (la.kind == 94) {
			ParameterArray(
#line  1088 "cs.ATG" 
out p);

#line  1088 "cs.ATG" 
			p.Attributes = attributes; parameter.Add(p); 
		} else SynErr(135);
	}

	void ClassType(
#line  1136 "cs.ATG" 
out TypeReference typeRef, bool canBeUnbound) {

#line  1137 "cs.ATG" 
		TypeReference r; typeRef = null; 
		if (la.kind == 1) {
			TypeName(
#line  1139 "cs.ATG" 
out r, canBeUnbound);

#line  1139 "cs.ATG" 
			typeRef = r; 
		} else if (la.kind == 90) {
			lexer.NextToken();

#line  1140 "cs.ATG" 
			typeRef = new TypeReference("object"); 
		} else if (la.kind == 107) {
			lexer.NextToken();

#line  1141 "cs.ATG" 
			typeRef = new TypeReference("string"); 
		} else SynErr(136);
	}

	void TypeName(
#line  2417 "cs.ATG" 
out TypeReference typeRef, bool canBeUnbound) {

#line  2418 "cs.ATG" 
		List<TypeReference> typeArguments = null;
		string alias = null;
		string qualident;
		
		if (
#line  2423 "cs.ATG" 
la.kind == Tokens.Identifier && Peek(1).kind == Tokens.DoubleColon) {
			lexer.NextToken();

#line  2424 "cs.ATG" 
			alias = t.val; 
			Expect(10);
		}
		Qualident(
#line  2427 "cs.ATG" 
out qualident);
		if (la.kind == 23) {
			TypeArgumentList(
#line  2428 "cs.ATG" 
out typeArguments, canBeUnbound);
		}

#line  2430 "cs.ATG" 
		if (alias == null) {
		typeRef = new TypeReference(qualident, typeArguments);
		} else if (alias == "global") {
			typeRef = new TypeReference(qualident, typeArguments);
			typeRef.IsGlobal = true;
		} else {
			typeRef = new TypeReference(alias + "." + qualident, typeArguments);
		}
		
		while (
#line  2439 "cs.ATG" 
DotAndIdent()) {
			Expect(15);

#line  2440 "cs.ATG" 
			typeArguments = null; 
			Qualident(
#line  2441 "cs.ATG" 
out qualident);
			if (la.kind == 23) {
				TypeArgumentList(
#line  2442 "cs.ATG" 
out typeArguments, canBeUnbound);
			}

#line  2443 "cs.ATG" 
			typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); 
		}
	}

	void MemberModifiers(
#line  1157 "cs.ATG" 
Modifiers m) {
		while (StartOf(15) || 
#line  1174 "cs.ATG" 
la.kind == Tokens.Identifier && la.val == "partial") {
			if (la.kind == 48) {
				lexer.NextToken();

#line  1160 "cs.ATG" 
				m.Add(Modifier.Abstract, t.Location); 
			} else if (la.kind == 70) {
				lexer.NextToken();

#line  1161 "cs.ATG" 
				m.Add(Modifier.Extern, t.Location); 
			} else if (la.kind == 83) {
				lexer.NextToken();

#line  1162 "cs.ATG" 
				m.Add(Modifier.Internal, t.Location); 
			} else if (la.kind == 88) {
				lexer.NextToken();

#line  1163 "cs.ATG" 
				m.Add(Modifier.New, t.Location); 
			} else if (la.kind == 93) {
				lexer.NextToken();

#line  1164 "cs.ATG" 
				m.Add(Modifier.Override, t.Location); 
			} else if (la.kind == 95) {
				lexer.NextToken();

#line  1165 "cs.ATG" 
				m.Add(Modifier.Private, t.Location); 
			} else if (la.kind == 96) {
				lexer.NextToken();

#line  1166 "cs.ATG" 
				m.Add(Modifier.Protected, t.Location); 
			} else if (la.kind == 97) {
				lexer.NextToken();

#line  1167 "cs.ATG" 
				m.Add(Modifier.Public, t.Location); 
			} else if (la.kind == 98) {
				lexer.NextToken();

#line  1168 "cs.ATG" 
				m.Add(Modifier.ReadOnly, t.Location); 
			} else if (la.kind == 102) {
				lexer.NextToken();

#line  1169 "cs.ATG" 
				m.Add(Modifier.Sealed, t.Location); 
			} else if (la.kind == 106) {
				lexer.NextToken();

#line  1170 "cs.ATG" 
				m.Add(Modifier.Static, t.Location); 
			} else if (la.kind == 118) {
				lexer.NextToken();

#line  1171 "cs.ATG" 
				m.Add(Modifier.Unsafe, t.Location); 
			} else if (la.kind == 121) {
				lexer.NextToken();

#line  1172 "cs.ATG" 
				m.Add(Modifier.Virtual, t.Location); 
			} else if (la.kind == 123) {
				lexer.NextToken();

#line  1173 "cs.ATG" 
				m.Add(Modifier.Volatile, t.Location); 
			} else {
				Expect(1);

#line  1175 "cs.ATG" 
				m.Add(Modifier.Partial, t.Location); 
			}
		}
	}

	void ClassMemberDecl(
#line  1450 "cs.ATG" 
Modifiers m, List<AttributeSection> attributes) {

#line  1451 "cs.ATG" 
		Statement stmt = null; 
		if (StartOf(16)) {
			StructMemberDecl(
#line  1453 "cs.ATG" 
m, attributes);
		} else if (la.kind == 27) {

#line  1454 "cs.ATG" 
			m.Check(Modifier.Destructors); Point startPos = t.Location; 
			lexer.NextToken();
			Expect(1);

#line  1455 "cs.ATG" 
			DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); 
			d.Modifier = m.Modifier;
			d.StartLocation = m.GetDeclarationLocation(startPos);
			
			Expect(20);
			Expect(21);

#line  1459 "cs.ATG" 
			d.EndLocation = t.EndLocation; 
			if (la.kind == 16) {
				Block(
#line  1459 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(137);

#line  1460 "cs.ATG" 
			d.Body = (BlockStatement)stmt;
			compilationUnit.AddChild(d);
			
		} else SynErr(138);
	}

	void StructMemberDecl(
#line  1180 "cs.ATG" 
Modifiers m, List<AttributeSection> attributes) {

#line  1182 "cs.ATG" 
		string qualident = null;
		TypeReference type;
		Expression expr;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		Statement stmt = null;
		List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
		List<TemplateDefinition> templates = new List<TemplateDefinition>();
		TypeReference explicitInterface = null;
		
		if (la.kind == 59) {

#line  1192 "cs.ATG" 
			m.Check(Modifier.Constants); 
			lexer.NextToken();

#line  1193 "cs.ATG" 
			Point startPos = t.Location; 
			Type(
#line  1194 "cs.ATG" 
out type);
			Expect(1);

#line  1194 "cs.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const);
			fd.StartLocation = m.GetDeclarationLocation(startPos);
			VariableDeclaration f = new VariableDeclaration(t.val);
			fd.Fields.Add(f);
			
			Expect(3);
			Expr(
#line  1199 "cs.ATG" 
out expr);

#line  1199 "cs.ATG" 
			f.Initializer = expr; 
			while (la.kind == 14) {
				lexer.NextToken();
				Expect(1);

#line  1200 "cs.ATG" 
				f = new VariableDeclaration(t.val);
				fd.Fields.Add(f);
				
				Expect(3);
				Expr(
#line  1203 "cs.ATG" 
out expr);

#line  1203 "cs.ATG" 
				f.Initializer = expr; 
			}
			Expect(11);

#line  1204 "cs.ATG" 
			fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); 
		} else if (
#line  1208 "cs.ATG" 
NotVoidPointer()) {

#line  1208 "cs.ATG" 
			m.Check(Modifier.PropertysEventsMethods); 
			Expect(122);

#line  1209 "cs.ATG" 
			Point startPos = t.Location; 
			if (
#line  1210 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
				TypeName(
#line  1211 "cs.ATG" 
out explicitInterface, false);

#line  1212 "cs.ATG" 
				if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
				qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
				 } 
			} else if (la.kind == 1) {
				lexer.NextToken();

#line  1215 "cs.ATG" 
				qualident = t.val; 
			} else SynErr(139);
			if (la.kind == 23) {
				TypeParameterList(
#line  1218 "cs.ATG" 
templates);
			}
			Expect(20);
			if (StartOf(10)) {
				FormalParameterList(
#line  1221 "cs.ATG" 
p);
			}
			Expect(21);

#line  1222 "cs.ATG" 
			MethodDeclaration methodDeclaration = new MethodDeclaration(qualident,
			                                                         m.Modifier,
			                                                         new TypeReference("void"),
			                                                         p,
			                                                         attributes);
			methodDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
			methodDeclaration.EndLocation   = t.EndLocation;
			methodDeclaration.Templates = templates;
			if (explicitInterface != null)
			methodDeclaration.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
			compilationUnit.AddChild(methodDeclaration);
			compilationUnit.BlockStart(methodDeclaration);
			
			while (
#line  1237 "cs.ATG" 
IdentIsWhere()) {
				TypeParameterConstraintsClause(
#line  1237 "cs.ATG" 
templates);
			}
			if (la.kind == 16) {
				Block(
#line  1239 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(140);

#line  1239 "cs.ATG" 
			compilationUnit.BlockEnd();
			methodDeclaration.Body  = (BlockStatement)stmt;
			
		} else if (la.kind == 68) {

#line  1243 "cs.ATG" 
			m.Check(Modifier.PropertysEventsMethods); 
			lexer.NextToken();

#line  1244 "cs.ATG" 
			EventDeclaration eventDecl = new EventDeclaration(null, null, m.Modifier, attributes, null);
			eventDecl.StartLocation = t.Location;
			compilationUnit.AddChild(eventDecl);
			compilationUnit.BlockStart(eventDecl);
			EventAddRegion addBlock = null;
			EventRemoveRegion removeBlock = null;
			
			Type(
#line  1251 "cs.ATG" 
out type);

#line  1251 "cs.ATG" 
			eventDecl.TypeReference = type; 
			if (
#line  1252 "cs.ATG" 
IsExplicitInterfaceImplementation()) {
				TypeName(
#line  1253 "cs.ATG" 
out explicitInterface, false);

#line  1254 "cs.ATG" 
				qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface); 

#line  1255 "cs.ATG" 
				eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident)); 
			} else if (la.kind == 1) {
				lexer.NextToken();

#line  1257 "cs.ATG" 
				qualident = t.val; 
			} else SynErr(141);

#line  1259 "cs.ATG" 
			eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation; 
			if (la.kind == 16) {
				lexer.NextToken();

#line  1260 "cs.ATG" 
				eventDecl.BodyStart = t.Location; 
				EventAccessorDecls(
#line  1261 "cs.ATG" 
out addBlock, out removeBlock);
				Expect(17);

#line  1262 "cs.ATG" 
				eventDecl.BodyEnd   = t.EndLocation; 
			}
			if (la.kind == 11) {
				lexer.NextToken();
			}

#line  1265 "cs.ATG" 
			compilationUnit.BlockEnd();
			eventDecl.AddRegion = addBlock;
			eventDecl.RemoveRegion = removeBlock;
			
		} else if (
#line  1271 "cs.ATG" 
IdentAndLPar()) {

#line  1271 "cs.ATG" 
			m.Check(Modifier.Constructors | Modifier.StaticConstructors); 
			Expect(1);

#line  1272 "cs.ATG" 
			string name = t.val; Point startPos = t.Location; 
			Expect(20);
			if (StartOf(10)) {

#line  1272 "cs.ATG" 
				m.Check(Modifier.Constructors); 
				FormalParameterList(
#line  1273 "cs.ATG" 
p);
			}
			Expect(21);

#line  1275 "cs.ATG" 
			ConstructorInitializer init = null;  
			if (la.kind == 9) {

#line  1276 "cs.ATG" 
				m.Check(Modifier.Constructors); 
				ConstructorInitializer(
#line  1277 "cs.ATG" 
out init);
			}

#line  1279 "cs.ATG" 
			ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); 
			cd.StartLocation = startPos;
			cd.EndLocation   = t.EndLocation;
			
			if (la.kind == 16) {
				Block(
#line  1284 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(142);

#line  1284 "cs.ATG" 
			cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); 
		} else if (la.kind == 69 || la.kind == 79) {

#line  1287 "cs.ATG" 
			m.Check(Modifier.Operators);
			if (m.isNone) Error("at least one modifier must be set"); 
			bool isImplicit = true;
			Point startPos = Point.Empty;
			
			if (la.kind == 79) {
				lexer.NextToken();

#line  1292 "cs.ATG" 
				startPos = t.Location; 
			} else {
				lexer.NextToken();

#line  1292 "cs.ATG" 
				isImplicit = false; startPos = t.Location; 
			}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -