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

📄 parser.cs

📁 全功能c#编译器
💻 CS
📖 第 1 页 / 共 5 页
字号:
		while (
#line  862 "cs.ATG" 
IsPointer()) {
			Expect(6);

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

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

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

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

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

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

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

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

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

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

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

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

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

	void VariableDeclarator(
#line  1363 "cs.ATG" 
ArrayList fieldDeclaration) {

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

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

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

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

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

#line  1313 "cs.ATG" 
		AttributeSection section;
		ArrayList attributes = new ArrayList();
		Statement stmt;
		addBlock = null;
		removeBlock = null;
		
		while (la.kind == 16) {
			AttributeSection(
#line  1320 "cs.ATG" 
out section);

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

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

#line  1323 "cs.ATG" 
			attributes = new ArrayList(); addBlock.Block = (BlockStatement)stmt; 
			while (la.kind == 16) {
				AttributeSection(
#line  1324 "cs.ATG" 
out section);

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

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

#line  1327 "cs.ATG" 
			removeBlock = new EventRemoveRegion(attributes); removeBlock.Block = (BlockStatement)stmt; attributes = new ArrayList(); 
			while (la.kind == 16) {
				AttributeSection(
#line  1328 "cs.ATG" 
out section);

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

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

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

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

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

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

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

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

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

	void OverloadableOperator(
#line  1420 "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  1429 "cs.ATG" 
		op = t; 
	}

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

#line  1272 "cs.ATG" 
		ArrayList attributes = new ArrayList(); 
		AttributeSection section;
		getBlock = null;
		setBlock = null; 
		
		while (la.kind == 16) {
			AttributeSection(
#line  1278 "cs.ATG" 
out section);

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

#line  1282 "cs.ATG" 
				attributes = new ArrayList(); 
				while (la.kind == 16) {
					AttributeSection(
#line  1283 "cs.ATG" 
out section);

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

#line  1288 "cs.ATG" 
				attributes = new ArrayList(); 
				while (la.kind == 16) {
					AttributeSection(
#line  1289 "cs.ATG" 
out section);

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

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

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

#line  1336 "cs.ATG" 
		AttributeSection section;
		ArrayList attributes = new ArrayList();
		getBlock = null; setBlock = null;
		
		while (la.kind == 16) {
			AttributeSection(
#line  1341 "cs.ATG" 
out section);

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

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

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

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

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

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

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

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

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

	void GetAccessorDecl(
#line  1296 "cs.ATG" 
out PropertyGetRegion getBlock, ArrayList attributes) {

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

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

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

	void SetAccessorDecl(
#line  1304 "cs.ATG" 
out PropertySetRegion setBlock, ArrayList attributes) {

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

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

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

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

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

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

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

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

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

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

#line  1413 "cs.ATG" 
		TypeReference type = null; Expression expr = null; initializerExpression = null; 
		if (StartOf(4)) {
			Expr(
#line  1415 "cs.ATG" 
out initializerExpression);
		} else if (la.kind == 14) {
			ArrayInitializer(
#line  1416 "cs.ATG" 
out initializerExpression);
		} else if (la.kind == 105) {
			lexer.NextToken();
			Type(
#line  1417 "cs.ATG" 
out type);
			Expect(16);
			Expr(
#line  1417 "cs.ATG" 
out expr);
			Expect(17);

#line  1417 "cs.ATG" 
			initializerExpression = new StackAllocExpression(type, expr); 
		} else SynErr(164);
	}

	void Statement() {

#line  1501 "cs.ATG" 
		TypeReference type;
		Expression expr;
		Statement stmt;
		
		if (
#line  1507 "cs.ATG" 
IsLabel()) {
			Expect(1);

#line  1507 "cs.ATG" 
			compilationUnit.AddChild(new LabelStatement(t.val)); 
			Expect(9);
			Statement();
		} else if (la.kind == 59) {
			lexer.NextToken();
			Type(
#line  1510 "cs.ATG" 
out type);

#line  1510 "cs.ATG" 
			LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; 
			Expect(1);

#line  1511 "cs.ATG" 
			i

⌨️ 快捷键说明

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