Generate LaTeX code for factorials

@retval string
@param FunctionNode $node AST to be typeset
761757
private function visitFactorialNode(FunctionNode $node)
    {
        $functionName = $node->getName();
        $op = $node->getOperand();
        $operand = $op->accept($this);

        // Add parentheses most of the time.
        if ($this->isNumeric($op)) {
            if ($op->getValue() < 0) {
                $operand = "($operand)";
            }
        } elseif ($op instanceof VariableNode || $op instanceof ConstantNode) {
            // Do nothing
        } else {
            $operand = "($operand)";
        }

        return "$operand$functionName";
    }
46201
function build($node) {
		if (is_string($node))
			return parent::build($node);
		$out='';
		foreach ($node as $key=>$val)
			$out.=is_int($key)?$this->build($val):$this->{'_'.$key}($val);
		return $out;
	}
506493
protected function applyRule(MethodNode $node)
    {
        $comment = $node->getComment();
        if ($this->hasInvalidReturnType($comment)) {
            $message = sprintf(
                'The %s is using an invalid return type "%s" which violates the rule "%s"',
                $node->getFullQualifiedName(),
                $this->getInvalidReturnType($comment),
                static::RULE
            );

            $this->addViolation($node, [$message]);
        }
    }
219461
public function apply(AbstractNode $node)
    {
        /** @var \PDepend\Source\AST\ASTClass $node */
        if ($node->isAbstract()) {
            return;
        }

        if (empty($this->classRegex) || preg_match($this->classRegex, $node->getFullQualifiedName()) === 0) {
            return;
        }

        /** @var \PHPMD\Node\ClassNode $node */
        $this->applyImplementsInterfaceWithSameNameAndSuffix($node);
    }
1264080
protected function compileFor(Node $node)
    {

        $subject = $node->subject;
        $phtml = $this->createCode("for ({$subject}) {").$this->newLine();
        $phtml .= $this->compileChildren($node->children).$this->newLine();
        $phtml .= $this->indent().$this->createCode('}').$this->newLine();

        return $phtml;
    }
718808
private void formatNodeTo(Formatter f, int level, RadixTreeNode<T> node) {
        for (int i = 0; i < level; i++) {
            f.format(" ");
        }
        f.format("|");
        for (int i = 0; i < level; i++) {
        	f.format("-");
        }

        if (node.isReal() == true)
        	f.format("%s[%s]*%n", node.getKey(),  node.getValue());
        else
        	f.format("%s%n", node.getKey());

        for (RadixTreeNode<T> child : node.getChildern()) {
        	formatNodeTo(f, level + 1, child);
        }		
	}
781622
public function apply(AbstractNode $node)
    {
        if (preg_match('([A-Za-z0-9]+Constants$)', $node->getName()) === 0) {
            return;
        }

        foreach ($node->getMethods() as $method) {
            $this->addViolation(
                $node,
                [
                    sprintf(
                        'Interface %s defines a method %s() which violates rule "%s"',
                        $node->getFullQualifiedName(),
                        $method->getName(),
                        static::RULE
                    ),
                ]
            );
        }
    }
1169889
public function functionWriter(&$doclet)
    {

        parent::HTMLWriter($doclet);

        $this->_id = 'definition';

        $rootDoc =& $this->_doclet->rootDoc();

        $packages =& $rootDoc->packages();
        ksort($packages);

        foreach ($packages as $packageName => $package) {

            $this->_depth = $package->depth() + 1;

            ob_start();

            echo '<header>';
            echo '<h1>'.$this->_doclet->_docTitle.'</h1>';
            echo "<span>Global</span>\n\n";
            echo "<h2>Functions</h2>\n\n";
            echo '</header>';

            $functions =& $package->functions();

            if ($functions) {
                ksort($functions);
                echo '<table>', "\n";
                foreach ($functions as $function) {
                    $textTag =& $function->tags('@text');
                    echo "<tr>\n";
                    echo '<td class="type">', $function->modifiers(FALSE), ' ', $function->returnTypeAsString(), "</td>\n";
                    echo '<td class="description">';
                    echo '<p class="name"><a href="#', $function->name(), '()">', $function->name(), '</a>', $function->flatSignature(), '</p>';
                    if ($textTag) {
                        echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                    }
                    echo "</td>\n";
                    echo "</tr>\n";
                }
                echo "</table>\n\n";

                echo '<h2>Details</h2>', "\n";
                foreach ($functions as $function) {
                    $textTag =& $function->tags('@text');
                    $this->_sourceLocation($function);
                    echo '<h3 id="', $function->name(),'()">', $function->name(), "</h3>\n";
                    echo '<code class="signature">', $function->modifiers(), ' ', $function->returnTypeAsString(), ' <strong>';
                    echo $function->name(), '</strong>', $function->flatSignature();
                    echo "</code>\n";
                    echo '<div class="details">', "\n";
                    if ($textTag) {
                        echo $this->_processInlineTags($textTag), "\n";
                    }
                    $this->_processTags($function->tags());
                    echo "</div>\n\n";
                }
            }

            $this->_output = ob_get_contents();
            ob_end_clean();

            $this->_write($package->asPath().'/package-functions.html', 'Functions', TRUE);
        }

    }
