@param  ParseTree          &$current_leaf
@param  ParseTree          $current_parent
@param  array<int, string> $type_tokens
@param  string             $current_token
@param  int                &$i

@return void
349222
private static function createMethodParam(
        ParseTree &$current_leaf,
        ParseTree $current_parent,
        array $type_tokens,
        $current_token,
        &$i
    ) {
        $byref = false;
        $variadic = false;
        $has_default = false;
        $default = '';

        $c = count($type_tokens);

        if ($current_token === '&') {
            throw new TypeParseTreeException('Magic args cannot be passed by reference');
        }

        if ($current_token === '...') {
            $variadic = true;

            ++$i;
            $current_token = $i < $c ? $type_tokens[$i] : null;
        }

        if (!$current_token || $current_token[0] !== '$') {
            throw new TypeParseTreeException('Unexpected token after space ' . $current_token);
        }

        $new_parent_leaf = new ParseTree\MethodParamTree(
            $current_token,
            $byref,
            $variadic,
            $current_parent
        );

        for ($j = $i + 1; $j < $c; ++$j) {
            $ahead_type_token = $type_tokens[$j];

            if ($ahead_type_token === ','
                || ($ahead_type_token === ')' && $type_tokens[$j - 1] !== '(')
            ) {
                $i = $j - 1;
                break;
            }

            if ($has_default) {
                $default .= $ahead_type_token;
            }

            if ($ahead_type_token === '=') {
                $has_default = true;
                continue;
            }

            if ($j === $c - 1) {
                throw new TypeParseTreeException('Unterminated method');
            }
        }

        $new_parent_leaf->default = $default;

        if ($current_leaf !== $current_parent) {
            $new_parent_leaf->children = [$current_leaf];
            $current_leaf->parent = $new_parent_leaf;
            array_pop($current_parent->children);
        }

        $current_parent->children[] = $new_parent_leaf;

        $current_leaf = $new_parent_leaf;
    }
1282056
void clear()
    {
        NodeBuilder current = this;
        while (current != null && current.upperBound != null)
        {
            current.clearSelf();
            current = current.child;
        }
        current = parent;
        while (current != null && current.upperBound != null)
        {
            current.clearSelf();
            current = current.parent;
        }
    }
922140
private void initTopicTree(HelpTopicNode htnParent, TreeNode ttnParent) {
        
        for (int i = 0; i < ttnParent.getChildCount(); i++) {
            TreeNode ttnChild = ttnParent.getChildAt(i);
            HelpTopic ht = getTopic(ttnChild);
            HelpTopicNode htnChild = new HelpTopicNode(ht);
            htnParent.addChild(htnChild);
            initTopicTree(htnChild, ttnChild);
        }
        
    }
1061750
@Override
  protected void initParser() throws MtasConfigException {
    super.initParser();
    if (config != null) {
      for (int i = 0; i < config.children.size(); i++) {
        MtasConfiguration current = config.children.get(i);
        if (current.name.equals(PENNTREEBANK_IGNORE)) {
          for (int j = 0; j < current.children.size(); j++) {
            if (current.children.get(j).name.equals(PENNTREEBANK_NODE)) {
              String nameVariable = current.children.get(j).attributes
                  .get(PENNTREEBANK_NODE_NAME);
              if (!nameVariable.isEmpty()) {
                ignoreNodes.add(nameVariable);
              }
            }
          }
        }
      }
    }
  }
808059
function _tag_close( &$parser, $tag ) {
		$this->currentElement = '';

		switch( strtoupper( $tag ) ) {
			case 'DATA':
				xml_set_object( $parser, $this->parent );
				break;
		}
	}
