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

📄 parser.cs

📁 全功能c#编译器
💻 CS
📖 第 1 页 / 共 5 页
字号:
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  1072 "VBNET.ATG" 
out p);
					}
					Expect(26);
				}
			} else SynErr(205);
			if (la.kind == 108) {
				ImplementsClause(
#line  1074 "VBNET.ATG" 
out implementsClause);
			}

#line  1076 "VBNET.ATG" 
			eventDeclaration = new EventDeclaration(type, m.Modifier, p, attributes, name, implementsClause);
			eventDeclaration.StartLocation = startPos;
			eventDeclaration.EndLocation = t.EndLocation;
			compilationUnit.AddChild(eventDeclaration);
			
			Expect(1);
			break;
		}
		case 2: case 52: case 71: case 171: {

#line  1083 "VBNET.ATG" 
			Point startPos = t.Location; 

#line  1085 "VBNET.ATG" 
			m.Check(Modifier.Fields);
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
			fd.StartLocation = startPos; 
			
			VariableDeclarator(
#line  1089 "VBNET.ATG" 
variableDeclarators);
			while (la.kind == 12) {
				lexer.NextToken();
				VariableDeclarator(
#line  1090 "VBNET.ATG" 
variableDeclarators);
			}
			Expect(1);

#line  1093 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			fd.Fields = variableDeclarators;
			compilationUnit.AddChild(fd);
			
			break;
		}
		case 72: {

#line  1098 "VBNET.ATG" 
			m.Check(Modifier.Fields); 
			lexer.NextToken();

#line  1099 "VBNET.ATG" 
			m.Add(Modifier.Constant);  

#line  1101 "VBNET.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
			fd.StartLocation = t.Location;
			ArrayList constantDeclarators = new ArrayList();
			
			ConstantDeclarator(
#line  1105 "VBNET.ATG" 
constantDeclarators);
			while (la.kind == 12) {
				lexer.NextToken();
				ConstantDeclarator(
#line  1106 "VBNET.ATG" 
constantDeclarators);
			}

#line  1108 "VBNET.ATG" 
			fd.Fields = constantDeclarators;
			fd.EndLocation = t.Location;
			
			Expect(1);

#line  1113 "VBNET.ATG" 
			fd.EndLocation = t.EndLocation;
			compilationUnit.AddChild(fd);
			
			break;
		}
		case 148: {
			lexer.NextToken();

#line  1119 "VBNET.ATG" 
			m.Check(Modifier.Properties);
			Point startPos = t.Location;
			ImplementsClause implementsClause = null;
			
			Identifier();

#line  1123 "VBNET.ATG" 
			string propertyName = t.val; 
			if (la.kind == 25) {
				lexer.NextToken();
				if (StartOf(4)) {
					FormalParameterList(
#line  1124 "VBNET.ATG" 
out p);
				}
				Expect(26);
			}
			if (la.kind == 49) {
				lexer.NextToken();
				TypeName(
#line  1125 "VBNET.ATG" 
out type);
			}

#line  1127 "VBNET.ATG" 
			if(type == null) {
			type = new TypeReference("System.Object");
			}
			
			if (la.kind == 108) {
				ImplementsClause(
#line  1131 "VBNET.ATG" 
out implementsClause);
			}
			Expect(1);
			if (
#line  1135 "VBNET.ATG" 
IsMustOverride(m)) {

#line  1137 "VBNET.ATG" 
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				pDecl.StartLocation = startPos;
				pDecl.EndLocation   = t.Location;
				pDecl.TypeReference = type;
				pDecl.ImplementsClause = implementsClause;
				pDecl.Parameters = p;
				compilationUnit.AddChild(pDecl);
				
			} else if (la.kind == 28 || la.kind == 102 || la.kind == 158) {

#line  1147 "VBNET.ATG" 
				PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
				pDecl.StartLocation = startPos;
				pDecl.EndLocation   = t.Location;
				pDecl.BodyStart   = t.Location;
				pDecl.TypeReference = type;
				pDecl.ImplementsClause = implementsClause;
				pDecl.Parameters = p;
				PropertyGetRegion getRegion;
				PropertySetRegion setRegion;
				
				AccessorDecls(
#line  1157 "VBNET.ATG" 
out getRegion, out setRegion);
				Expect(89);
				Expect(148);
				Expect(1);

#line  1161 "VBNET.ATG" 
				pDecl.GetRegion = getRegion;
				pDecl.SetRegion = setRegion;
				pDecl.BodyEnd = t.EndLocation;
				compilationUnit.AddChild(pDecl);
				
			} else SynErr(206);
			break;
		}
		default: SynErr(207); break;
		}
	}

	void EnumMemberDecl(
#line  839 "VBNET.ATG" 
out FieldDeclaration f) {

#line  841 "VBNET.ATG" 
		Expression expr = null;
		ArrayList attributes = new ArrayList();
		AttributeSection section = null;
		VariableDeclaration varDecl = null;
		
		while (la.kind == 28) {
			AttributeSection(
#line  846 "VBNET.ATG" 
out section);

#line  846 "VBNET.ATG" 
			attributes.Add(section); 
		}
		Identifier();

#line  849 "VBNET.ATG" 
		f = new FieldDeclaration(attributes);
		varDecl = new VariableDeclaration(t.val);
		f.Fields.Add(varDecl);
		f.StartLocation = t.Location;
		
		if (la.kind == 11) {
			lexer.NextToken();
			Expr(
#line  854 "VBNET.ATG" 
out expr);

#line  854 "VBNET.ATG" 
			varDecl.Initializer = expr; 
		}
		Expect(1);
	}

	void InterfaceMemberDecl() {

#line  745 "VBNET.ATG" 
		TypeReference type =null;
		ArrayList p = null;
		AttributeSection section;
		Modifiers mod = new Modifiers(this);
		ArrayList attributes = new ArrayList();
		ArrayList parameters = new ArrayList();
		string name;
		
		if (StartOf(12)) {
			while (la.kind == 28) {
				AttributeSection(
#line  753 "VBNET.ATG" 
out section);

#line  753 "VBNET.ATG" 
				attributes.Add(section); 
			}
			while (StartOf(6)) {
				MemberModifier(
#line  757 "VBNET.ATG" 
mod);
			}
			if (la.kind == 94) {
				lexer.NextToken();

#line  760 "VBNET.ATG" 
				mod.Check(Modifier.InterfaceEvents); 
				Identifier();

#line  761 "VBNET.ATG" 
				name = t.val; 
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  762 "VBNET.ATG" 
out p);
					}
					Expect(26);
				}
				if (la.kind == 49) {
					lexer.NextToken();
					TypeName(
#line  763 "VBNET.ATG" 
out type);
				}
				Expect(1);

