Exemplo n.º 1
0
		public static void AddStatement(this BlockStatement block, Statement statement)
		{
			if (block == null)
				throw new ArgumentNullException("block");
			if (statement == null)
				throw new ArgumentNullException("statement");
			block.AddChild(statement);
			statement.Parent = block;
		}
Exemplo n.º 2
0
		public ForStatement(List<Statement> initializers, Expression condition, List<Statement> iterator, Statement embeddedStatement) {
			Initializers = initializers;
			Condition = condition;
			Iterator = iterator;
			EmbeddedStatement = embeddedStatement;
		}
Exemplo n.º 3
0
	void TryStatement(
#line  1721 "Frames/cs.ATG" 
out Statement tryStatement) {

#line  1723 "Frames/cs.ATG" 
		Statement blockStmt = null, finallyStmt = null;
		CatchClause catchClause = null;
		List<CatchClause> catchClauses = new List<CatchClause>();
		
		Expect(114);
		Block(
#line  1728 "Frames/cs.ATG" 
out blockStmt);
		while (la.kind == 56) {
			CatchClause(
#line  1730 "Frames/cs.ATG" 
out catchClause);

#line  1731 "Frames/cs.ATG" 
			if (catchClause != null) catchClauses.Add(catchClause); 
		}
		if (la.kind == 73) {
			lexer.NextToken();
			Block(
#line  1733 "Frames/cs.ATG" 
out finallyStmt);
		}

#line  1735 "Frames/cs.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		if (catchClauses != null) {
			foreach (CatchClause cc in catchClauses) cc.Parent = tryStatement;
		}
		
	}
Exemplo n.º 4
0
	void GotoStatement(
#line  1768 "Frames/cs.ATG" 
out Statement stmt) {

#line  1769 "Frames/cs.ATG" 
		Expression expr; stmt = null; 
		Expect(78);
		if (StartOf(19)) {
			Identifier();

#line  1773 "Frames/cs.ATG" 
			stmt = new GotoStatement(t.val); 
			Expect(11);
		} else if (la.kind == 55) {
			lexer.NextToken();
			Expr(
#line  1774 "Frames/cs.ATG" 
out expr);
			Expect(11);

#line  1774 "Frames/cs.ATG" 
			stmt = new GotoCaseStatement(expr); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(11);

#line  1775 "Frames/cs.ATG" 
			stmt = new GotoCaseStatement(null); 
		} else SynErr(202);
	}
Exemplo n.º 5
0
	void EmbeddedStatement(
#line  1550 "Frames/cs.ATG" 
out Statement statement) {

#line  1552 "Frames/cs.ATG" 
		TypeReference type = null;
		Expression expr = null;
		Statement embeddedStatement = null;
		statement = null;
		

#line  1558 "Frames/cs.ATG" 
		Location startLocation = la.Location; 
		if (la.kind == 16) {
			Block(
#line  1560 "Frames/cs.ATG" 
out statement);
		} else if (la.kind == 11) {
			lexer.NextToken();

#line  1563 "Frames/cs.ATG" 
			statement = new EmptyStatement(); 
		} else if (
#line  1566 "Frames/cs.ATG" 
UnCheckedAndLBrace()) {

#line  1566 "Frames/cs.ATG" 
			Statement block; bool isChecked = true; 
			if (la.kind == 58) {
				lexer.NextToken();
			} else if (la.kind == 118) {
				lexer.NextToken();

#line  1567 "Frames/cs.ATG" 
				isChecked = false;
			} else SynErr(197);
			Block(
#line  1568 "Frames/cs.ATG" 
out block);

#line  1568 "Frames/cs.ATG" 
			statement = isChecked ? (Statement)new CheckedStatement(block) : (Statement)new UncheckedStatement(block); 
		} else if (la.kind == 79) {
			IfStatement(
#line  1571 "Frames/cs.ATG" 
out statement);
		} else if (la.kind == 110) {
			lexer.NextToken();

#line  1573 "Frames/cs.ATG" 
			List<SwitchSection> switchSections = new List<SwitchSection>(); 
			Expect(20);
			Expr(
#line  1574 "Frames/cs.ATG" 
out expr);
			Expect(21);
			Expect(16);
			SwitchSections(
#line  1575 "Frames/cs.ATG" 
switchSections);
			Expect(17);

#line  1577 "Frames/cs.ATG" 
			statement = new SwitchStatement(expr, switchSections); 
		} else if (la.kind == 125) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1580 "Frames/cs.ATG" 
out expr);
			Expect(21);
			EmbeddedStatement(
#line  1581 "Frames/cs.ATG" 
out embeddedStatement);

