public ASTOpNode BuildOperatorNode(Operator op, INode[] arguments) { ASTOpNode node = new ASTOpNode(JJTFUNNODE) { Op = op }; this.CopyChildren(node, arguments); return(node); }
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); }
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); }
public object Visit(ASTOpNode node, object data) { this.VisitFun(node); return(null); }