Transpiles all nodes in an abstract syntax tree

@param AbstractSyntaxTree $ast The abstract syntax tree to transpile
@return string The view with transpiled nodes
@throws RuntimeException Thrown if the nodes could not be transpiled
352580
protected function transpileNodes(AbstractSyntaxTree $ast) : string
    {
        $transpiledView = '';
        $rootNode = $ast->getRootNode();
        $previousNodeWasExpression = false;

        foreach ($rootNode->getChildren() as $childNode) {
            switch (get_class($childNode)) {
                case DirectiveNode::class:
                    $transpiledView .= $this->transpileDirectiveNode($childNode);
                    $previousNodeWasExpression = false;

                    break;
                case SanitizedTagNode::class:
                    $transpiledView .= $this->transpileSanitizedTagNode($childNode);
                    $previousNodeWasExpression = false;

                    break;
                case UnsanitizedTagNode::class:
                    $transpiledView .= $this->transpileUnsanitizedTagNode($childNode);
                    $previousNodeWasExpression = false;

                    break;
                case CommentNode::class:
                    $transpiledView .= $this->transpileCommentNode($childNode);
                    $previousNodeWasExpression = false;

                    break;
                case ExpressionNode::class:
                    // To keep expressions from running against each other, we pad all expressions but the first
                    if ($previousNodeWasExpression) {
                        $transpiledView .= ' ';
                    }

                    $transpiledView .= $this->transpileExpressionNode($childNode);
                    $previousNodeWasExpression = true;

                    break;
                default:
                    throw new RuntimeException(
                        sprintf(
                            'Unknown node class %s',
                            get_class($childNode)
                        )
                    );
            }
        }

        return $transpiledView;
    }
56091
public function generate(array $ast) : string
    {
        $code = parent::generate($ast);

        if (! $this->canEval) {
            $fileName = sys_get_temp_dir() . '/EvaluatingGeneratorStrategy.php.tmp.' . uniqid('', true);

            file_put_contents($fileName, "<?php\n" . $code);
            require $fileName;
            unlink($fileName);

            return $code;
        }

        eval($code);

        return $code;
    }
774306
public function apply($txt)
    {
        if (!is_string($txt))
            throw new \RuntimeException("Argument should be a string");

        foreach ($this->rules as $pattern => $replacement)
        {
            if (is_callable($replacement))
                $txt = preg_replace_callback($pattern, $replacement, $txt);
            else
                $txt = preg_replace($pattern, $replacement, $txt);
        }

        return $txt;
    }
664479
public function buildTree()
	{
		if( !$this->path )																			//  no Path to read is set
			throw new RuntimeException( 'No path set' );											//  exit
		$tree	= $this->buildRecursive( $this->path );												//  build HTML Tree recursively
		if( $this->id )																				//  an ID for Tree is set
			$tree	= UI_HTML_Tag::create( 'div', $tree, array( 'id' => $this->id ) );				//  wrap Tree in DIV with ID
		return $tree;																				//  return finished HTML Tree
	}
469525
protected function __toSend($asDomElement = false)
    {
        $this->setValue([
            $this->getCreated(),
            $this->getExpires(),
        ]);

        return parent::__toSend($asDomElement);
    }
993441
public static List<INode> getNodes(List<? extends INode> ast)
	{
		List<INode> nodes = new LinkedList<>();

		nodes.addAll(ast);

		return nodes;
	}
329245
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
    {
        // This can't be in the method type as
        // the method is an abstract and should
        // have the same interface
        if (!$inline instanceof Link) {
            throw new \RuntimeException(
                'Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ .
                " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
                get_class($inline) . "' was provided"
            );
        }

        // Default handling
        $element = parent::render($inline, $htmlRenderer);

        $url = $inline->getUrl();

        // empty urls, anchors and absolute urls
        // should not go through the url resolver
        if (!$this->isValidUrl($url) || $this->isExternalUrl($url)) {
            return $element;
        }

        //Internal links
        $file = $this->resolveInternalFile($url);

        $link_props = [
            'ri:content-title' => trim(trim($this->daux['confluence']['prefix']) . ' ' . $file->getTitle()),
            'ri:space-key' => $this->daux['confluence']['space_id'],
        ];

        $page = strval(new HtmlElement('ri:page', $link_props, '', true));
        $children = $htmlRenderer->renderInlines($inline->children());
        if (strpos($children, '<') !== false) {
            $children = '<ac:link-body>' . $children . '</ac:link-body>';
        } else {
            $children = '<ac:plain-text-link-body><![CDATA[' . $children . ']]></ac:plain-text-link-body>';
        }

        return new HtmlElement('ac:link', [], $page . $children);
    }
1193722
public function conditionalExpression()
    {
        $conditionalTerms = array();
        $conditionalTerms[] = $this->conditionalTerm();

        while ($this->lexer->isNextToken(Lexer::T_OR)) {
            $this->match(Lexer::T_OR);

            $conditionalTerms[] = $this->conditionalTerm();
        }

        // Phase 1 AST optimization: Prevent AST\ConditionalExpression
        // if only one AST\ConditionalTerm is defined
        if (count($conditionalTerms) == 1) {
            return $conditionalTerms[0];
        }

        return new ConditionalExpressionNode($conditionalTerms);
    }
