Пример #1
0
 /**
  * Lex and parse the template into segments for final compilation.
  *
  * @return array Parsed segments
  */
 public function lexAndParse()
 {
     $lexer = new XenForo_Template_Compiler_Lexer($this->_text);
     $parser = new XenForo_Template_Compiler_Parser();
     try {
         while ($lexer->yylex() !== false) {
             $parser->doParse($lexer->match[0], $lexer->match[1]);
             $parser->setLineNumber($lexer->line);
             // if this is before the doParse, it seems to give wrong numbers
         }
         $parser->doParse(0, 0);
     } catch (Exception $e) {
         // from lexer, can't use the base exception, re-throw
         throw new XenForo_Template_Compiler_Exception(new XenForo_Phrase('line_x_template_syntax_error', array('number' => $lexer->line)), true);
     }
     // XenForo_Template_Compiler_Exception: ok -- no need to catch and rethrow
     return $parser->getOutput();
 }
Пример #2
0
 /**
  * Output debug information to output (php://output stream)
  */
 static function PrintTrace()
 {
     self::$yyTraceFILE = fopen('php://output', 'w');
     self::$yyTracePrompt = '';
 }