#line  1582 "Frames/cs.ATG" 
			statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
		} else if (la.kind == 65) {
			lexer.NextToken();
			EmbeddedStatement(
#line  1584 "Frames/cs.ATG" 
out embeddedStatement);
			Expect(125);
			Expect(20);
			Expr(
#line  1585 "Frames/cs.ATG" 
out expr);
			Expect(21);
			Expect(11);

#line  1586 "Frames/cs.ATG" 
			statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.End); 
		} else if (la.kind == 76) {
			lexer.NextToken();

#line  1588 "Frames/cs.ATG" 
			List<Statement> initializer = null; List<Statement> iterator = null; 
			Expect(20);
			if (StartOf(6)) {
				ForInitializer(
#line  1589 "Frames/cs.ATG" 
out initializer);
			}
			Expect(11);
			if (StartOf(6)) {
				Expr(
#line  1590 "Frames/cs.ATG" 
out expr);
			}
			Expect(11);
			if (StartOf(6)) {
				ForIterator(
#line  1591 "Frames/cs.ATG" 
out iterator);
			}
			Expect(21);
			EmbeddedStatement(
#line  1592 "Frames/cs.ATG" 
out embeddedStatement);

#line  1593 "Frames/cs.ATG" 
			statement = new ForStatement(initializer, expr, iterator, embeddedStatement); 
		} else if (la.kind == 77) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1595 "Frames/cs.ATG" 
out type);
			Identifier();

#line  1595 "Frames/cs.ATG" 
			string varName = t.val; 
			Expect(81);
			Expr(
#line  1596 "Frames/cs.ATG" 
out expr);
			Expect(21);
			EmbeddedStatement(
#line  1597 "Frames/cs.ATG" 
out embeddedStatement);

#line  1598 "Frames/cs.ATG" 
			statement = new ForeachStatement(type, varName , expr, embeddedStatement); 
		} else if (la.kind == 53) {
			lexer.NextToken();
			Expect(11);

#line  1601 "Frames/cs.ATG" 
			statement = new BreakStatement(); 
		} else if (la.kind == 61) {
			lexer.NextToken();
			Expect(11);

#line  1602 "Frames/cs.ATG" 
			statement = new ContinueStatement(); 
		} else if (la.kind == 78) {
			GotoStatement(
#line  1603 "Frames/cs.ATG" 
out statement);
		} else if (
#line  1605 "Frames/cs.ATG" 
IsYieldStatement()) {
			Expect(132);
			if (la.kind == 101) {
				lexer.NextToken();
				Expr(
#line  1606 "Frames/cs.ATG" 
out expr);

#line  1606 "Frames/cs.ATG" 
				statement = new YieldStatement(new ReturnStatement(expr)); 
			} else if (la.kind == 53) {
				lexer.NextToken();

#line  1607 "Frames/cs.ATG" 
				statement = new YieldStatement(new BreakStatement()); 
			} else SynErr(198);
			Expect(11);
		} else if (la.kind == 101) {
			lexer.NextToken();
			if (StartOf(6)) {
				Expr(
#line  1610 "Frames/cs.ATG" 
out expr);
			}
			Expect(11);

#line  1610 "Frames/cs.ATG" 
			statement = new ReturnStatement(expr); 
		} else if (la.kind == 112) {
			lexer.NextToken();
			if (StartOf(6)) {
				Expr(
#line  1611 "Frames/cs.ATG" 
out expr);
			}
			Expect(11);

#line  1611 "Frames/cs.ATG" 
			statement = new ThrowStatement(expr); 
		} else if (StartOf(6)) {
			StatementExpr(
#line  1614 "Frames/cs.ATG" 
out statement);
			while (!(la.kind == 0 || la.kind == 11)) {SynErr(199); lexer.NextToken(); }
			Expect(11);
		} else if (la.kind == 114) {
			TryStatement(
#line  1617 "Frames/cs.ATG" 
out statement);
		} else if (la.kind == 86) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1620 "Frames/cs.ATG" 
out expr);
			Expect(21);
			EmbeddedStatement(
#line  1621 "Frames/cs.ATG" 
out embeddedStatement);

#line  1621 "Frames/cs.ATG" 
			statement = new LockStatement(expr, embeddedStatement); 
		} else if (la.kind == 121) {

#line  1624 "Frames/cs.ATG" 
			Statement resourceAcquisitionStmt = null; 
			lexer.NextToken();
			Expect(20);
			ResourceAcquisition(
#line  1626 "Frames/cs.ATG" 
out resourceAcquisitionStmt);
			Expect(21);
			EmbeddedStatement(
#line  1627 "Frames/cs.ATG" 
out embeddedStatement);

#line  1627 "Frames/cs.ATG" 
			statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); 
		} else if (la.kind == 119) {
			lexer.NextToken();
			Block(
#line  1630 "Frames/cs.ATG" 
out embeddedStatement);

#line  1630 "Frames/cs.ATG" 
			statement = new UnsafeStatement(embeddedStatement); 
		} else if (la.kind == 74) {

#line  1632 "Frames/cs.ATG" 
			Statement pointerDeclarationStmt = null; 
			lexer.NextToken();
			Expect(20);
			ResourceAcquisition(
#line  1634 "Frames/cs.ATG" 
out pointerDeclarationStmt);
			Expect(21);
			EmbeddedStatement(
#line  1635 "Frames/cs.ATG" 
out embeddedStatement);

#line  1635 "Frames/cs.ATG" 
			statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); 
		} else SynErr(200);

#line  1637 "Frames/cs.ATG" 
		if (statement != null) {
		statement.StartLocation = startLocation;
		statement.EndLocation = t.EndLocation;
		}
		
	}
