Ejemplo n.º 1
0
        public object VisitUnaryOp(Token op, INode node, object options) // добавление ветрки для унарной операции
        {
            LegacyData legacyData = (LegacyData)options;

            BranchOrientation legacyOrientation = legacyData.LegacyOrientation;
            string            legacyIndent      = legacyData.LegacyIndent;

            if (legacyOrientation == BranchOrientation.Left)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, L_TURN) + H_PIPE + " (" + op.ToString() + ")");
            }
            else
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, R_TURN) + H_PIPE + " (" + op.ToString() + ")");
            }

            if (legacyOrientation == BranchOrientation.Right)
            {
                node.Accept(this, new LegacyData
                {
                    LegacyIndent      = ReplaceLastChar(legacyIndent, SPACE) + TAB + R_TURN,
                    LegacyOrientation = BranchOrientation.Right
                });
            }
            else
            {
                node.Accept(this, new LegacyData
                {
                    LegacyIndent      = ReplaceLastChar(legacyIndent, V_PIPE) + TAB + R_TURN,
                    LegacyOrientation = BranchOrientation.Right
                });
            }

            return(this.sb.ToString());
        }
Ejemplo n.º 2
0
        public object VisitAssignStatement(Variable variable, Token op, Node expr, object options) // добавление ветки операции присваивания
        {
            LegacyData legacyData = (LegacyData)options;

            BranchOrientation legacyOrientation = legacyData.LegacyOrientation;
            string            legacyIndent      = legacyData.LegacyIndent;

            if (legacyOrientation == BranchOrientation.Left)
            {
                variable.Accept(this, new LegacyData
                {
                    LegacyIndent      = ReplaceLastChar(legacyIndent, SPACE) + TAB + L_TURN,
                    LegacyOrientation = BranchOrientation.Left
                });
            }
            else
            {
                variable.Accept(this, new LegacyData
                {
                    LegacyIndent      = ReplaceLastChar(legacyIndent, V_PIPE) + TAB + V_PIPE,
                    LegacyOrientation = BranchOrientation.Left
                });
            }

            if (legacyOrientation == BranchOrientation.Left)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, L_TURN) + H_PIPE + " (" + op.ToString() + ")");
            }
            else if (legacyOrientation == BranchOrientation.Mid)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, M_TURN) + H_PIPE + " (" + op.ToString() + ")");
            }
            else
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, R_TURN) + H_PIPE + " (" + op.ToString() + ")");
            }

            if (legacyOrientation == BranchOrientation.Right)
            {
                expr.Accept(this, new LegacyData
                {
                    LegacyIndent      = ReplaceLastChar(legacyIndent, SPACE) + TAB + R_TURN,
                    LegacyOrientation = BranchOrientation.Right
                });
            }
            else
            {
                expr.Accept(this, new LegacyData
                {
                    LegacyIndent      = ReplaceLastChar(legacyIndent, V_PIPE) + TAB + V_PIPE,
                    LegacyOrientation = BranchOrientation.Right
                });
            }

            return(this.sb.ToString());
        }
Ejemplo n.º 3
0
        public object VisitCompoundStatement(List <Node> statements, object options) // добавление дочерних веток - структур внутри begin та end
        {
            LegacyData legacyData = (LegacyData)options;

            BranchOrientation legacyOrientation = legacyData.LegacyOrientation;
            string            legacyIndent      = legacyData.LegacyIndent;

            if (legacyOrientation == BranchOrientation.Left)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, L_TURN) + H_PIPE + " (Child)");
            }
            else if (legacyOrientation == BranchOrientation.Mid)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, M_TURN) + H_PIPE + " (Child)");
            }
            else
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, R_TURN) + H_PIPE + " (Child)");
            }

            string childIndent = legacyIndent;

            if (legacyOrientation == BranchOrientation.Right)
            {
                childIndent = ReplaceLastChar(childIndent, SPACE) + TAB;
            }
            else
            {
                childIndent = ReplaceLastChar(childIndent, V_PIPE) + TAB;
            }

            for (int i = 0; i < statements.Count; i++)
            {
                Node statement = statements[i];

                if (i < statements.Count - 1)
                {
                    statement.Accept(this, new LegacyData
                    {
                        LegacyIndent      = childIndent,
                        LegacyOrientation = BranchOrientation.Mid
                    });
                }
                else
                {
                    statement.Accept(this, new LegacyData
                    {
                        LegacyIndent      = childIndent,
                        LegacyOrientation = BranchOrientation.Right
                    });
                }
            }

            return(this.sb.ToString());
        }
Ejemplo n.º 4
0
        public object VisitVariable(Token variable, object options) // добавление ветки для переменной
        {
            LegacyData legacyData = (LegacyData)options;

            BranchOrientation legacyOrientation = legacyData.LegacyOrientation;
            string            legacyIndent      = legacyData.LegacyIndent;

            if (legacyOrientation == BranchOrientation.Left)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, L_TURN) + H_PIPE + "  " + variable.ToString());
            }
            else
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, R_TURN) + H_PIPE + "  " + variable.ToString());
            }

            return(this.sb.ToString());
        }
Ejemplo n.º 5
0
        public object VisitNum(Token num, object options) // добавление ветки для числа
        {
            LegacyData legacyData = (LegacyData)options;

            BranchOrientation legacyOrientation = legacyData.LegacyOrientation;
            string            legacyIndent      = legacyData.LegacyIndent;

            if (legacyOrientation == BranchOrientation.Left)
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, L_TURN) + H_PIPE + "  " + num.ToString());
            }
            else
            {
                sb.AppendLine(ReplaceLastChar(legacyIndent, R_TURN) + H_PIPE + "  " + num.ToString());
            }

            return(this.sb.ToString());
        }