예제 #1
0
 /**
  * Dump block node to string. 
  * 
  * @param   BlockNode   $node   block node
  * @param   integer     $level  indentation level
  *
  * @return  string
  */
 protected function dumpBlock(BlockNode $node, $level = 0)
 {
     $html = '';
     $last = '';
     $childs = $node->getChilds();
     foreach ($childs as $i => $child) {
         if (!empty($html) && !empty($last)) {
             $html .= "\n";
         }
         $this->nextIsIf[$level] = isset($childs[$i + 1]) && $childs[$i + 1] instanceof CodeNode && ($childs[$i + 1]->getPhpAlternateControlStructure() == 'else' || $childs[$i + 1]->getPhpAlternateControlStructure() == 'else if');
         $last = $this->dumpNode($child, $level);
         $html .= $last;
     }
     return $html;
 }
예제 #2
0
파일: Parser.php 프로젝트: clthck/slimphp
 /**
  * Parse indented block token. 
  * 
  * @return  BlockNode
  */
 protected function parseBlock()
 {
     $node = new BlockNode($this->lexer->getCurrentLine());
     $this->expectTokenType('indent');
     while ('outdent' !== $this->lexer->predictToken()->type && 'eos' !== $this->lexer->predictToken()->type) {
         if ('newline' === $this->lexer->predictToken()->type) {
             $this->lexer->getAdvancedToken();
         } else {
             if ($child = $this->parseExpression()) {
                 $node->addChild($child);
             }
         }
     }
     //$this->expectTokenType('outdent');
     $this->lexer->getAdvancedToken();
     return $node;
 }