73653
public function index(PageController $parent_controller, Tree $tree, $block_id, $template) {        
        $view_bag = new ViewBag();
        
        if($parent_controller && $tree) {
        
            $view_bag->set('tree', $tree);
            $view_bag->set('indi', $parent_controller->getSignificantIndividual());
        
            $id = $this->module->getName().$block_id;
            $class = $this->module->getName().'_block';
            $parent_controller->addInlineJavascript('
                jQuery("#maj-new_passwd").hide();
                jQuery("#maj-passwd_click").click(function()
                {
                    jQuery("#maj-new_passwd").slideToggle(100, function() {
                        jQuery("#maj-new_passwd_username").focus();
    			});
    					return false;
    				  });
    			');
    
            if (Auth::isAdmin()) {
                $title='<a class="icon-admin" title="'.I18N::translate('Preferences').'" href="block_edit.php?block_id='.$block_id.'&amp;ged=' . $tree->getNameHtml() . '&amp;ctype=gedcom"></a>';
            } else {
                $title='';
            }
            $title .='<span dir="auto">'.$tree->getTitleHtml().'</span>';
    
            $piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false);
            $view_bag->set('piwik_enabled', $piwik_enabled);
            if($piwik_enabled) {
                $parent_controller->addInlineJavascript(
                    '$("#piwik_stats")
                        .load("module.php?mod='.$this->module->getName().'&mod_action=Piwik&block_id='.$block_id.'");'
                );
            }
    
            $content = ViewFactory::make('WelcomeBlock', $this,  new BaseController(), $view_bag)->getHtmlPartial();   
            
            if ($template) {
                return Theme::theme()->formatBlock($id, $title, $class, $content);
            } else {
                return $content;
            }
        }
    }
639647
function _displayTree($tree, $parent = NULL) {
        $outputList = TRUE;
        foreach ($tree as $name => $element) {
            if ($element->superclass() == $parent) {
                if ($outputList)
                    echo "<ul>\n";
                echo "<li><a href=\"", $this->_asURL($element), "\">", $element->qualifiedName(), "</a>";
                $this->_displayTree($tree, $name);
                echo "</li>\n";
                $outputList = FALSE;
            }
        }
        if (!$outputList)
            echo "</ul>\n";
    }
935987
public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree)
    {
        $last_subtree = count($this->subtrees) - 1;
        if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $parser->block_nesting_level) {
            if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
                $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
            } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
                $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
            } else {
                $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
            }
        } else {
            $this->subtrees[] = $subtree;
        }
        if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
            $parser->block_nesting_level = count($parser->compiler->_tag_stack);
        }
    }
250427
protected function formatOpeningParenthesis($token, $i, array &$tokens, array &$originalTokens)
    {
        $length = 0;
        for ($j = 1; $j <= 250; ++$j) {
            if (isset($tokens[$i + $j])) {
                $next = $tokens[$i + $j];
                if ($this->parentheses->stringIsClosingParentheses($next)) {
                    $this->parentheses->writeNewInlineParentheses();
                    break;
                }

                if ($this->parentheses->invalidParenthesesTokenValue($next)
                    || $this->parentheses->invalidParenthesesTokenType($next)
                ) {
                    break;
                }

                $length += \strlen($next[Tokenizer::TOKEN_VALUE]);
            }
        }
        $this->newLine->writeNewLineForLongInlineValues($length);

        if (WhiteSpace::isPrecedingCurrentTokenOfTokenTypeWhiteSpace($originalTokens, $token)) {
            $this->formattedSql = \rtrim($this->formattedSql, ' ');
        }

        $this->newLine->addNewLineAfterOpeningParentheses();

        return $tokens;
    }
812541
public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree)
    {
        if (!empty($subtree->subtrees)) {
            $this->subtrees = array_merge($this->subtrees, $subtree->subtrees);
        } else {
            if ($subtree->data !== '') {
                $this->subtrees[] = $subtree;
            }
        }
    }
646721
public function current()
    {
        $token = parent::current();
        $offset = $this->key();
        $before = isset($this[$offset - 1])
                ? $this[$offset - 1]
                : null;

        // is it an unused token?
        if (false === self::$sequences[$token[0]]) {
            throw UnexpectedTokenException::create(
                'Token #%d (%d) is not used by this library.',
                $offset,
                $token[0]
            );

            // not in the list of expected tokens?
        } elseif ((empty($before) && (DocLexer::T_AT !== $token[0]))
            || ($before && !isset(self::$sequences[$token[0]][$before[0]]))) {
            throw UnexpectedTokenException::create(
                'Token #%d (%d) is not expected here.',
                $offset,
                $token[0]
            );

            // before token has another before requirement?
        } elseif (isset(self::$sequences[$token[0]][$before[0]])
            && (true !== self::$sequences[$token[0]][$before[0]])) {
            $ancestor = isset($this[$offset - 2])
                      ? $this[$offset - 2]
                      : null;

            if (!$ancestor
                || ($ancestor[0] !== self::$sequences[$token[0]][$before[0]])) {
                throw UnexpectedTokenException::create(
                    'Token #%d (%d) is not expected here.',
                    $offset,
                    $token[0]
                );
            }
        }

        return $token;
    }
