/** * Create a lexer file from its skeleton plex file. * * @param string Path to the plex file. * @param string Optional path to output file. Default is lexerfile with * extension of ".php". */ function create($lexerfile, $outfile = '') { $this->_lex = new PHP_LexerGenerator_Lexer(file_get_contents($lexerfile)); $info = pathinfo($lexerfile); if ($outfile) { $this->outfile = $outfile; } else { $this->outfile = $info['dirname'] . DIRECTORY_SEPARATOR . substr($info['basename'], 0, strlen($info['basename']) - strlen($info['extension'])) . 'php'; } $this->_parser = new PHP_LexerGenerator_Parser($this->outfile, $this->_lex); if ($this->debug) { $this->_parser->PrintTrace(); } while ($this->_lex->advance($this->_parser)) { $this->_parser->doParse($this->_lex->token, $this->_lex->value); } $this->_parser->doParse(0, 0); }
/** * Output debug information to output (php://output stream) */ static function PrintTrace() { self::$yyTraceFILE = fopen('php://output', 'w'); self::$yyTracePrompt = ''; }