Exemplo n.º 6
0
	void RemoveAccessorDecl(
#line  1332 "Frames/cs.ATG" 
out Statement stmt) {

#line  1333 "Frames/cs.ATG" 
		stmt = null;
		Expect(131);
		Block(
#line  1336 "Frames/cs.ATG" 
out stmt);
	}
Exemplo n.º 7
0
	void Block(
#line  1309 "Frames/cs.ATG" 
out Statement stmt) {
		Expect(16);

#line  1311 "Frames/cs.ATG" 
		BlockStatement blockStmt = new BlockStatement();
		blockStmt.StartLocation = t.Location;
		compilationUnit.BlockStart(blockStmt);
		if (!ParseMethodBodies) lexer.SkipCurrentBlock(0);
		
		while (StartOf(25)) {
			Statement();
		}
		while (!(la.kind == 0 || la.kind == 17)) {SynErr(182); lexer.NextToken(); }
		Expect(17);

#line  1319 "Frames/cs.ATG" 
		stmt = blockStmt;
		blockStmt.EndLocation = t.Kind != Tokens.CloseCurlyBrace ? Location.Empty : t.EndLocation;
		compilationUnit.BlockEnd();
		
	}
Exemplo n.º 8
0
		public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement) {
			ResourceAcquisition = resourceAcquisition;
			EmbeddedStatement = embeddedStatement;
		}
Exemplo n.º 9
0
		public YieldStatement(Statement statement) {
			Statement = statement;
		}
Exemplo n.º 10
0
		public TryCatchStatement(Statement statementBlock, List<CatchClause> catchClauses, Statement finallyBlock) {
			StatementBlock = statementBlock;
			CatchClauses = catchClauses;
			FinallyBlock = finallyBlock;
		}
Exemplo n.º 11
0
		public UnsafeStatement(Statement block) {
			Block = block;
		}
Exemplo n.º 12
0
		public OnErrorStatement(Statement embeddedStatement) {
			EmbeddedStatement = embeddedStatement;
		}
Exemplo n.º 13
0
		public LockStatement(Expression lockExpression, Statement embeddedStatement) {
			LockExpression = lockExpression;
			EmbeddedStatement = embeddedStatement;
		}
Exemplo n.º 14
0
			public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement)
				: this(condition) {
				this.trueStatement.Add(Statement.CheckNull(trueStatement));
				this.falseStatement.Add(Statement.CheckNull(falseStatement));
				if (trueStatement != null) trueStatement.Parent = this;
				if (falseStatement != null) falseStatement.Parent = this;
			}
Exemplo n.º 15
0
	void TryStatement(
#line  3245 "VBNET.ATG" 
out Statement tryStatement) {

#line  3247 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
		
		Expect(203);
		EndOfStmt();
		Block(
#line  3250 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 62 || la.kind == 100 || la.kind == 110) {
			CatchClauses(
#line  3251 "VBNET.ATG" 
out catchClauses);
		}
		if (la.kind == 110) {
			lexer.NextToken();
			EndOfStmt();
			Block(
#line  3252 "VBNET.ATG" 
out finallyStmt);
		}
		Expect(100);
		Expect(203);

#line  3255 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
Exemplo n.º 16
0
		public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock) {
			TypeReference = typeReference;
			VariableName = variableName;
			StatementBlock = statementBlock;
			condition = Expression.Null;
		}
Exemplo n.º 17
0
	void WithStatement(
#line  3225 "VBNET.ATG" 
out Statement withStatement) {

#line  3227 "VBNET.ATG" 
		Statement blockStmt = null;
		Expression expr = null;
		
		Expect(218);

#line  3230 "VBNET.ATG" 
		Location start = t.Location; 
		Expr(
#line  3231 "VBNET.ATG" 
out expr);
		EndOfStmt();

#line  3233 "VBNET.ATG" 
		withStatement = new WithStatement(expr);
		withStatement.StartLocation = start;
		
		Block(
#line  3236 "VBNET.ATG" 
out blockStmt);

#line  3238 "VBNET.ATG" 
		((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
		
		Expect(100);
		Expect(218);

#line  3241 "VBNET.ATG" 
		withStatement.EndLocation = t.Location; 
	}
Exemplo n.º 18
0
		public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition) {
			TypeReference = typeReference;
			VariableName = variableName;
			StatementBlock = statementBlock;
			Condition = condition;
		}
Exemplo n.º 19
0
		public static Statement CheckNull(Statement statement)
		{
			return statement ?? NullStatement.Instance;
		}
Exemplo n.º 20
0
		public CatchClause(Statement statementBlock) {
			StatementBlock = statementBlock;
			typeReference = TypeReference.Null;
			variableName = "";
			condition = Expression.Null;
		}
Exemplo n.º 21
0
	void AddAccessorDecl(
#line  1325 "Frames/cs.ATG" 
out Statement stmt) {

#line  1326 "Frames/cs.ATG" 
		stmt = null;
		Expect(130);
		Block(
#line  1329 "Frames/cs.ATG" 
out stmt);
	}
Exemplo n.º 22
0
		public CheckedStatement(Statement block) {
			Block = block;
		}
Exemplo n.º 23
0
	void LocalVariableDecl(
#line  1478 "Frames/cs.ATG" 
out Statement stmt) {

#line  1480 "Frames/cs.ATG" 
		TypeReference type;
		VariableDeclaration      var = null;
		LocalVariableDeclaration localVariableDeclaration; 
		Location startPos = la.Location;
		
		Type(
#line  1486 "Frames/cs.ATG" 
out type);

#line  1486 "Frames/cs.ATG" 
		localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = startPos; 
		LocalVariableDeclarator(
#line  1487 "Frames/cs.ATG" 
out var);

#line  1487 "Frames/cs.ATG" 
		SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); 
		while (la.kind == 14) {
			lexer.NextToken();
			LocalVariableDeclarator(
#line  1488 "Frames/cs.ATG" 
out var);

#line  1488 "Frames/cs.ATG" 
			SafeAdd(localVariableDeclaration, localVariableDeclaration.Variables, var); 
		}

#line  1489 "Frames/cs.ATG" 
		stmt = localVariableDeclaration; stmt.EndLocation = t.EndLocation; 
	}
