Exemple #1
0
		public TryStatement(BlockStatement Block, CatchClause Catch, FinallyClause Finally, TextSpan Location)
			: base(Operation.Try, Location)
		{
			this.Block = Block;
			this.Catch = Catch;
			this.Finally = Finally;
		}
Exemple #2
0
 public TryStatement(BlockStatement Block, CatchClause Catch, FinallyClause Finally, TextSpan Location)
     : base(Operation.Try, Location)
 {
     this.Block   = Block;
     this.Catch   = Catch;
     this.Finally = Finally;
 }
Exemple #3
0
		private TryStatement ParseTry ()
		{
			Token start = current;
			Next ();
			BlockStatement block = ParseBlock ();
			Next();
			bool flag = true;
			CatchClause catchClause = null;
			FinallyClause finallyClause = null;

			if (current.Kind == Token.Type.@catch) {
				Token start2 = current;
				flag = false;
				Next ();
				CheckSyntaxExpected (Token.Type.LeftParenthesis);
				Token left = current;
				Next ();
				Token id = current;
				Identifier name = null;
				if (CheckSyntaxExpected (Token.Type.Identifier))
					name = (current as IdentifierToken).Spelling;

				Next();
				CheckSyntaxExpected (Token.Type.RightParenthesis);
				Token right = current;
				Next();
				BlockStatement handler = ParseBlock();
				catchClause = new CatchClause(name, handler,new TextSpan(start2,current), new TextSpan(id, id), new TextPoint(left.StartPosition),new TextPoint(right.StartPosition));
			}

			if (current.Kind == Token.Type.@finally) {
				Token start3 = current;
				flag = false;
				Next ();
				BlockStatement handler2 = ParseBlock();
				finallyClause = new FinallyClause(handler2,new TextSpan(start3,current));
			}

			if (flag) {
				diagnostics.Add(new Diagnostic(DiagnosticCode.TryHasNoHandlers,new TextSpan(start,current)));
			}
			return new TryStatement (block, catchClause, finallyClause, new TextSpan (start, current));
		}