Returns the node string value, line by line.
If the compiler is present, that means we need
to interpolate line contents
@param Filter $node
@param Compiler $compiler
@return mixed
341259
protected function getNodeString(Filter $node, Compiler $compiler = null)
    {
        return array_reduce($node->block->nodes, function(&$result, $line) use($compiler) {
            $val = $compiler ? $compiler->interpolate($line->value) : $line->value;
            return $result .= $val."\n";
        });
    }
540326
private function loadNode(\Twig_Node $node)
    {
        $formulae = array();

        if ($node instanceof AsseticNode) {
            $formulae[$node->getAttribute('name')] = array(
                $node->getAttribute('inputs'),
                $node->getAttribute('filters'),
                array(
                    'output'  => $node->getAttribute('asset')->getTargetPath(),
                    'name'    => $node->getAttribute('name'),
                    'debug'   => $node->getAttribute('debug'),
                    'combine' => $node->getAttribute('combine'),
                    'vars'    => $node->getAttribute('vars'),
                ),
            );
        } elseif ($node instanceof AsseticFilterNode) {
            $name = $node->getAttribute('name');

            $arguments = array();
            foreach ($node->getNode('arguments') as $argument) {
                $arguments[] = eval('return '.$this->twig->compile($argument).';');
            }

            $invoker = $this->twig->getExtension('Assetic\Extension\Twig\AsseticExtension')->getFilterInvoker($name);

            $inputs  = isset($arguments[0]) ? (array) $arguments[0] : array();
            $filters = $invoker->getFilters();
            $options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array());

            if (!isset($options['name'])) {
                $options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options);
            }

            $formulae[$options['name']] = array($inputs, $filters, $options);
        }

        foreach ($node as $child) {
            if ($child instanceof \Twig_Node) {
                $formulae += $this->loadNode($child);
            }
        }

        if ($node->hasAttribute('embedded_templates')) {
            foreach ($node->getAttribute('embedded_templates') as $child) {
                $formulae += $this->loadNode($child);
            }
        }

        return $formulae;
    }
69204
public static function compile(Compiler $compiler, $file)
    {
        preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
        $resource   = $m[1];
        $identifier = $m[2];

        $tpl = $compiler->getCore()->templateFactory($resource, $identifier);

        if ($tpl === null) {
            throw new CompilationException($compiler,
                'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
        } elseif ($tpl === false) {
            throw new CompilationException($compiler,
                'Load Templates : Resource "' . $resource . '" does not support includes.');
        }

        $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";

        $modCheck = $tpl->getIsModifiedCode();

        if ($modCheck) {
            $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
        } else {
            $out .= 'try {
	$tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
} catch (Dwoo\Exception $e) {
	$this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING);
}
if ($tpl === null)
	$this->triggerError(\'Load Templates : Resource "' . $resource . ':' . $identifier . '" was not found.\', E_USER_WARNING);
elseif ($tpl === false)
	$this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
        }

        return $out;
    }
534800
public function compile(Compiler $compiler)
    {
        $compiler
            ->addDebugInfo($this)
            ->write('switch (')
            ->subcompile($this->getNode('value'))
            ->raw(") {\n")
            ->indent();

        foreach ($this->getNode('cases') as $case) {
            if (!$case->hasNode('body')) {
                continue;
            }

            foreach ($case->getNode('values') as $value) {
                $compiler
                    ->write('case ')
                    ->subcompile($value)
                    ->raw(":\n");
            }

            $compiler
                ->write("{\n")
                ->indent()
                ->subcompile($case->getNode('body'))
                ->write("break;\n")
                ->outdent()
                ->write("}\n");
        }

        if ($this->hasNode('default') && $this->getNode('default') !== null) {
            $compiler
                ->write("default:\n")
                ->write("{\n")
                ->indent()
                ->subcompile($this->getNode('default'))
                ->outdent()
                ->write("}\n");
        }

        $compiler
            ->outdent()
            ->write("}\n");
    }
