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

📄 parser.cs

📁 全功能c#编译器
💻 CS
📖 第 1 页 / 共 5 页
字号:

#line  869 "cs.ATG" 
			name = "decimal"; 
		} else if (la.kind == 51) {
			lexer.NextToken();

#line  870 "cs.ATG" 
			name = "bool"; 
		} else SynErr(154);
	}

	void NonArrayType(
#line  845 "cs.ATG" 
out TypeReference type) {

#line  847 "cs.ATG" 
		string name = "";
		int pointer = 0;
		
		if (la.kind == 1 || la.kind == 90 || la.kind == 107) {
			ClassType(
#line  851 "cs.ATG" 
out name);
		} else if (StartOf(14)) {
			SimpleType(
#line  852 "cs.ATG" 
out name);
		} else if (la.kind == 122) {
			lexer.NextToken();
			Expect(6);

#line  853 "cs.ATG" 
			pointer = 1; name = "void"; 
		} else SynErr(155);
		while (
#line  855 "cs.ATG" 
IsPointer()) {
			Expect(6);

#line  856 "cs.ATG" 
			++pointer; 
		}

#line  859 "cs.ATG" 
		type = new TypeReference(name, pointer, null);
		
	}

	void FixedParameter(
#line  900 "cs.ATG" 
out ParameterDeclarationExpression p) {

#line  902 "cs.ATG" 
		TypeReference type;
		ParamModifiers mod = ParamModifiers.In;
		
		if (la.kind == 92 || la.kind == 99) {
			if (la.kind == 99) {
				lexer.NextToken();

#line  907 "cs.ATG" 
				mod = ParamModifiers.Ref; 
			} else {
				lexer.NextToken();

#line  908 "cs.ATG" 
				mod = ParamModifiers.Out; 
			}
		}
		Type(
#line  910 "cs.ATG" 
out type);
		Expect(1);

#line  910 "cs.ATG" 
		p = new ParameterDeclarationExpression(type, t.val, mod); 
	}

	void ParameterArray(
#line  913 "cs.ATG" 
out ParameterDeclarationExpression p) {

#line  914 "cs.ATG" 
		TypeReference type; 
		Expect(94);
		Type(
#line  916 "cs.ATG" 
out type);
		Expect(1);

#line  916 "cs.ATG" 
		p = new ParameterDeclarationExpression(type, t.val, ParamModifiers.Params); 
	}

	void Block(
#line  1368 "cs.ATG" 
out Statement stmt) {
		Expect(14);

#line  1370 "cs.ATG" 
		BlockStatement blockStmt = new BlockStatement();
		blockStmt.StartLocation = t.Location;
		compilationUnit.BlockStart(blockStmt);
		
		while (StartOf(20)) {
			Statement();
		}
		Expect(15);

#line  1375 "cs.ATG" 
		stmt = blockStmt;
		blockStmt.EndLocation = t.EndLocation;
		compilationUnit.BlockEnd();
		
	}

	void VariableDeclarator(
#line  1361 "cs.ATG" 
List<VariableDeclaration> fieldDeclaration) {

#line  1362 "cs.ATG" 
		Expression expr = null; 
		Expect(1);

#line  1364 "cs.ATG" 
		VariableDeclaration f = new VariableDeclaration(t.val); 
		if (la.kind == 3) {
			lexer.NextToken();
			VariableInitializer(
#line  1365 "cs.ATG" 
out expr);

#line  1365 "cs.ATG" 
			f.Initializer = expr; 
		}

#line  1365 "cs.ATG" 
		fieldDeclaration.Add(f); 
	}

	void EventAccessorDecls(
#line  1310 "cs.ATG" 
out EventAddRegion addBlock, out EventRemoveRegion removeBlock) {

#line  1311 "cs.ATG" 
		AttributeSection section;
		List<AttributeSection> attributes = new List<AttributeSection>();
		Statement stmt;
		addBlock = null;
		removeBlock = null;
		
		while (la.kind == 16) {
			AttributeSection(
#line  1318 "cs.ATG" 
out section);

#line  1318 "cs.ATG" 
			attributes.Add(section); 
		}
		if (
#line  1320 "cs.ATG" 
IdentIsAdd()) {

#line  1320 "cs.ATG" 
			addBlock = new EventAddRegion(attributes); 
			AddAccessorDecl(
#line  1321 "cs.ATG" 
out stmt);

#line  1321 "cs.ATG" 
			attributes = new List<AttributeSection>(); addBlock.Block = (BlockStatement)stmt; 
			while (la.kind == 16) {
				AttributeSection(
#line  1322 "cs.ATG" 
out section);

#line  1322 "cs.ATG" 
				attributes.Add(section); 
			}
			RemoveAccessorDecl(
#line  1323 "cs.ATG" 
out stmt);

#line  1323 "cs.ATG" 
			removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; 
		} else if (
#line  1324 "cs.ATG" 
IdentIsRemove()) {
			RemoveAccessorDecl(
#line  1325 "cs.ATG" 
out stmt);

#line  1325 "cs.ATG" 
			removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new List<AttributeSection>(); 
			while (la.kind == 16) {
				AttributeSection(
#line  1326 "cs.ATG" 
out section);

#line  1326 "cs.ATG" 
				attributes.Add(section); 
			}
			AddAccessorDecl(
#line  1327 "cs.ATG" 
out stmt);

#line  1327 "cs.ATG" 
			addBlock = new EventAddRegion(attributes); addBlock.Block = (BlockStatement)stmt; 
		} else if (la.kind == 1) {
			lexer.NextToken();

#line  1328 "cs.ATG" 
			Error("add or remove accessor declaration expected"); 
		} else SynErr(156);
	}

	void ConstructorInitializer(
#line  1397 "cs.ATG" 
out ConstructorInitializer ci) {

#line  1398 "cs.ATG" 
		Expression expr; ci = new ConstructorInitializer(); 
		Expect(9);
		if (la.kind == 50) {
			lexer.NextToken();

#line  1402 "cs.ATG" 
			ci.ConstructorInitializerType = ConstructorInitializerType.Base; 
		} else if (la.kind == 110) {
			lexer.NextToken();

#line  1403 "cs.ATG" 
			ci.ConstructorInitializerType = ConstructorInitializerType.This; 
		} else SynErr(157);
		Expect(18);
		if (StartOf(21)) {
			Argument(
#line  1406 "cs.ATG" 
out expr);

#line  1406 "cs.ATG" 
			ci.Arguments.Add(expr); 
			while (la.kind == 12) {
				lexer.NextToken();
				Argument(
#line  1406 "cs.ATG" 
out expr);

#line  1406 "cs.ATG" 
				ci.Arguments.Add(expr); 
			}
		}
		Expect(19);
	}

	void OverloadableOperator(
#line  1418 "cs.ATG" 
out Token op) {
		switch (la.kind) {
		case 4: {
			lexer.NextToken();
			break;
		}
		case 5: {
			lexer.NextToken();
			break;
		}
		case 22: {
			lexer.NextToken();
			break;
		}
		case 25: {
			lexer.NextToken();
			break;
		}
		case 29: {
			lexer.NextToken();
			break;
		}
		case 30: {
			lexer.NextToken();
			break;
		}
		case 112: {
			lexer.NextToken();
			break;
		}
		case 71: {
			lexer.NextToken();
			break;
		}
		case 6: {
			lexer.NextToken();
			break;
		}
		case 7: {
			lexer.NextToken();
			break;
		}
		case 8: {
			lexer.NextToken();
			break;
		}
		case 26: {
			lexer.NextToken();
			break;
		}
		case 27: {
			lexer.NextToken();
			break;
		}
		case 28: {
			lexer.NextToken();
			break;
		}
		case 35: {
			lexer.NextToken();
			break;
		}
		case 36: {
			lexer.NextToken();
			break;
		}
		case 31: {
			lexer.NextToken();
			break;
		}
		case 32: {
			lexer.NextToken();
			break;
		}
		case 20: {
			lexer.NextToken();
			break;
		}
		case 21: {
			lexer.NextToken();
			break;
		}
		case 33: {
			lexer.NextToken();
			break;
		}
		case 34: {
			lexer.NextToken();
			break;
		}
		default: SynErr(158); break;
		}

#line  1427 "cs.ATG" 
		op = t; 
	}

	void AccessorDecls(
#line  1268 "cs.ATG" 
out PropertyGetRegion getBlock, out PropertySetRegion setBlock) {

#line  1270 "cs.ATG" 
		List<AttributeSection> attributes = new List<AttributeSection>(); 
		AttributeSection section;
		getBlock = null;
		setBlock = null; 
		
		while (la.kind == 16) {
			AttributeSection(
#line  1276 "cs.ATG" 
out section);

#line  1276 "cs.ATG" 
			attributes.Add(section); 
		}
		if (
#line  1278 "cs.ATG" 
IdentIsGet()) {
			GetAccessorDecl(
#line  1279 "cs.ATG" 
out getBlock, attributes);
			if (la.kind == 1 || la.kind == 16) {

#line  1280 "cs.ATG" 
				attributes = new List<AttributeSection>(); 
				while (la.kind == 16) {
					AttributeSection(
#line  1281 "cs.ATG" 
out section);

#line  1281 "cs.ATG" 
					attributes.Add(section); 
				}
				SetAccessorDecl(
#line  1282 "cs.ATG" 
out setBlock, attributes);
			}
		} else if (
#line  1284 "cs.ATG" 
IdentIsSet()) {
			SetAccessorDecl(
#line  1285 "cs.ATG" 
out setBlock, attributes);
			if (la.kind == 1 || la.kind == 16) {

#line  1286 "cs.ATG" 
				attributes = new List<AttributeSection>(); 
				while (la.kind == 16) {
					AttributeSection(
#line  1287 "cs.ATG" 
out section);

#line  1287 "cs.ATG" 
					attributes.Add(section); 
				}
				GetAccessorDecl(
#line  1288 "cs.ATG" 
out getBlock, attributes);
			}
		} else if (la.kind == 1) {
			lexer.NextToken();

#line  1290 "cs.ATG" 
			Error("get or set accessor declaration expected"); 
		} else SynErr(159);
	}

	void InterfaceAccessors(
#line  1332 "cs.ATG" 
out PropertyGetRegion getBlock, out PropertySetRegion setBlock) {

#line  1334 "cs.ATG" 
		AttributeSection section;
		List<AttributeSection> attributes = new List<AttributeSection>();
		getBlock = null; setBlock = null;
		
		while (la.kind == 16) {
			AttributeSection(
#line  1339 "cs.ATG" 
out section);

#line  1339 "cs.ATG" 
			attributes.Add(section); 
		}
		if (
#line  1341 "cs.ATG" 
IdentIsGet()) {
			Expect(1);

#line  1341 "cs.ATG" 
			getBlock = new PropertyGetRegion(null, attributes); 
		} else if (
#line  1342 "cs.ATG" 
IdentIsSet()) {
			Expect(1);

#line  1342 "cs.ATG" 
			setBlock = new PropertySetRegion(null, attributes); 
		} else if (la.kind == 1) {
			lexer.NextToken();

#line  1343 "cs.ATG" 
			Error("set or get expected"); 
		} else SynErr(160);
		Expect(10);

#line  1345 "cs.ATG" 
		attributes = new List<AttributeSection>(); 
		if (la.kind == 1 || la.kind == 16) {
			while (la.kind == 16) {
				AttributeSection(
#line  1347 "cs.ATG" 
out section);

#line  1347 "cs.ATG" 
				attributes.Add(section); 
			}
			if (
#line  1349 "cs.ATG" 
IdentIsGet()) {
				Expect(1);

#line  1349 "cs.ATG" 
				if (getBlock != null) Error("get already declared");
				else getBlock = new PropertyGetRegion(null, attributes);
				
			} else if (
#line  1352 "cs.ATG" 
IdentIsSet()) {
				Expect(1);

#line  1352 "cs.ATG" 
				if (setBlock != null) Error("set already declared");
				else setBlock = new PropertySetRegion(null, attributes);
				
			} else if (la.kind == 1) {
				lexer.NextToken();

#line  1355 "cs.ATG" 
				Error("set or get expected"); 
			} else SynErr(161);
			Expect(10);
		}
	}

	void GetAccessorDecl(
#line  1294 "cs.ATG" 
out PropertyGetRegion getBlock, List<AttributeSection> attributes) {

#line  1295 "cs.ATG" 
		Statement stmt = null; 
		Expect(1);

#line  1298 "cs.ATG" 
		if (t.val != "get") Error("get expected"); 
		if (la.kind == 14) {
			Block(
#line  1299 "cs.ATG" 
out stmt);
		} else if (la.kind == 10) {
			lexer.NextToken();
		} else SynErr(162);

#line  1299 "cs.ATG" 
		getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); 
	}

	void SetAccessorDecl(
#line  1302 "cs.ATG" 
out PropertySetRegion setBlock, List<AttributeSection> attributes) {

#line  1303 "cs.ATG" 
		Statement stmt = null; 
		Expect(1);

#line  1306 "cs.ATG" 
		if (t.val != "set") Error("set expected"); 
		if (la.kind == 14) {
			Block(
#line  1307 "cs.ATG" 
out stmt);
		} else if (la.kind == 10) {
			lexer.NextToken();
		} else SynErr(163);

#line  1307 "cs.ATG" 
		setBlock = new PropertySetRegion((BlockStatement)stmt, attributes); 
	}

	void AddAccessorDecl(
#line  1381 "cs.ATG" 
out Statement stmt) {

#line  1382 "cs.ATG" 
		stmt = null;
		Expect(1);

#line  1385 "cs.ATG" 
		if (t.val != "add") Error("add expected"); 
		Block(
#line  1386 "cs.ATG" 
out stmt);
	}

	void RemoveAccessorDecl(
#line  1389 "cs.ATG" 
out Statement stmt) {

#line  1390 "cs.ATG" 
		stmt = null;
		Expect(1);

#line  1393 "cs.ATG" 
		if (t.val != "remove") Error("remove expected"); 
		Block(
#line  1394 "cs.ATG" 
out stmt);
	}

	void VariableInitializer(
#line  1410 "cs.ATG" 
out Expression initializerExpression) {

#line  1411 "cs.ATG" 
		TypeReference type = null; Expression expr = null; initializerExpression = null; 
		if (StartOf(4)) {
			Expr(
#line  1413 "cs.ATG" 
out initializerExpression);
		} else if (la.kind == 14) {
			ArrayInitializer(
#line  1414 "cs.ATG" 

⌨️ 快捷键说明

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