683249
protected function _processTree($parent)
    {
        foreach ($parent->tree as $node) {
            if ($node->hasMethods && $node->type !== 'interface') {
                $this->_processMethods($node);
            } elseif (!empty($node->tree)) {
                $this->_processTree($node);
            }
        }
    }
763796
protected void handleParentheses( TokenList tokens, Sequence sequence ) {
        // have a list to handle embedded parentheses, e.g. (((((a)))))
        List<TokenList.Token> left = new ArrayList<TokenList.Token>();

        // find all of them
        TokenList.Token t = tokens.first;
        while( t != null ) {
            TokenList.Token next = t.next;
            if( t.getType() == Type.SYMBOL ) {
                if( t.getSymbol() == Symbol.PAREN_LEFT  )
                    left.add(t);
                else if( t.getSymbol() == Symbol.PAREN_RIGHT ) {
                    if( left.isEmpty() )
                        throw new ParseError(") found with no matching (");

                    TokenList.Token a = left.remove(left.size()-1);

                    // remember the element before so the new one can be inserted afterwards
                    TokenList.Token before = a.previous;

                    TokenList sublist = tokens.extractSubList(a,t);
                    // remove parentheses
                    sublist.remove(sublist.first);
                    sublist.remove(sublist.last);

                    // if its a function before () then the () indicates its an input to a function
                    if( before != null && before.getType() == Type.FUNCTION ) {
                        List<TokenList.Token> inputs = parseParameterCommaBlock(sublist, sequence);
                        if (inputs.isEmpty())
                            throw new ParseError("Empty function input parameters");
                        else {
                            createFunction(before, inputs, tokens, sequence);
                        }
                    } else if( before != null && before.getType() == Type.VARIABLE &&
                            before.getVariable().getType() == VariableType.MATRIX ) {
                        // if it's a variable then that says it's a sub-matrix
                        TokenList.Token extract = parseSubmatrixToExtract(before,sublist, sequence);
                        // put in the extract operation
                        tokens.insert(before,extract);
                        tokens.remove(before);
                    } else {
                        // if null then it was empty inside
                        TokenList.Token output = parseBlockNoParentheses(sublist,sequence, false);
                        if (output != null)
                            tokens.insert(before, output);
                    }
                }
            }
            t = next;
        }

        if( !left.isEmpty())
            throw new ParseError("Dangling ( parentheses");
    }
65623
private function traverse($currentNode)
    {
        $this->collectDiagnostics($currentNode);

        // Only update/descend into Nodes, Tokens are leaves
        if ($currentNode instanceof Node) {
            $this->collectDefinitionsAndReferences($currentNode);

            foreach ($currentNode::CHILD_NAMES as $name) {
                $child = $currentNode->$name;

                if ($child === null) {
                    continue;
                }

                if (\is_array($child)) {
                    foreach ($child as $actualChild) {
                        if ($actualChild !== null) {
                            $this->traverse($actualChild);
                        }
                    }
                } else {
                    $this->traverse($child);
                }
            }
        }
    }