185810
public function compileNode(NodeInterface $node, ElementInterface $parent = null)
    {
        $nodeEvent = new NodeEvent($node);
        $this->trigger($nodeEvent);
        $node = $nodeEvent->getNode();

        $this->currentNode = $node;

        foreach ($this->nodeCompilers as $className => $compiler) {
            if (is_a($node, $className)) {
                if (!($compiler instanceof NodeCompilerInterface)) {
                    $compiler = $this->getNamedCompiler($compiler);
                }

                $element = $compiler->compileNode($node, $parent);

                if ($element instanceof ElementInterface && !($element instanceof BlockElement)) {
                    $elementEvent = new ElementEvent($nodeEvent, $element);
                    $this->trigger($elementEvent);
                    $element = $elementEvent->getElement();
                }

                return $element;
            }
        }

        $this->throwException(
            'No compiler found able to compile '.get_class($node),
            $node
        );
    }
18803
public function getClosestDocument(NodeInterface $node)
    {
        if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
            return $node;
        }

        $flowQuery = new FlowQuery([$node]);

        return $flowQuery->closest('[instanceof Neos.Neos:Document]')->get(0);
    }
1327037
private function getResolvableValue(\Twig_Node_Expression $node)
    {
        if ($node instanceof \Twig_Node_Expression_Constant
            && 'not_used' !== $node->getAttribute('value')) {
            return $node->getAttribute('value');
        }

        return false;
    }
788520
public static function CreateFilter( $context, $node, $predicateList )
	{
		if ( count( $predicateList ) == 1 )
		{
			/**
			 * @var AbstractNode $predicate
			 */
			$predicate = AbstractNode::Create( $context, $predicateList[0] );
			if ( $predicate instanceof ValueNode )
			{
				/**
				 * @var ValueNode $numexpr
				 */
				$numexpr = $predicate;
				if ( is_int( $numexpr->getContent() ) || $numexpr->getContent() instanceof Integer )
				{
					/**
					 * @var PathStep $res
					 */
					$res = PathStep::Create( $context, $node );
					$res->AddLast( PathStep::fromNodeType( $numexpr->getContent(), XPath2ExprType::PositionFilter ) );
					return $res;
				}
			}
		}

		/**
		 * @var AbstractNode $filterExpr
		 */
		$filterExpr = new FilterExprNode( $context, $node, $predicateList );
		// return new PathStep( $filterExpr );
		return PathStep::fromNode( $filterExpr );
	}
587477
private function getNodeToStringConverter(): Closure
    {
        return function (...$nodes) {
            $value = '';
            foreach ($nodes as $node) {
                if (is_scalar($node)) {
                    $value .= $node;
                } else {
                    $value .= $node->getValue();
                }
            }

            return $value;
        };
    }
750618
public function leaveNode(Node $node)
    {
        $filter = $this->filter;

        if (! $node instanceof ClassMethod || null === ($filterResult = $filter($node))) {
            return null;
        }

        if (false === $filterResult) {
            return false;
        }

        $node->stmts = array(
            new Throw_(
                new New_(
                    new FullyQualified('BadMethodCallException'),
                    array(new Arg(new String_('Method is disabled')))
                )
            )
        );

        return $node;
    }
301014
private function getPrimitiveValue(Node $node) {
		if ($this->isBool($node)) {
			return (bool) $this->getExpression($node);
		}
	
		if ($this->isNull($node)) {
			return null;
		}
	
		return $node->value;
	}
271619
protected function filterNode(\DOMNode $node): bool
    {
        switch ($node->nodeType) {
            case XML_ELEMENT_NODE:
                return $this->filterElement($node);
            case XML_PI_NODE:
                return $this->filterProcessingInstruction($node);
            case XML_COMMENT_NODE:
                return $this->filterComment($node);
        }
        return false;
    }