Exemplo n.º 24
0
	void Block(
#line  2680 "VBNET.ATG" 
out Statement stmt) {

#line  2683 "VBNET.ATG" 
		BlockStatement blockStmt = new BlockStatement();
		/* in snippet parsing mode, t might be null */
		if (t != null) blockStmt.StartLocation = t.EndLocation;
		compilationUnit.BlockStart(blockStmt);
		
		while (StartOf(22) || 
#line  2689 "VBNET.ATG" 
IsEndStmtAhead()) {
			if (
#line  2689 "VBNET.ATG" 
IsEndStmtAhead()) {
				Expect(100);
				EndOfStmt();

#line  2689 "VBNET.ATG" 
				compilationUnit.AddChild(new EndStatement()); 
			} else {
				Statement();
				EndOfStmt();
			}
		}

#line  2694 "VBNET.ATG" 
		stmt = blockStmt;
		if (t != null) blockStmt.EndLocation = t.EndLocation;
		compilationUnit.BlockEnd();
		
	}
Exemplo n.º 25
0
	void IfStatement(
#line  1644 "Frames/cs.ATG" 
out Statement statement) {

#line  1646 "Frames/cs.ATG" 
		Expression expr = null;
		Statement embeddedStatement = null;
		statement = null;
		Location elseStart = Location.Empty;
		
		Expect(79);
		Expect(20);
		Expr(
#line  1653 "Frames/cs.ATG" 
out expr);
		Expect(21);
		EmbeddedStatement(
#line  1654 "Frames/cs.ATG" 
out embeddedStatement);

#line  1655 "Frames/cs.ATG" 
		Statement elseStatement = null; 
		if (la.kind == 67) {
			lexer.NextToken();

#line  1656 "Frames/cs.ATG" 
			elseStart = t.Location; 
			EmbeddedStatement(
#line  1656 "Frames/cs.ATG" 
out elseStatement);
		}

#line  1657 "Frames/cs.ATG" 
		statement = elseStatement != null ? new IfElseStatement(expr, embeddedStatement, elseStatement) : new IfElseStatement(expr, embeddedStatement); 

#line  1658 "Frames/cs.ATG" 
		if (elseStatement is IfElseStatement && (elseStatement as IfElseStatement).TrueStatement.Count == 1) {
		/* else if-section (otherwise we would have a BlockStatment) */
		ElseIfSection elseIfSection = new ElseIfSection((elseStatement as IfElseStatement).Condition, (elseStatement as IfElseStatement).TrueStatement[0]);
		elseIfSection.StartLocation = elseStart;
		elseIfSection.EndLocation = (elseStatement as IfElseStatement).TrueStatement[0].EndLocation;
		(statement as IfElseStatement).ElseIfSections.Add(elseIfSection);
		(statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections);
		(statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement;
		}
		
	}
Exemplo n.º 26
0
	void EmbeddedStatement(
#line  2755 "VBNET.ATG" 
out Statement statement) {

#line  2757 "VBNET.ATG" 
		Statement embeddedStatement = null;
		statement = null;
		Expression expr = null;
		string name = String.Empty;
		List<Expression> p = null;
		
		if (la.kind == 107) {
			lexer.NextToken();

#line  2763 "VBNET.ATG" 
			ExitType exitType = ExitType.None; 
			switch (la.kind) {
			case 195: {
				lexer.NextToken();

#line  2765 "VBNET.ATG" 
				exitType = ExitType.Sub; 
				break;
			}
			case 114: {
				lexer.NextToken();

#line  2767 "VBNET.ATG" 
				exitType = ExitType.Function; 
				break;
			}
			case 171: {
				lexer.NextToken();

#line  2769 "VBNET.ATG" 
				exitType = ExitType.Property; 
				break;
			}
			case 95: {
				lexer.NextToken();

#line  2771 "VBNET.ATG" 
				exitType = ExitType.Do; 
				break;
			}
			case 111: {
				lexer.NextToken();

#line  2773 "VBNET.ATG" 
				exitType = ExitType.For; 
				break;
			}
			case 203: {
				lexer.NextToken();

#line  2775 "VBNET.ATG" 
				exitType = ExitType.Try; 
				break;
			}
			case 216: {
				lexer.NextToken();

#line  2777 "VBNET.ATG" 
				exitType = ExitType.While; 
				break;
			}
			case 182: {
				lexer.NextToken();

#line  2779 "VBNET.ATG" 
				exitType = ExitType.Select; 
				break;
			}
			default: SynErr(273); break;
			}

#line  2781 "VBNET.ATG" 
			statement = new ExitStatement(exitType); 
		} else if (la.kind == 203) {
			TryStatement(
#line  2782 "VBNET.ATG" 
out statement);
		} else if (la.kind == 76) {
			lexer.NextToken();

#line  2783 "VBNET.ATG" 
			ContinueType continueType = ContinueType.None; 
			if (la.kind == 95 || la.kind == 111 || la.kind == 216) {
				if (la.kind == 95) {
					lexer.NextToken();

#line  2783 "VBNET.ATG" 
					continueType = ContinueType.Do; 
				} else if (la.kind == 111) {
					lexer.NextToken();

#line  2783 "VBNET.ATG" 
					continueType = ContinueType.For; 
				} else {
					lexer.NextToken();

#line  2783 "VBNET.ATG" 
					continueType = ContinueType.While; 
				}
			}

#line  2783 "VBNET.ATG" 
			statement = new ContinueStatement(continueType); 
		} else if (la.kind == 200) {
			lexer.NextToken();
			if (StartOf(29)) {
				Expr(
#line  2785 "VBNET.ATG" 
out expr);
			}

#line  2785 "VBNET.ATG" 
			statement = new ThrowStatement(expr); 
		} else if (la.kind == 180) {
			lexer.NextToken();
			if (StartOf(29)) {
				Expr(
#line  2787 "VBNET.ATG" 
out expr);
			}

#line  2787 "VBNET.ATG" 
			statement = new ReturnStatement(expr); 
		} else if (la.kind == 196) {
			lexer.NextToken();
			Expr(
#line  2789 "VBNET.ATG" 
out expr);
			EndOfStmt();
			Block(
#line  2789 "VBNET.ATG" 
out embeddedStatement);
			Expect(100);
			Expect(196);

#line  2790 "VBNET.ATG" 
			statement = new LockStatement(expr, embeddedStatement); 
		} else if (la.kind == 174) {
			lexer.NextToken();
			Identifier();

#line  2792 "VBNET.ATG" 
			name = t.val; 
			if (la.kind == 25) {
				lexer.NextToken();
				if (StartOf(37)) {
					ArgumentList(
#line  2793 "VBNET.ATG" 
out p);
				}
				Expect(26);
			}

#line  2795 "VBNET.ATG" 
			statement = new RaiseEventStatement(name, p);
			
		} else if (la.kind == 218) {
			WithStatement(
#line  2798 "VBNET.ATG" 
out statement);
		} else if (la.kind == 43) {
			lexer.NextToken();

#line  2800 "VBNET.ATG" 
			Expression handlerExpr = null; 
			Expr(
#line  2801 "VBNET.ATG" 
out expr);
			Expect(12);
			Expr(
#line  2801 "VBNET.ATG" 
out handlerExpr);

#line  2803 "VBNET.ATG" 
			statement = new AddHandlerStatement(expr, handlerExpr);
			
		} else if (la.kind == 178) {
			lexer.NextToken();

#line  2806 "VBNET.ATG" 
			Expression handlerExpr = null; 
			Expr(
#line  2807 "VBNET.ATG" 
out expr);
			Expect(12);
			Expr(
#line  2807 "VBNET.ATG" 
out handlerExpr);

#line  2809 "VBNET.ATG" 
			statement = new RemoveHandlerStatement(expr, handlerExpr);
			
		} else if (la.kind == 216) {
			lexer.NextToken();
			Expr(
#line  2812 "VBNET.ATG" 
out expr);
			EndOfStmt();
			Block(
#line  2813 "VBNET.ATG" 
out embeddedStatement);
			Expect(100);
			Expect(216);

#line  2815 "VBNET.ATG" 
			statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
			
		} else if (la.kind == 95) {
			lexer.NextToken();

#line  2820 "VBNET.ATG" 
			ConditionType conditionType = ConditionType.None;
			
			if (la.kind == 209 || la.kind == 216) {
				WhileOrUntil(
#line  2823 "VBNET.ATG" 
out conditionType);
				Expr(
#line  2823 "VBNET.ATG" 
out expr);
				EndOfStmt();
				Block(
#line  2824 "VBNET.ATG" 
out embeddedStatement);
				Expect(138);

#line  2827 "VBNET.ATG" 
				statement = new DoLoopStatement(expr, 
				                               embeddedStatement, 
				                               conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, 
				                               ConditionPosition.Start);
				
			} else if (la.kind == 1 || la.kind == 11) {
				EndOfStmt();
				Block(
#line  2834 "VBNET.ATG" 
out embeddedStatement);
				Expect(138);
				if (la.kind == 209 || la.kind == 216) {
					WhileOrUntil(
#line  2835 "VBNET.ATG" 
out conditionType);
					Expr(
#line  2835 "VBNET.ATG" 
out expr);
				}

#line  2837 "VBNET.ATG" 
				statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
				
			} else SynErr(274);
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  2842 "VBNET.ATG" 
			Expression group = null;
			TypeReference typeReference;
			string        typeName;
			Location startLocation = t.Location;
			
			if (la.kind == 97) {
				lexer.NextToken();
				LoopControlVariable(
#line  2849 "VBNET.ATG" 
out typeReference, out typeName);
				Expect(125);
				Expr(
#line  2850 "VBNET.ATG" 
out group);
				EndOfStmt();
				Block(
#line  2851 "VBNET.ATG" 
out embeddedStatement);
				Expect(149);
				if (StartOf(29)) {
					Expr(
#line  2852 "VBNET.ATG" 
out expr);
				}

#line  2854 "VBNET.ATG" 
				statement = new ForeachStatement(typeReference, 
				                                typeName,
				                                group, 
				                                embeddedStatement, 
				                                expr);
				statement.StartLocation = startLocation;
				statement.EndLocation   = t.EndLocation;
				
				
			} else if (StartOf(38)) {

#line  2865 "VBNET.ATG" 
				Expression start = null;
				Expression end = null;
				Expression step = null;
				Expression variableExpr = null;
				Expression nextExpr = null;
				List<Expression> nextExpressions = null;
				
				if (
#line  2872 "VBNET.ATG" 
IsLoopVariableDeclaration()) {
					LoopControlVariable(
#line  2873 "VBNET.ATG" 
out typeReference, out typeName);
				} else {

#line  2875 "VBNET.ATG" 
					typeReference = null; typeName = null; 
					SimpleExpr(
#line  2876 "VBNET.ATG" 
out variableExpr);
				}
				Expect(10);
				Expr(
#line  2878 "VBNET.ATG" 
out start);
				Expect(201);
				Expr(
#line  2878 "VBNET.ATG" 
out end);
				if (la.kind == 190) {
					lexer.NextToken();
					Expr(
#line  2878 "VBNET.ATG" 
out step);
				}
				EndOfStmt();
				Block(
#line  2879 "VBNET.ATG" 
out embeddedStatement);
				Expect(149);
				if (StartOf(29)) {
					Expr(
#line  2882 "VBNET.ATG" 
out nextExpr);

#line  2884 "VBNET.ATG" 
					nextExpressions = new List<Expression>();
					nextExpressions.Add(nextExpr);
					
					while (la.kind == 12) {
						lexer.NextToken();
						Expr(
#line  2887 "VBNET.ATG" 
out nextExpr);

#line  2887 "VBNET.ATG" 
						nextExpressions.Add(nextExpr); 
					}
				}

#line  2890 "VBNET.ATG" 
				statement = new ForNextStatement {
				TypeReference = typeReference,
				VariableName = typeName, 
				LoopVariableExpression = variableExpr,
				Start = start, 
				End = end, 
				Step = step, 
				EmbeddedStatement = embeddedStatement, 
				NextExpressions = nextExpressions
				};
				
			} else SynErr(275);
		} else if (la.kind == 105) {
			lexer.NextToken();
			Expr(
#line  2903 "VBNET.ATG" 
out expr);

#line  2903 "VBNET.ATG" 
			statement = new ErrorStatement(expr); 
		} else if (la.kind == 176) {
			lexer.NextToken();

#line  2905 "VBNET.ATG" 
			bool isPreserve = false; 
			if (la.kind == 169) {
				lexer.NextToken();

#line  2905 "VBNET.ATG" 
				isPreserve = true; 
			}
			ReDimClause(
#line  2906 "VBNET.ATG" 
out expr);

#line  2908 "VBNET.ATG" 
			ReDimStatement reDimStatement = new ReDimStatement(isPreserve);
			statement = reDimStatement;
			SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression);
			
			while (la.kind == 12) {
				lexer.NextToken();
				ReDimClause(
#line  2912 "VBNET.ATG" 
out expr);

#line  2913 "VBNET.ATG" 
				SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); 
			}
		} else if (la.kind == 104) {
			lexer.NextToken();
			Expr(
#line  2917 "VBNET.ATG" 
out expr);

#line  2919 "VBNET.ATG" 
			EraseStatement eraseStatement = new EraseStatement();
			if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr);}
			
			while (la.kind == 12) {
				lexer.NextToken();
				Expr(
#line  2922 "VBNET.ATG" 
out expr);

#line  2922 "VBNET.ATG" 
				if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr); }
			}

