public virtual void Visit(GroupingOperator node) { if (node != null && node.Operand != null) { node.Operand.Accept(this); } }
public void Visit(GroupingOperator node) { if (node != null) { DoesRequire = true; } }
public virtual void Visit(GroupingOperator node) { if (node != null && node.Operand != null) { // just totally ignore any parentheses node.Operand.Accept(this); } }
public void Visit(GroupingOperator node) { // not TECHNICALLY valid! set the invalid flag, but // still recurse the operand, just in case IsValid = false; if (node != null && node.Operand != null) { node.Operand.Accept(this); } }
public override void Visit(GroupingOperator node) { if (node != null) { if (m_measure) { // either we add one by putting a ! in front of the parens, or // the expression itself can come out equal to less. // save the current delta, check the operand, and if applying the // logical not to the operand is MORE than just throwing a ! on the // front, then we'll just return the +1 for the simple not. var plusOne = m_delta + 1; node.Operand.Accept(this); if (m_delta > plusOne) { m_delta = plusOne; } } else { // we need to know how we're going to do this, so we need // to run another measurement. m_measure = true; m_delta = 0; node.Operand.Accept(this); m_measure = false; // if the delta is greater than 1, then we are just going // to wrap ourselves in a unary not. Otherwise we're going // to replace ourselves with our operand and not it in-place. if (m_delta > 1) { WrapWithLogicalNot(node); } else { node.Parent.ReplaceChild(node, node.Operand); node.Operand.Accept(this); } } } }
public override void Visit(GroupingOperator node) { if (node != null) { // if the parent isn't null, we need to run some checks // to see if we can be removed for being superfluous. if (node.Parent != null) { var deleteParens = false; if (node.Operand == null) { // delete self - no operand make the parens superfluous // TODO: or should we leave them to preserve the "error"? deleteParens = true; } else if (node.Parent is BlockStatement) { // function expressions and object literals need to keep the parens // or they'll be mistaken for function delcarations and blocks, respectively. // all others get axed. if (!(node.Operand is FunctionObject) && !(node.Operand is ObjectLiteral)) { // delete self deleteParens = true; } } else if (node.Parent is AstNodeList) { // keep the parens if the node is itself a comma-operator // question: do we need to check for ANY comma-operators in the entire expression, // or will precedence rules dictate that there will be parens lower down if this // expression isn't a comma-operator? var binOp = node.Operand as BinaryExpression; if (binOp == null || binOp.OperatorToken != JSToken.Comma) { // delete self deleteParens = true; } } else if (node.Parent.IsExpression) { var targetPrecedence = node.Parent.Precedence; var conditional = node.Parent as Conditional; if (conditional != null) { // the conditional is weird in that the different parts need to be // compared against different precedences, not the precedence of the // conditional itself. The condition should be compared to logical-or, // and the true/false expressions against assignment. targetPrecedence = conditional.Condition == node ? OperatorPrecedence.LogicalOr : OperatorPrecedence.Assignment; } if (targetPrecedence <= node.Operand.Precedence) { // if the target precedence is less than or equal to the // precedence of the operand, then the parens are superfluous. deleteParens = true; } } else { // delete self deleteParens = true; } if (deleteParens) { // delete the parens by replacing the grouping opertor node // with its own operand node.Parent.ReplaceChild(node, node.Operand); } } // always recurse the operand if (node.Operand != null) { node.Operand.Accept(this); } } }
public virtual void Visit(GroupingOperator node) { // definitely does NOT need parens, because we will // output parens ourselves. And don't bother recursing. }
public void Visit(GroupingOperator node) { // starts with a '(', so we don't care }
public void Visit(GroupingOperator node) { ReportError(node); }
public override bool Walk(GroupingOperator node) { AddNode(node); return(true); }
public virtual void PostWalk(GroupingOperator node) { }
public virtual bool Walk(GroupingOperator node) { return true; }
public virtual bool Walk(GroupingOperator node) { return(true); }