/*public override int VisitExpr([NotNull] firstParser.ExprContext context) {
         *
         *  int serial = ms_serialCounter++;
         *  string s = "Expr_" + serial;
         *  // Preorder action
         *  outFile.WriteLine("\"{0}\"->\"{1}\";", m_labels.Peek(), s);
         *
         *  m_labels.Push(s);
         *
         *  base.VisitChildren(context);
         *
         *  m_labels.Pop();
         *  return 0;
         * }*/

        public override int VisitExpr_MULDIV(firstParser.Expr_MULDIVContext context)
        {
            int    serial = ms_serialCounter++;
            string s      = "";

            switch (context.op.Type)
            {
            case firstParser.MULT:
                s = "Mult_" + serial;
                // Preorder action
                outFile.WriteLine("\"{0}\"->\"{1}\";", m_labels.Peek(), s);
                break;

            case firstParser.DIV:
                s = "Div_" + serial;
                // Preorder action
                outFile.WriteLine("\"{0}\"->\"{1}\";", m_labels.Peek(), s);
                break;

            default:
                break;
            }

            m_labels.Push(s);

            base.VisitChildren(context);

            m_labels.Pop();
            return(0);
        }
Ejemplo n.º 2
0
        public override int VisitExpr_MULDIV(firstParser.Expr_MULDIVContext context)
        {
            ASTComposite m_parent = m_parents.Peek();

            if (context.op.Type == firstParser.MULT)
            {
                CASTMultiplication newnode = new CASTMultiplication(context.GetText(), nodeType.NT_MULTIPLICATION, m_parents.Peek(), 2);
                m_parent.AddChild(newnode, m_parentContext.Peek());
                m_parents.Push(newnode);

                this.VisitElementInContext(context.expr(0), m_parentContext, contextType.CT_MULTIPLICATION_LEFT);
                this.VisitElementInContext(context.expr(1), m_parentContext, contextType.CT_MULTIPLICATION_RIGHT);
            }
            else if (context.op.Type == firstParser.DIV)
            {
                CASTDivision newnode = new CASTDivision(context.GetText(), nodeType.NT_DIVISION, m_parents.Peek(), 2);
                m_parent.AddChild(newnode, m_parentContext.Peek());
                m_parents.Push(newnode);

                this.VisitElementInContext(context.expr(0), m_parentContext, contextType.CT_DIVISION_LEFT);
                this.VisitElementInContext(context.expr(1), m_parentContext, contextType.CT_DIVISION_RIGHT);
            }

            m_parents.Pop();
            return(0);
        }
Ejemplo n.º 3
0
        public override int VisitExpr_MULDIV(firstParser.Expr_MULDIVContext context)
        {
            if (context.op.Type == firstParser.MULT)
            {
                CASTMultiplication newNode = new CASTMultiplication(nodeType.NT_MULTIPLICATION, m_parents.Peek(), 2);
                m_parents.Push(newNode);
            }
            else if (context.op.Type == firstParser.DIV)
            {
                CASTDivision newNode = new CASTDivision(nodeType.NT_MULTIPLICATION, m_parents.Peek(), 2);
                m_parents.Push(newNode);
            }

            base.VisitExpr_MULDIV(context);
            m_parents.Pop();
            return(0);
        }