223005
protected function handleExpression($node)
    {
        if ($node instanceof FunctionNode) throw new ParenthesisMismatchException($node->getOperator());
        if ($node instanceof SubExpressionNode) throw new ParenthesisMismatchException($node->getOperator());

        if (!$this->simplifyingParser) return $this->naiveHandleExpression($node);

        if ($node->getOperator() == '~') {

            $left = $this->operandStack->pop();
            if ($left === null) {
                throw new SyntaxErrorException();
            }

            if ($left instanceof NumberNode) {
                return new NumberNode(-$left->getValue());
            }

            if ($left instanceof IntegerNode) {
                return new IntegerNode(-$left->getValue());
            }

            if ($left instanceof RationalNode) {
                return new RationalNode(-$left->getNumerator(), $left->getDenominator());
            }

            $node->setOperator('-');
            $node->setLeft($left);

            return $this->nodeFactory->simplify($node);
        }

        $right = $this->operandStack->pop();
        $left = $this->operandStack->pop();
        if ($right === null || $left === null) {
            throw new SyntaxErrorException();
        }

        $node->setLeft($left);
        $node->setRight($right);

        return $this->nodeFactory->simplify($node);
    }
1201787
private function _isAttrSelector($node)
    {
        $ret = false;

        if ($this->_op == CssParserFilterAttr::EQUAL_SELECTOR) {
            $ret = $this->_isEqualSelector($node);
        } elseif ($this->_op == CssParserFilterAttr::NOT_EQUAL_SELECTOR) {
            $ret = $this->_isNotEqualSelector($node);
        } elseif ($this->_op == CssParserFilterAttr::CONTAIN_SELECTOR) {
            $ret = $this->_isContainSelector($node);
        } elseif ($this->_op == CssParserFilterAttr::CONTAIN_WORD_SELECTOR) {
            $ret = $this->_isContainWordSelector($node);
        } elseif ($this->_op == CssParserFilterAttr::CONTAIN_PREFIX_SELECTOR) {
            $ret = $this->_isContainPrefixSelector($node);
        } elseif ($this->_op == CssParserFilterAttr::START_WITH_SELECTOR) {
            $ret = $this->_isStartWithSelector($node);
        } elseif ($this->_op == CssParserFilterAttr::END_WITH_SELECTOR) {
            $ret = $this->_isEndWithSelector($node);
        } else {
            $ret = $this->_hasAttribute($node);
        }

        return $ret;
    }
882236
protected function transpileDirectiveNode(Node $node) : string
    {
        $children = $node->getChildren();

        if (count($children) === 0) {
            return '';
        }

        $directiveName = $children[0]->getValue();
        $expression = count($children) === 2 ? $children[1]->getValue() : '';

        if (!isset($this->directiveTranspilers[$directiveName])) {
            throw new RuntimeException(
                sprintf(
                    'No transpiler registered for directive "%s"',
                    $directiveName
                )
            );
        }

        return $this->directiveTranspilers[$directiveName]($expression);
    }
251936
public function compile(Compiler $compiler)
    {
        $compiler->addDebugInfo($this);

        $compiler
            ->write('try {')
        ;

        $compiler
            ->indent()
            ->subcompile($this->getNode('try'))
        ;

        if ($this->hasNode('catch') && null !== $this->getNode('catch')) {
            $compiler
                ->outdent()
                ->write('} catch (\Exception $e) {' . "\n")
                ->indent()
                ->write('if (isset($context[\'grav\'][\'debugger\'])) $context[\'grav\'][\'debugger\']->addException($e);' . "\n")
                ->write('$context[\'e\'] = $e;' . "\n")
                ->subcompile($this->getNode('catch'))
            ;
        }

        $compiler
            ->outdent()
            ->write("}\n");
    }
1158453
public function filterLanguage()
    {
        $this->lexer->moveNext();

        $node = $this->filterNode();

        // Check for end of string
        if ($this->lexer->lookahead !== null) {
            $this->syntaxError('end of string');
        }

        return $node;
    }