Beispiel #1
0
        private void AnalyzeChunk(ChunkNode chunk, bool newList = true)
        {
            if (newList)
            {
                Symbols.PushList();
            }
            foreach (SyntaxNode analysisNode in chunk.Nodes)
            {
                switch (analysisNode.NodeType)
                {
                case NodeType.Assign:
                    AnalyzeAssign((AssignNode)analysisNode);
                    break;

                case NodeType.Continue:
                    AnalyzeContinue((ContinueNode)analysisNode);
                    break;

                case NodeType.Break:
                    AnalyzeBreak((BreakNode)analysisNode);
                    break;

                case NodeType.Return:
                    AnalyzeReturn((ReturnNode)analysisNode);
                    break;

                case NodeType.DefineVariable:
                    AnalyzeVarDef((DefineVariableNode)analysisNode);
                    break;

                case NodeType.Invoker:
                    InvokerNode invokerNode = (InvokerNode)analysisNode;
                    AnalyzeElement(invokerNode);
                    if (invokerNode.GetLastElement().NodeType != NodeType.Invoker)
                    {
                        return;     //TODO:报错 只有assignment、invoker 和 new 对象表达式可用作语句
                    }
                    break;

                case NodeType.New:
                    NewNode newNode = (NewNode)analysisNode;
                    AnalyzeElement(newNode);
                    switch (newNode.GetLastElement().NodeType)
                    {
                    case NodeType.New:
                    case NodeType.Invoker:
                        break;

                    default:
                        return;         //TODO:报错 只有assignment、invoker 和 new 对象表达式可用作语句
                    }
                    break;

                case NodeType.If:
                    AnalyzeIf((IfNode)analysisNode);
                    break;

                case NodeType.For:
                    AnalyzeForNode((ForNode)analysisNode);
                    break;

                case NodeType.While:
                    AnalyzeWhileNode((WhileNode)analysisNode);
                    break;
                }
            }
            if (newList)
            {
                Symbols.PopList();
            }
        }