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;
 }
Exemple #2
0
        void ReDimStatement(out Statement statement)
        {
            Expression expr = null;
            Expect(191);
            bool isPreserve = false;
            if (la.kind == 184) {
            Expect(184);
            isPreserve = true;
            }
            ReDimClause(out expr);
            ReDimStatement reDimStatement = new ReDimStatement(isPreserve);
            statement = reDimStatement;
            SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression);

            while (la.kind == 22) {
            Get();
            ReDimClause(out expr);
            SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression);
            }
        }
Exemple #3
0
 public static Statement CheckNull(Statement statement)
 {
     return statement ?? NullStatement.Instance;
 }
Exemple #4
0
 public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition)
 {
     TypeReference = typeReference;
     VariableName = variableName;
     StatementBlock = statementBlock;
     Condition = condition;
 }
Exemple #5
0
 public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement)
 {
     ResourceAcquisition = resourceAcquisition;
     EmbeddedStatement = embeddedStatement;
 }
Exemple #6
0
 public OnErrorStatement(Statement embeddedStatement)
 {
     EmbeddedStatement = embeddedStatement;
 }
Exemple #7
0
 public LambdaExpression()
 {
     parameters = new List<ParameterDeclarationExpression>();
     statementBody = Statement.Null;
     expressionBody = Expression.Null;
     returnType = TypeReference.Null;
 }
Exemple #8
0
 public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression)
 {
     TypeReference = typeReference;
     VariableName = variableName;
     Expression = expression;
     EmbeddedStatement = embeddedStatement;
     NextExpression = nextExpression;
 }
Exemple #9
0
 void SyncLockStatement(out Statement statement)
 {
     Expression expr; Statement embeddedStatement;
     Expect(211);
     Expr(out expr);
     EndOfStmt();
     Block(out embeddedStatement);
     Expect(113);
     Expect(211);
     statement = new LockStatement(expr, embeddedStatement);
 }
Exemple #10
0
        void Block(out Statement stmt)
        {
            BlockStatement blockStmt = new BlockStatement();
            /* in snippet parsing mode, t might be null */
            if (t != null) blockStmt.StartLocation = t.EndLocation;
            BlockStart(blockStmt);

            while (IsEndStmtAhead() || StartOf(StatementEndOfStmt)) {
            if (la.kind == 113) {
                Get();
                Token first = t;
                    AddChild(new EndStatement() {
                        StartLocation = first.Location,
                        EndLocation = first.EndLocation }
                    );

                EndOfStmt();
            } else if (StartOf(1)) {
                Statement();
                EndOfStmt();
            } else SynErr(268);
            }
            stmt = blockStmt;
            if (t != null) blockStmt.EndLocation = t.EndLocation;
            BlockEnd();
        }
Exemple #11
0
 void StopStatement(out Statement statement)
 {
     Expect(206);
     statement = new StopStatement();
 }
Exemple #12
0
        void SelectStatement(out Statement statement)
        {
            Expression expr = null;
            Expect(197);
            if (la.kind == 74) {
            Get();
            }
            Expr(out expr);
            EndOfStmt();
            List<SwitchSection> selectSections = new List<SwitchSection>();
            Statement block = null;

            while (la.kind == 74) {
            List<CaseLabel> caseClauses = null; Location caseLocation = la.Location;
            Get();
            CaseClauses(out caseClauses);
            if (IsNotStatementSeparator()) {
                Expect(21);
            }
            EndOfStmt();
            SwitchSection selectSection = new SwitchSection(caseClauses);
                selectSection.StartLocation = caseLocation;

            Block(out block);
            selectSection.Children = block.Children;
                selectSection.EndLocation = t.EndLocation;
                selectSections.Add(selectSection);

            }
            statement = new SwitchStatement(expr, selectSections);

            Expect(113);
            Expect(197);
        }
Exemple #13
0
 void ReturnStatement(out Statement statement)
 {
     Expression expr = null;
     Expect(195);
     if (StartOf(24)) {
     Expr(out expr);
     }
     statement = new ReturnStatement(expr);
 }
Exemple #14
0
        void ResumeStatement(out Statement resumeStatement)
        {
            resumeStatement = null;
            string label = string.Empty;

            Expect(194);
            if (StartOf(45)) {
            if (la.kind == 163) {
                Get();
                resumeStatement = new ResumeStatement(true);
            } else {
                LabelName(out label);
            }
            }
            resumeStatement = new ResumeStatement(label);
        }
Exemple #15
0
 void RemoveHandlerStatement(out Statement statement)
 {
     Expression expr = null;
     Expect(193);
     Expression handlerExpr = null;
     Expr(out expr);
     Expect(22);
     Expr(out handlerExpr);
     statement = new RemoveHandlerStatement(expr, handlerExpr);
 }
Exemple #16
0
 public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition)
 {
     Condition = condition;
     EmbeddedStatement = embeddedStatement;
     ConditionType = conditionType;
     ConditionPosition = conditionPosition;
 }
Exemple #17
0
 public ElseIfSection(Expression condition, Statement embeddedStatement)
 {
     Condition = condition;
     EmbeddedStatement = embeddedStatement;
 }