#line  766 "VBNET.ATG" 
				EventDeclaration ed = new EventDeclaration(type, mod.Modifier, p, attributes, name, null);
				compilationUnit.AddChild(ed);
				ed.EndLocation = t.EndLocation;
				
			} else if (la.kind == 169) {
				lexer.NextToken();

#line  772 "VBNET.ATG" 
				mod.Check(Modifier.InterfaceMethods); 
				Identifier();

#line  773 "VBNET.ATG" 
				name = t.val; 
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  774 "VBNET.ATG" 
out p);
					}
					Expect(26);
				}
				Expect(1);

#line  777 "VBNET.ATG" 
				MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, null, p, attributes);
				md.EndLocation = t.EndLocation;
				compilationUnit.AddChild(md);
				
			} else if (la.kind == 101) {
				lexer.NextToken();

#line  783 "VBNET.ATG" 
				mod.Check(Modifier.InterfaceMethods); 
				Identifier();

#line  784 "VBNET.ATG" 
				name = t.val; 
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  785 "VBNET.ATG" 
out p);
					}
					Expect(26);
				}
				if (la.kind == 49) {
					lexer.NextToken();
					TypeName(
#line  786 "VBNET.ATG" 
out type);
				}

#line  788 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object");
				}
				MethodDeclaration md = new MethodDeclaration(name, mod.Modifier, type, p, attributes);
				md.EndLocation = t.EndLocation;
				compilationUnit.AddChild(md);
				
				Expect(1);
			} else if (la.kind == 148) {
				lexer.NextToken();

#line  798 "VBNET.ATG" 
				mod.Check(Modifier.InterfaceProperties); 
				Identifier();

#line  799 "VBNET.ATG" 
				name = t.val;  
				if (la.kind == 25) {
					lexer.NextToken();
					if (StartOf(4)) {
						FormalParameterList(
#line  800 "VBNET.ATG" 
out p);
					}
					Expect(26);
				}
				if (la.kind == 49) {
					lexer.NextToken();
					TypeName(
#line  801 "VBNET.ATG" 
out type);
				}

#line  803 "VBNET.ATG" 
				if(type == null) {
				type = new TypeReference("System.Object");
				}
				
				Expect(1);

#line  809 "VBNET.ATG" 
				PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
				pd.Parameters = p;
				pd.EndLocation = t.EndLocation;
				compilationUnit.AddChild(pd);
				
			} else if (la.kind == 91) {
				lexer.NextToken();

#line  817 "VBNET.ATG" 
				mod.Check(Modifier.InterfaceEnums);
				TypeDeclaration newType = new TypeDeclaration();
				compilationUnit.AddChild(newType);
				compilationUnit.BlockStart(newType);
				newType.StartLocation = t.Location;
				newType.Type = Types.Enum;
				newType.Modifier = mod.Modifier;
				newType.Attributes = attributes;
				
				Identifier();

#line  826 "VBNET.ATG" 
				newType.Name = t.val; 
				if (la.kind == 49) {
					lexer.NextToken();
					PrimitiveTypeName(
#line  827 "VBNET.ATG" 
out name);

#line  827 "VBNET.ATG" 
					newType.BaseType = name; 
				}
				Expect(1);
				EnumBody(
#line  829 "VBNET.ATG" 
newType);

#line  831 "VBNET.ATG" 
				compilationUnit.BlockEnd();
				
			} else SynErr(208);
		} else if (StartOf(13)) {
			NonModuleDeclaration(
#line  835 "VBNET.ATG" 
mod, attributes);
		} else SynErr(209);
	}

	void Expr(
#line  1415 "VBNET.ATG" 
out Expression expr) {

#line  1416 "VBNET.ATG" 
		expr = new Expression(); 
		ConditionalOrExpr(
#line  1417 "VBNET.ATG" 
out expr);
		while (StartOf(14)) {

#line  1420 "VBNET.ATG" 
			AssignmentOperatorType op; Expression val; 
			AssignmentOperator(
#line  1421 "VBNET.ATG" 
out op);
			Expr(
#line  1421 "VBNET.ATG" 
out val);

#line  1421 "VBNET.ATG" 
			expr = new AssignmentExpression(expr, op, val); 
		}
	}

	void ImplementsClause(
#line  1393 "VBNET.ATG" 
out ImplementsClause clause) {

#line  1395 "VBNET.ATG" 
		clause = new ImplementsClause();
		string typename = String.Empty;
		string first;
		
		Expect(108);
		Identifier();

#line  1399 "VBNET.ATG" 
		first = t.val; 
		Expect(10);
		Qualident(
#line  1399 "VBNET.ATG" 
out typename);

#line  1399 "VBNET.ATG" 
		((ImplementsClause)clause).BaseMembers.Add(first + "." + typename); 
		while (la.kind == 12) {
			lexer.NextToken();
			Identifier();

#line  1400 "VBNET.ATG" 
			first = t.val; 
			Expect(10);
			Qualident(
#line  1400 "VBNET.ATG" 
out typename);

#line  1400 "VBNET.ATG" 
			((ImplementsClause)clause).BaseMembers.Add(first + "." + typename); 
		}
	}

	void HandlesClause(
#line  1351 "VBNET.ATG" 
out HandlesClause handlesClause) {

#line  1353 "VBNET.ATG" 
		handlesClause = new HandlesClause();
		string name;
		
		Expect(106);
		EventMemberSpecifier(
#line  1356 "VBNET.ATG" 
out name);

#line  1356 "VBNET.ATG" 
		handlesClause.EventNames.Add(name); 
		while (la.kind == 12) {
			lexer.NextToken();
			EventMemberSpecifier(
#line  1357 "VBNET.ATG" 
out name);

#line  1357 "VBNET.ATG" 
			handlesClause.EventNames.Add(name); 
		}
	}

	void Block(
#line  1959 "VBNET.ATG" 
out Statement stmt) {

#line  1962 "VBNET.ATG" 
		BlockStatement blockStmt = new BlockStatement();
		blockStmt.StartLocation = t.Location;
		compilationUnit.BlockStart(blockStmt);
		
		while (StartOf(15) || 
#line  1967 "VBNET.ATG" 
IsEndStmtAhead()) {
			if (StartOf(15)) {
				Statement();
				EndOfStmt();
			} else {
				Expect(89);
				EndOfStmt();

#line  1967 "VBNET.ATG" 
				compilationUnit.AddChild(new EndStatement()); 
			}
		}

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

	void Charset(
#line  1343 "VBNET.ATG" 
out CharsetModifier charsetModifier) {

#line  1344 "VBNET.ATG" 
		charsetModifier = CharsetModifier.None; 
		if (la.kind == 101 || la.kind == 169) {
		} else if (la.kind == 48) {
			lexer.NextToken();

#line  1345 "VBNET.ATG" 
			charsetModifier = CharsetModifier.ANSI; 
		} else if (la.kind == 51) {
			lexer.NextToken();

#line  1346 "VBNET.ATG" 
			charsetModifier = CharsetModifier.Auto; 
		} else if (la.kind == 178) {
			lexer.NextToken();

#line  1347 "VBNET.ATG" 
			charsetModifier = CharsetModifier.Unicode; 
		} else SynErr(210);
	}

	void VariableDeclarator(
#line  1244 "VBNET.ATG" 
ArrayList fieldDeclaration) {

#line  1246 "VBNET.ATG" 
		Expression expr = null;
		TypeReference type = null;
		ObjectCreateExpression oce = null;
		ArrayCreateExpression ace = null;
		ArrayList rank = null;
		ArrayList dimension = null;
		
		Identifier();

#line  1255 "VBNET.ATG" 
		VariableDeclaration f = new VariableDeclaration(t.val);
		
		if (
#line  1257 "VBNET.ATG" 
IsDims()) {
			ArrayNameModifier(
#line  1257 "VBNET.ATG" 
out rank);
		}
		if (
#line  1258 "VBNET.ATG" 
IsSize()) {
			ArrayInitializationModifier(
#line  1258 "VBNET.ATG" 
out dimension);
		}
		if (
#line  1260 "VBNET.ATG" 
IsObjectCreation()) {
			Expect(49);
			ObjectCreateExpression(
#line  1260 "VBNET.ATG" 
out expr);

#line  1262 "VBNET.ATG" 
			if(expr is ArrayCreateExpression) {
			ace = expr as ArrayCreateExpression;
			f.Initializer = ace.ArrayInitializer;
			
			} else {
				oce = expr as ObjectCreateExpression;
				f.Initializer = oce;
				if(oce.CreateType != null) {
					f.Type = oce.CreateType;
				}
			}
			
		} else if (StartOf(16)) {
			if (la.kind == 49) {
				lexer.NextToken();
				TypeName(
#line  1275 "VBNET.ATG" 
out type);
			}

#line  1277 "VBNET.ATG" 
			if(type != null) {
			type.Dimension = dimension;
			}
			f.Type = type;
			if (type != null && rank != null) {
				if(type.RankSpecifier != null) {
					Error("array rank only allowed one time");
				} else {
					type.RankSpecifier = rank;
				}
			}
			
			if (la.kind == 11) {
				lexer.NextToken();
				VariableInitializer(
#line  1289 "VBNET.ATG" 
out expr);

#line  1289 "VBNET.ATG" 
				f.Initializer = expr; 

⌨️ 快捷键说明

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