#line  2923 "VBNET.ATG" 
			statement = eraseStatement; 
		} else if (la.kind == 191) {
			lexer.NextToken();

#line  2925 "VBNET.ATG" 
			statement = new StopStatement(); 
		} else if (
#line  2927 "VBNET.ATG" 
la.kind == Tokens.If) {
			Expect(122);

#line  2928 "VBNET.ATG" 
			Location ifStartLocation = t.Location; 
			Expr(
#line  2928 "VBNET.ATG" 
out expr);
			if (la.kind == 199) {
				lexer.NextToken();
			}
			if (la.kind == 1 || la.kind == 11) {
				EndOfStmt();
				Block(
#line  2931 "VBNET.ATG" 
out embeddedStatement);

#line  2933 "VBNET.ATG" 
				IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement);
				ifStatement.StartLocation = ifStartLocation;
				Location elseIfStart;
				
				while (la.kind == 99 || 
#line  2939 "VBNET.ATG" 
IsElseIf()) {
					if (
#line  2939 "VBNET.ATG" 
IsElseIf()) {
						Expect(98);

#line  2939 "VBNET.ATG" 
						elseIfStart = t.Location; 
						Expect(122);
					} else {
						lexer.NextToken();

#line  2940 "VBNET.ATG" 
						elseIfStart = t.Location; 
					}

#line  2942 "VBNET.ATG" 
					Expression condition = null; Statement block = null; 
					Expr(
#line  2943 "VBNET.ATG" 
out condition);
					if (la.kind == 199) {
						lexer.NextToken();
					}
					EndOfStmt();
					Block(
#line  2944 "VBNET.ATG" 
out block);

#line  2946 "VBNET.ATG" 
					ElseIfSection elseIfSection = new ElseIfSection(condition, block);
					elseIfSection.StartLocation = elseIfStart;
					elseIfSection.EndLocation = t.Location;
					elseIfSection.Parent = ifStatement;
					ifStatement.ElseIfSections.Add(elseIfSection);
					
				}
				if (la.kind == 98) {
					lexer.NextToken();
					EndOfStmt();
					Block(
#line  2955 "VBNET.ATG" 
out embeddedStatement);

#line  2957 "VBNET.ATG" 
					ifStatement.FalseStatement.Add(embeddedStatement);
					
				}
				Expect(100);
				Expect(122);

#line  2961 "VBNET.ATG" 
				ifStatement.EndLocation = t.Location;
				statement = ifStatement;
				
			} else if (StartOf(39)) {

#line  2966 "VBNET.ATG" 
				IfElseStatement ifStatement = new IfElseStatement(expr);
				ifStatement.StartLocation = ifStartLocation;
				
				SingleLineStatementList(
#line  2969 "VBNET.ATG" 
ifStatement.TrueStatement);
				if (la.kind == 98) {
					lexer.NextToken();
					if (StartOf(39)) {
						SingleLineStatementList(
#line  2972 "VBNET.ATG" 
ifStatement.FalseStatement);
					}
				}

#line  2974 "VBNET.ATG" 
				ifStatement.EndLocation = t.Location; statement = ifStatement; 
			} else SynErr(276);
		} else if (la.kind == 182) {
			lexer.NextToken();
			if (la.kind == 61) {
				lexer.NextToken();
			}
			Expr(
#line  2977 "VBNET.ATG" 
out expr);
			EndOfStmt();

#line  2978 "VBNET.ATG" 
			List<SwitchSection> selectSections = new List<SwitchSection>();
			Statement block = null;
			
			while (la.kind == 61) {

#line  2982 "VBNET.ATG" 
				List<CaseLabel> caseClauses = null; Location caseLocation = la.Location; 
				lexer.NextToken();
				CaseClauses(
#line  2983 "VBNET.ATG" 
out caseClauses);
				if (
#line  2983 "VBNET.ATG" 
IsNotStatementSeparator()) {
					lexer.NextToken();
				}
				EndOfStmt();

#line  2985 "VBNET.ATG" 
				SwitchSection selectSection = new SwitchSection(caseClauses);
				selectSection.StartLocation = caseLocation;
				
				Block(
#line  2988 "VBNET.ATG" 
out block);

#line  2990 "VBNET.ATG" 
				selectSection.Children = block.Children;
				selectSection.EndLocation = t.EndLocation;
				selectSections.Add(selectSection);
				
			}

#line  2996 "VBNET.ATG" 
			statement = new SwitchStatement(expr, selectSections);
			
			Expect(100);
			Expect(182);
		} else if (la.kind == 157) {

#line  2999 "VBNET.ATG" 
			OnErrorStatement onErrorStatement = null; 
			OnErrorStatement(
#line  3000 "VBNET.ATG" 
out onErrorStatement);

#line  3000 "VBNET.ATG" 
			statement = onErrorStatement; 
		} else if (la.kind == 119) {

#line  3001 "VBNET.ATG" 
			GotoStatement goToStatement = null; 
			GotoStatement(
#line  3002 "VBNET.ATG" 
out goToStatement);

#line  3002 "VBNET.ATG" 
			statement = goToStatement; 
		} else if (la.kind == 179) {

#line  3003 "VBNET.ATG" 
			ResumeStatement resumeStatement = null; 
			ResumeStatement(
#line  3004 "VBNET.ATG" 
out resumeStatement);

#line  3004 "VBNET.ATG" 
			statement = resumeStatement; 
		} else if (StartOf(38)) {

#line  3007 "VBNET.ATG" 
			Expression val = null;
			AssignmentOperatorType op;
			
			bool mustBeAssignment = la.kind == Tokens.Plus  || la.kind == Tokens.Minus ||
			                        la.kind == Tokens.Not   || la.kind == Tokens.Times;
			
			SimpleExpr(
#line  3013 "VBNET.ATG" 
out expr);
			if (StartOf(40)) {
				AssignmentOperator(
#line  3015 "VBNET.ATG" 
out op);
				Expr(
#line  3015 "VBNET.ATG" 
out val);

#line  3015 "VBNET.ATG" 
				expr = new AssignmentExpression(expr, op, val); 
			} else if (la.kind == 1 || la.kind == 11 || la.kind == 98) {

#line  3016 "VBNET.ATG" 
				if (mustBeAssignment) Error("error in assignment."); 
			} else SynErr(277);

#line  3019 "VBNET.ATG" 
			// a field reference expression that stands alone is a
			// invocation expression without parantheses and arguments
			if(expr is MemberReferenceExpression || expr is IdentifierExpression) {
				expr = new InvocationExpression(expr);
			}
			statement = new ExpressionStatement(expr);
			
		} else if (la.kind == 60) {
			lexer.NextToken();
			SimpleExpr(
#line  3026 "VBNET.ATG" 
out expr);

#line  3026 "VBNET.ATG" 
			statement = new ExpressionStatement(expr); 
		} else if (la.kind == 211) {
			lexer.NextToken();

#line  3028 "VBNET.ATG" 
			Statement block;  
			if (
#line  3029 "VBNET.ATG" 
Peek(1).kind == Tokens.As) {

#line  3030 "VBNET.ATG" 
				LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifiers.None); 
				VariableDeclarator(
#line  3031 "VBNET.ATG" 
resourceAquisition.Variables);
				while (la.kind == 12) {
					lexer.NextToken();
					VariableDeclarator(
#line  3033 "VBNET.ATG" 
resourceAquisition.Variables);
				}
				Block(
#line  3035 "VBNET.ATG" 
out block);

#line  3037 "VBNET.ATG" 
				statement = new UsingStatement(resourceAquisition, block);
				
			} else if (StartOf(29)) {
				Expr(
#line  3039 "VBNET.ATG" 
out expr);
				Block(
#line  3040 "VBNET.ATG" 
out block);

#line  3041 "VBNET.ATG" 
				statement = new UsingStatement(new ExpressionStatement(expr), block); 
			} else SynErr(278);
			Expect(100);
			Expect(211);
		} else if (StartOf(41)) {
			LocalDeclarationStatement(
#line  3044 "VBNET.ATG" 
out statement);
		} else SynErr(279);
	}
