Exemple #1
0
        public ISyntaxTree GetSyntaxTree()
        {
            ExpressionParser expressionParser = new ExpressionParser(Line[4]);

            expressionParser.Normalize();
            Line[4].Element = expressionParser.Line[0].Element;

            //ISyntaxTree blockTrue = new AssignTree();
            //blockTrue.Context = Line[3].Element;
            //blockTrue.Childs.Add(expressionParser.GetSyntaxTree());
            ISyntaxTree blockTrue = Line[3].ElementReference.GetParser().GetSyntaxTree();

            //ISyntaxTree blockFalse = new AssignTree();
            //if (Line.Count > 5)
            //{
            //    expressionParser = new ExpressionParser(Line[6]);
            //    expressionParser.Normalize();
            //    Line[6] = expressionParser.Line[0];

            //    blockFalse.Context = Line[5];
            //    blockFalse.Childs.Add(expressionParser.GetSyntaxTree());
            //}
            //else blockFalse = null;

            ISyntaxTree blockFalse = new FunctionTree();

            //if (Line[5].ElementReference != null)
            if (Line[4].ElementReference != null)
            {
                //ISyntaxTree function = Line[5].ElementReference.GetParser().GetSyntaxTree();
                ISyntaxTree function = Line[4].ElementReference.GetParser().GetSyntaxTree();
                blockFalse.Childs.Add(function);
            }
            else
            {
                blockFalse = null;
            }

            expressionParser = new ExpressionParser(Line[0]);
            expressionParser.Normalize();
            Line[0] = expressionParser.Line[0];

            ISyntaxTree leftOp = expressionParser.GetSyntaxTree();

            expressionParser = new ExpressionParser(Line[2]);
            expressionParser.Normalize();
            Line[2] = expressionParser.Line[0];

            ISyntaxTree rightOp = expressionParser.GetSyntaxTree();

            ISyntaxTree condition = GetConditionTree(Line[1].Element);

            condition.Childs.Add(leftOp);
            condition.Childs.Add(rightOp);

            ISyntaxTree tree = new IFTree(blockTrue, blockFalse);

            tree.Childs.Add(condition);
            return(tree);
        }
Exemple #2
0
        public ISyntaxTree GetSyntaxTree()
        {
            ISyntaxTree      tree             = new AssignTree();
            ExpressionParser expressionParser = new ExpressionParser(Line[1].Element);

            expressionParser.Normalize();
            Line[1].Element = expressionParser.Line[0].Element;

            tree.Context = Line[0].Element;
            tree.Childs.Add(expressionParser.GetSyntaxTree());
            return(tree);
        }
Exemple #3
0
        public ISyntaxTree GetSyntaxTree()
        {
            WriteTree        tree             = new WriteTree();
            ExpressionParser expressionParser = new ExpressionParser(Line[0].Element);
            SyntaxError      syntaxError      = expressionParser.Check();

            if (syntaxError == SyntaxError.NoError)
            {
                expressionParser.Normalize();
                tree.Childs.Add(expressionParser.GetSyntaxTree());
            }
            else
            {
                Console.WriteLine(syntaxError);
                return(null);
            }
            return(tree);
        }