163747
public function getAST()
    {
        // Parse & build AST
        $AST = $this->QueryLanguage();

        // Process any deferred validations of some nodes in the AST.
        // This also allows post-processing of the AST for modification purposes.
        $this->processDeferredIdentificationVariables();

        if ($this->deferredPartialObjectExpressions) {
            $this->processDeferredPartialObjectExpressions();
        }

        if ($this->deferredPathExpressions) {
            $this->processDeferredPathExpressions($AST);
        }

        if ($this->deferredResultVariables) {
            $this->processDeferredResultVariables();
        }

        if ($this->deferredNewObjectExpressions) {
            $this->processDeferredNewObjectExpressions($AST);
        }

        $this->processRootEntityAliasSelected();

        // TODO: Is there a way to remove this? It may impact the mixed hydration resultset a lot!
        $this->fixIdentificationVariableOrder($AST);

        return $AST;
    }
1150976
public function dispatch(Expression $expr, ?AbstractNode $parentNode = null)
    {
        if ($parentNode === null) {
            $parentNode = $this->queryBuilder->where();
        }

        switch (true) {
            case $expr instanceof Comparison:
                return $this->walkComparison($expr, $parentNode);
            case $expr instanceof CompositeExpression:
                return $this->walkCompositeExpression($expr, $parentNode);
        }

        throw new \RuntimeException('Unknown Expression: ' . get_class($expr));
    }
1300632
public function generate(SyntaxTree $syntaxTree, $options = null)
    {
        return $this->visitor->visit($syntaxTree->rootNode, null, $options);
    }
134373
private function findLastNode(callable $filterCallback, array $ast)
    {
        $traverser = new NodeTraverser();
        $visitor = new NodeVisitor\FindingVisitor($filterCallback);
        $traverser->addVisitor($visitor);
        $traverser->traverse($ast);

        $nodes = $visitor->getFoundNodes();
        $node = end($nodes);

        return false === $node ? null : $node;
    }
301845
protected function buildNode(array $ast, string $propertyName): ?NodeInterface
    {
        return isset($ast[$propertyName]) ? $this->build($ast[$propertyName]) : null;
    }
522253
function(ast, source) {
      if(!ast) return;
      for(var i=0;i<ast.length;i++) {
        var node=ast[i];
        if(node && node.length>=3 && node[0]=='=') {
          // looking for ['=', id, val]
          runtime.ast()[node[1]] = {'ast': [node]};
          runtime.source()[node[1]] = source;
        }
      }
    }
805514
public function walkSelectStatement(SelectStatement $AST)
    {
        $queryComponents = $this->_getQueryComponents();
        // Get the root entity and alias from the AST fromClause
        $from      = $AST->fromClause->identificationVariableDeclarations;
        $fromRoot  = reset($from);
        $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable;
        $rootClass = $queryComponents[$rootAlias]['metadata'];
        $selectExpressions = array();

        $this->validate($AST);

        foreach ($queryComponents as $dqlAlias => $qComp) {
            // Preserve mixed data in query for ordering.
            if (isset($qComp['resultVariable'])) {
                $selectExpressions[] = new SelectExpression($qComp['resultVariable'], $dqlAlias);
                continue;
            }
        }
        
        $identifier = $rootClass->getSingleIdentifierFieldName();
        
        if (isset($rootClass->associationMappings[$identifier])) {
            throw new \RuntimeException("Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.");
        }

        $this->_getQuery()->setHint(
            self::IDENTIFIER_TYPE,
            Type::getType($rootClass->getTypeOfField($identifier))
        );

        $pathExpression = new PathExpression(
            PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION,
            $rootAlias,
            $identifier
        );
        $pathExpression->type = PathExpression::TYPE_STATE_FIELD;

        array_unshift($selectExpressions, new SelectExpression($pathExpression, '_dctrn_id'));
        $AST->selectClause->selectExpressions = $selectExpressions;

        if (isset($AST->orderByClause)) {
            foreach ($AST->orderByClause->orderByItems as $item) {
                if ( ! $item->expression instanceof PathExpression) {
                    continue;
                }
                
                $AST->selectClause->selectExpressions[] = new SelectExpression(
                    $this->createSelectExpressionItem($item->expression),
                    '_dctrn_ord' . $this->_aliasCounter++
                );
            }
        }

        $AST->selectClause->isDistinct = true;
    }
8005
public function walkSelectStatement(SelectStatement $AST)
    {
        if ($this->platformSupportsRowNumber()) {
            return $this->walkSelectStatementWithRowNumber($AST);
        }

        return $this->walkSelectStatementWithoutRowNumber($AST);
    }
206911
public function getSimpleTreeRecursive($fields=array(),$transfields=array(),$lang='',$wh=array()){
		$list=$this->getSimpleTree($fields,$transfields,$lang,$wh);
		if(!is_array($list)){
			return array();
			}
		$tree=array();
		foreach($list as $li){
			$id=(int)$li->{$this->primaryKeyName};
		        $ti=$li;
			//TODO: finish children
			$ti->children=array();
			$tree[]=$ti;
			}
		return $tree;
		}