Ejemplo n.º 1
0
        private Statement BuildStatementCore(StatementNode statementNode)
        {
            Statement statement = null;

            switch (statementNode.NodeType) {
                case ParseNodeType.Block:
                    statement = ProcessBlockStatement((BlockStatementNode)statementNode);
                    break;
                case ParseNodeType.EmptyStatement:
                    statement = new EmptyStatement();
                    break;
                case ParseNodeType.VariableDeclaration:
                case ParseNodeType.ConstDeclaration:
                    statement = ProcessVariableDeclarationStatement((VariableDeclarationNode)statementNode);
                    break;
                case ParseNodeType.Return:
                    statement = ProcessReturnStatement((ReturnNode)statementNode);
                    break;
                case ParseNodeType.ExpressionStatement:
                    statement = ProcessExpressionStatement((ExpressionStatementNode)statementNode);
                    break;
                case ParseNodeType.IfElse:
                    statement = ProcessIfElseStatement((IfElseNode)statementNode);
                    break;
                case ParseNodeType.While:
                    statement = ProcessWhileStatement((WhileNode)statementNode);
                    break;
                case ParseNodeType.DoWhile:
                    statement = ProcessDoWhileStatement((DoWhileNode)statementNode);
                    break;
                case ParseNodeType.For:
                    statement = ProcessForStatement((ForNode)statementNode);
                    break;
                case ParseNodeType.Foreach:
                    statement = ProcessForeachStatement((ForeachNode)statementNode);
                    break;
                case ParseNodeType.Switch:
                    statement = ProcessSwitchStatement((SwitchNode)statementNode);
                    break;
                case ParseNodeType.Break:
                    statement = new BreakStatement();
                    break;
                case ParseNodeType.Continue:
                    statement = new ContinueStatement();
                    break;
                case ParseNodeType.Throw:
                    statement = ProcessThrowStatement((ThrowNode)statementNode);
                    break;
                case ParseNodeType.Try:
                    statement = ProcessTryCatchFinallyStatement((TryNode)statementNode);
                    break;
            }
            return statement;
        }
Ejemplo n.º 2
0
        public Statement BuildStatement(StatementNode statementNode) {
            Statement statement = null;

            try {
                statement = BuildStatementCore(statementNode);
            }
            catch {
                string location = statementNode.Token.Location;
                string message = "Check that your C# source compiles and that you are not using an unsupported feature. " +
                                 "Common things to check for include use of fully-qualified names " +
                                 "(use a using statement to import namespaces instead) or " +
                                 "accessing private members of a type from a static member of the same type.";

                statement = new ErrorStatement(message, location);
                _errorHandler.ReportError(message, location);
            }

            return statement;
        }