513080
protected function calculateFunctionNode(FunctionNode $functionNode)
    {
        $nodes = $functionNode->getChildNodes();

        $arguments = [];
        $argumentChildNodes = [];

        foreach ($nodes as $node) {
            if (is_a($node, SymbolNode::class)) {
                /** @var SymbolNode $node */

                if (is_a($node->getSymbol(), AbstractSeparator::class)) {
                    $containerNode = new ContainerNode($argumentChildNodes);
                    $arguments[] = $this->calculateContainerNode($containerNode);
                    $argumentChildNodes = [];
                } else {
                    $argumentChildNodes[] = $node;
                }
            } else {
                $argumentChildNodes[] = $node;
            }
        }

        if (sizeof($argumentChildNodes) > 0) {
            $containerNode = new ContainerNode($argumentChildNodes);
            $arguments[] = $this->calculateContainerNode($containerNode);
        }

        /** @var AbstractFunction $symbol */
        $symbol = $functionNode->getSymbolNode()->getSymbol();

        $result = $symbol->execute($arguments);

        return $result;
    }
1203882
public function visitExpressionNode(ExpressionNode $node)
    {
        $leftValue = $node->getLeft()->accept($this);
        $operator = $node->getOperator();

        // The operator and the right side are optional, remember?
        if (!$operator)
            return "$leftValue";

        $right = $node->getRight();

        if ($right) {
            $rightValue = $node->getRight()->accept($this);
            return "($operator, $leftValue, $rightValue)";
        } else {
            return "($operator, $leftValue)";
        }

    }
137635
protected function generateText($node)
    {
        $buffer = '';
        
        $value = explode("\n", $node['value']);
        $last = count($value) - 1;
        
        foreach ($value as $i => $line) {
            $line = str_replace("'", '\\\'', $line);
            
            if ($i === $last) {
                $buffer .= $this->prettyPrint(sprintf(self::BLOCK_TEXT_LAST, $line));
                continue;
            }

            $buffer .= $this->prettyPrint(sprintf(self::BLOCK_TEXT_LINE, $line));
        }
        
        return $buffer;
    }
1002011
protected function calculateNode(AbstractNode $node)
    {
        if (is_a($node, SymbolNode::class)) {
            /** @var SymbolNode $node */

            return $this->calculateSymbolNode($node);
        } elseif (is_a($node, FunctionNode::class)) {
            /** @var FunctionNode $node */

            return $this->calculateFunctionNode($node);
        } elseif (is_a($node, ContainerNode::class)) {
            /** @var ContainerNode $node */

            return $this->calculateContainerNode($node);
        } else {
            throw new \InvalidArgumentException('Error: Cannot calculate node of unknown type "'.get_class($node).'"');
        }
    }
773477
public function pExpr_FuncCall(Expr\FuncCall $node)
    {
        return sprintf(
            '%s%s%s%s',
            $this->pCallLhs($node->name),
            $this->color('(', SyntaxHighlighterConfig::TYPE_CALL_PARENTHESIS),
            $this->pCommaSeparated($node->args),
            $this->color(')', SyntaxHighlighterConfig::TYPE_CALL_PARENTHESIS)
        );
    }
610010
public function shim_generateAction($node) {
        if ( ! ($parentNode = $node->getParent())) {
            $parentNode = new Varien_Object();
        }
        return $this->_shim_getLayout()->_generateAction($node, $parentNode);
    }
792380
public function apply(AbstractNode $node)
    {
        if (preg_match('([A-Za-z0-9]+Bridge$)', $node->getName()) === 0 ||
            preg_match('#.*\\\\Dependency\\\\.*#', $node->getNamespaceName()) === 0) {
            return;
        }

        preg_match('#(?<moduleName>[\w]+)\\\\Dependency\\\\(?<layerName>[\w]+)#is', $node->getNamespaceName(), $namespaceParts);

        $this->verifyClass($node, $namespaceParts);
        $this->verifyInterface($node, $namespaceParts);
    }
727466
public function isFunctionCall($node, string $function): Bool
    {
        if ($node instanceof Node && $node->kind === \ast\AST_CALL) {
            $expr = $node->children['expr'];

            if ($expr->kind === \ast\AST_NAME && $expr->children['name'] === $function) {
                return true;
            }
        }

        return false;
    }
4494
protected function pExpr_FuncCall(Expr\FuncCall $node)
    {
        $functionName = $this->pCallLhs($node->name);

        $this->securityManager->checkFunctionCall($functionName, $node->args);

        return $functionName
            . '(' . $this->pMaybeMultiline($node->args) . ')';
    }