Exemple #18
0
 void ThrowStatement(out Statement statement)
 {
     Expression expr = null;
     Expect(215);
     if (StartOf(24)) {
     Expr(out expr);
     }
     statement = new ThrowStatement(expr);
 }
Exemple #19
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;
 }
Exemple #20
0
        void TryStatement(out Statement tryStatement)
        {
            Statement blockStmt = null;
            Statement finallyStmt = null;
            CatchClause clause = null;
            List<CatchClause> catchClauses = new List<CatchClause>();

            Expect(218);
            EndOfStmt();
            Block(out blockStmt);
            while (la.kind == 75) {
            CatchClause(out clause);
            if (clause != null) catchClauses.Add(clause);
            }
            if (la.kind == 123) {
            Get();
            EndOfStmt();
            Block(out finallyStmt);
            }
            Expect(113);
            Expect(218);
            tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
        }
Exemple #21
0
 public LockStatement(Expression lockExpression, Statement embeddedStatement)
 {
     LockExpression = lockExpression;
     EmbeddedStatement = embeddedStatement;
 }
Exemple #22
0
 void UsingStatement(out Statement statement)
 {
     Expression expr = null; Statement block; statement = null;
     Expect(226);
     if (Peek(1).kind == Tokens.As) {
     LocalVariableDeclaration resourceAquisition =
     new LocalVariableDeclaration(Modifiers.None);
     VariableDeclarator(resourceAquisition.Variables);
     while (la.kind == 22) {
         Get();
         VariableDeclarator(resourceAquisition.Variables);
     }
     EndOfStmt();
     Block(out block);
     statement = new UsingStatement(resourceAquisition, block);
     } else if (StartOf(24)) {
     Expr(out expr);
     EndOfStmt();
     Block(out block);
     statement = new UsingStatement(new ExpressionStatement(expr), block);
     } else SynErr(313);
     Expect(113);
     Expect(226);
 }
Exemple #23
0
 public TryCatchStatement(Statement statementBlock, List<CatchClause> catchClauses, Statement finallyBlock)
 {
     StatementBlock = statementBlock;
     CatchClauses = catchClauses;
     FinallyBlock = finallyBlock;
 }
Exemple #24
0
 void WhileStatement(out Statement statement)
 {
     Expression expr = null; Statement embeddedStatement;
     Expect(231);
     Expr(out expr);
     EndOfStmt();
     Block(out embeddedStatement);
     Expect(113);
     Expect(231);
     statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
 }
Exemple #25
0
 public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock)
 {
     TypeReference = typeReference;
     VariableName = variableName;
     StatementBlock = statementBlock;
     condition = Expression.Null;
 }
Exemple #26
0
        void WithStatement(out Statement withStatement)
        {
            Statement blockStmt = null;
            Expression expr = null;

            Expect(233);
            Location start = t.Location;
            Expr(out expr);
            EndOfStmt();
            withStatement = new WithStatement(expr);
            withStatement.StartLocation = start;

            Block(out blockStmt);
            ((WithStatement)withStatement).Body = (BlockStatement)blockStmt;

            Expect(113);
            Expect(233);
            withStatement.EndLocation = t.Location;
        }
Exemple #27
0
 public CatchClause(Statement statementBlock)
 {
     StatementBlock = statementBlock;
     typeReference = TypeReference.Null;
     variableName = "";
     condition = Expression.Null;
 }
Exemple #28
0
 void ContinueStatement(out Statement statement)
 {
     Expect(89);
     ContinueType continueType = ContinueType.None;
     if (la.kind == 108 || la.kind == 124 || la.kind == 231) {
     if (la.kind == 108) {
         Get();
         continueType = ContinueType.Do;
     } else if (la.kind == 124) {
         Get();
         continueType = ContinueType.For;
     } else {
         Get();
         continueType = ContinueType.While;
     }
     }
     statement = new ContinueStatement(continueType);
 }
Exemple #29
0
        void DoLoopStatement(out Statement statement)
        {
            Expression expr = null; Statement embeddedStatement; statement = null;
            Expect(108);
            ConditionType conditionType = ConditionType.None;
            if (la.kind == 224 || la.kind == 231) {
            WhileOrUntil(out conditionType);
            Expr(out expr);
            EndOfStmt();
            Block(out embeddedStatement);
            Expect(152);
            statement = new DoLoopStatement(expr,
                                                embeddedStatement,
                                                conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType,
                                                ConditionPosition.Start);

            } else if (la.kind == 1 || la.kind == 21) {
            EndOfStmt();
            Block(out embeddedStatement);
            Expect(152);
            if (la.kind == 224 || la.kind == 231) {
                WhileOrUntil(out conditionType);
                Expr(out expr);
            }
            statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
            } else SynErr(308);
        }
Exemple #30
0
 void RaiseEventStatement(out Statement statement)
 {
     List<Expression> arguments = null;
     Expect(189);
     Identifier();
     string name = t.val;
     if (la.kind == 37) {
     Get();
     ArgumentList(out arguments);
     Expect(38);
     }
     statement = new RaiseEventStatement(name, arguments);
 }