Exemplo n.º 27
0
	void StatementExpr(
#line  1795 "Frames/cs.ATG" 
out Statement stmt) {

#line  1796 "Frames/cs.ATG" 
		Expression expr; 
		Expr(
#line  1798 "Frames/cs.ATG" 
out expr);

#line  1801 "Frames/cs.ATG" 
		stmt = new ExpressionStatement(expr); if (expr is PrimitiveExpression) Error("Primitive expressions are not allowed as statements."); 
	}
Exemplo n.º 28
0
	void LocalDeclarationStatement(
#line  2724 "VBNET.ATG" 
out Statement statement) {

#line  2726 "VBNET.ATG" 
		ModifierList m = new ModifierList();
		LocalVariableDeclaration localVariableDeclaration;
		bool dimfound = false;
		
		while (la.kind == 75 || la.kind == 92 || la.kind == 189) {
			if (la.kind == 75) {
				lexer.NextToken();

#line  2732 "VBNET.ATG" 
				m.Add(Modifiers.Const, t.Location); 
			} else if (la.kind == 189) {
				lexer.NextToken();

#line  2733 "VBNET.ATG" 
				m.Add(Modifiers.Static, t.Location); 
			} else {
				lexer.NextToken();

#line  2734 "VBNET.ATG" 
				dimfound = true; 
			}
		}

#line  2737 "VBNET.ATG" 
		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(
#line  2748 "VBNET.ATG" 
localVariableDeclaration.Variables);
		while (la.kind == 12) {
			lexer.NextToken();
			VariableDeclarator(
#line  2749 "VBNET.ATG" 
localVariableDeclaration.Variables);
		}

#line  2751 "VBNET.ATG" 
		statement = localVariableDeclaration;
		
	}
Exemplo n.º 29
0
	void ResourceAcquisition(
#line  1779 "Frames/cs.ATG" 
out Statement stmt) {

#line  1781 "Frames/cs.ATG" 
		stmt = null;
		Expression expr;
		
		if (
#line  1786 "Frames/cs.ATG" 
IsLocalVarDecl()) {
			LocalVariableDecl(
#line  1786 "Frames/cs.ATG" 
out stmt);

#line  1786 "Frames/cs.ATG" 
			((LocalVariableDeclaration)stmt).SemicolonPosition = t.EndLocation; 
		} else if (StartOf(6)) {
			Expr(
#line  1787 "Frames/cs.ATG" 
out expr);

#line  1791 "Frames/cs.ATG" 
			stmt = new ExpressionStatement(expr); 
		} else SynErr(203);
	}
Exemplo n.º 30
0
		public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression) {
			TypeReference = typeReference;
			VariableName = variableName;
			Expression = expression;
			EmbeddedStatement = embeddedStatement;
			NextExpression = nextExpression;
		}