Пример #1
0
        public ASTOpNode BuildOperatorNode(Operator op, INode[] arguments)
        {
            ASTOpNode node = new ASTOpNode(JJTFUNNODE)
            {
                Op = op
            };

            this.CopyChildren(node, arguments);
            return(node);
        }
Пример #2
0
 public virtual object Visit(ASTOpNode node, object data)
 {
     if (node is IPrintRules)
     {
         ((IPrintRules)node).Append(node, this);
         return(null);
     }
     if (node.GetOperator() == null)
     {
         throw new JepException("Null operator in Print for " + node);
     }
     if (this.specialRules.ContainsKey(node.GetOperator()))
     {
         ((IPrintRules)this.specialRules[node.GetOperator()]).Append(node, this);
         return(null);
     }
     if (node.GetOperator().IsUnary())
     {
         return(this.VisitUnary(node, data));
     }
     if (node.GetOperator().IsBinary())
     {
         Operator op = node.GetOperator();
         if (node.JjtGetNumChildren() != 2)
         {
             return(this.VisitNaryBinary(node, op));
         }
         INode lhs = node.JjtGetChild(0);
         INode rhs = node.JjtGetChild(1);
         if (this.TestLeft(op, lhs))
         {
             this.PrintBrackets(lhs);
         }
         else
         {
             this.PrintNoBrackets(lhs);
         }
         this.sb.Append(node.GetOperator().GetSymbol());
         if (this.TestRight(op, rhs))
         {
             this.PrintBrackets(rhs);
         }
         else
         {
             this.PrintNoBrackets(rhs);
         }
     }
     return(null);
 }
Пример #3
0
        private object VisitUnary(ASTOpNode node, object data)
        {
            INode node2 = node.JjtGetChild(0);

            if (node.GetOperator().IsPrefix())
            {
                this.sb.Append(node.GetOperator().GetSymbol());
            }
            if (node2 is ASTOpNode)
            {
                this.PrintBrackets(node2);
            }
            else
            {
                this.PrintNoBrackets(node2);
            }
            if (node.GetOperator().IsSuffix())
            {
                this.sb.Append(node.GetOperator().GetSymbol());
            }
            return(data);
        }
Пример #4
0
 public object Visit(ASTOpNode node, object data)
 {
     this.VisitFun(node);
     return(null);
 }