1176103
function inputSectionXML( &$section, $currentSectionLevel, $tdSectionLevel = null )
    {
        $output = '';

        foreach ( $section->childNodes as $sectionNode )
        {
            if ( $tdSectionLevel == null )
            {
                $sectionLevel = $currentSectionLevel;
            }
            else
            {
                $sectionLevel = $tdSectionLevel;
            }

            $tagName = $sectionNode instanceof DOMNode ? $sectionNode->nodeName : '';

            switch ( $tagName )
            {
                case 'header' :
                {
                    $headerClassName = $sectionNode->getAttribute( 'class' );
                    $headerAlign = $sectionNode->getAttribute( 'align' );
                    $customAttributePart = self::getCustomAttrPart( $sectionNode, $styleString );

                    if ( $headerClassName )
                    {
                        $customAttributePart .= ' class="' . $headerClassName . '"';
                    }

                    if ( $headerAlign )
                    {
                        $customAttributePart .= ' align="' . $headerAlign . '"';
                    }

                    $tagContent = '';
                    // render children tags
                    $tagChildren = $sectionNode->childNodes;
                    foreach ( $tagChildren as $childTag )
                    {
                        $tagContent .= $this->inputTagXML( $childTag, $currentSectionLevel, $tdSectionLevel );
                        eZDebugSetting::writeDebug( 'kernel-datatype-ezxmltext',
                                                    $tagContent,
                                                    __METHOD__ . ' tag content of <header>' );
                    }

                    switch ( $sectionLevel )
                    {
                        case '2':
                        case '3':
                        case '4':
                        case '5':
                        case '6':
                        {
                            $level = $sectionLevel;
                        }break;
                        default:
                        {
                            $level = 1;
                        }break;
                    }
                    $archorName = $sectionNode->getAttribute( 'anchor_name' );
                    if ( $archorName != null )
                    {
                        $output .= "<h$level$customAttributePart$styleString><a name=\"$archorName\"" .
                                   ' class="mceItemAnchor"></a>' . $sectionNode->textContent. "</h$level>";
                    }
                    else
                    {
                        $output .= "<h$level$customAttributePart$styleString>" . $tagContent . "</h$level>";
                    }

                }break;

                case 'paragraph' :
                {
                    if ( $tdSectionLevel == null )
                    {
                        $output .= $this->inputParagraphXML( $sectionNode, $currentSectionLevel );
                    }
                    else
                    {
                        $output .= $this->inputParagraphXML( $sectionNode,
                                                             $currentSectionLevel,
                                                             $tdSectionLevel );
                    }
                }break;

                case 'section' :
                {
                    $sectionLevel += 1;
                    if ( $tdSectionLevel == null )
                    {
                        $output .= $this->inputSectionXML( $sectionNode, $sectionLevel );
                    }
                    else
                    {
                        $output .= $this->inputSectionXML( $sectionNode,
                                                           $currentSectionLevel,
                                                           $sectionLevel );
                    }
                }break;

                case '#text' :
                {
                    //ignore whitespace
                }break;

                default :
                {
                    eZDebug::writeError( "Unsupported tag at this level: $tagName", __METHOD__ );
                }break;
            }
        }
        return $output;
    }
424100
private void collectActiveElements(final List<GraphObject> resultList, final DOMNode root, final Set<String> parentDataKeys, final String parent, final int depth) {

		final String childDataKey  = root.getDataKey();
		final Set<String> dataKeys = new LinkedHashSet<>(parentDataKeys);
		String parentId            = parent;
		int dataCentricDepth       = depth;

		if (!StringUtils.isEmpty(childDataKey)) {

			dataKeys.add(childDataKey);
			dataCentricDepth++;
		}

		final ActiveElementState state = isActive(root, dataKeys);
		if (!state.equals(ActiveElementState.None)) {

			resultList.add(extractActiveElement(root, dataKeys, parentId, state, depth));
			if (state.equals(ActiveElementState.Query)) {

				parentId = root.getUuid();
			}
		}

		for (final DOMNode child : root.getChildren()) {

			collectActiveElements(resultList, child, dataKeys, parentId, dataCentricDepth);
		}

	}
1014135
private void condenseTree(IndexTreePath<E> subtree, Stack<N> stack) {
    N node = getNode(subtree.getEntry());
    // node is not root
    if(!isRoot(node)) {
      N parent = getNode(subtree.getParentPath().getEntry());
      int index = subtree.getIndex();
      if(hasUnderflow(node)) {
        if(parent.deleteEntry(index)) {
          stack.push(node);
        }
        else {
          node.adjustEntry(parent.getEntry(index));
        }
      }
      else {
        node.adjustEntry(parent.getEntry(index));
      }
      writeNode(parent);
      // get subtree to parent
      condenseTree(subtree.getParentPath(), stack);
    }

    // node is root
    else {
      if(hasUnderflow(node) && node.getNumEntries() == 1 && !node.isLeaf()) {
        N child = getNode(node.getEntry(0));
        final N newRoot;
        if(child.isLeaf()) {
          newRoot = createNewLeafNode();
          newRoot.setPageID(getRootID());
          for(int i = 0; i < child.getNumEntries(); i++) {
            newRoot.addLeafEntry(child.getEntry(i));
          }
        }
        else {
          newRoot = createNewDirectoryNode();
          newRoot.setPageID(getRootID());
          for(int i = 0; i < child.getNumEntries(); i++) {
            newRoot.addDirectoryEntry(child.getEntry(i));
          }
        }
        writeNode(newRoot);
        height--;
      }
    }
  }