2011-04-18 19:02:30 +02:00
|
|
|
<?php
|
2011-05-31 16:33:11 +02:00
|
|
|
$meta #
|
|
|
|
#semval($) $this->yyval
|
|
|
|
#semval($,%t) $this->yyval
|
|
|
|
#semval(%n) $this->yyastk[$this->yysp-(%l-%n)]
|
|
|
|
#semval(%n,%t) $this->yyastk[$this->yysp-(%l-%n)]
|
|
|
|
#include;
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2012-03-02 00:43:34 +01:00
|
|
|
/* This is an automatically GENERATED file, which should not be manually edited.
|
|
|
|
* Instead edit one of the following:
|
|
|
|
* * the grammar file grammar/zend_language_parser.phpy
|
2012-04-04 15:51:56 +02:00
|
|
|
* * the parser skeleton grammar/kymacc.php.parser
|
2012-03-02 00:43:34 +01:00
|
|
|
* * the preprocessing script grammar/rebuildParser.php
|
|
|
|
*
|
2012-04-04 15:51:56 +02:00
|
|
|
* The skeleton for this parser was written by Moriyoshi Koizumi and is based on
|
2012-03-02 00:43:34 +01:00
|
|
|
* the work by Masato Bito and is in the PUBLIC DOMAIN.
|
2011-04-18 19:02:30 +02:00
|
|
|
*/
|
2011-08-14 15:36:15 +02:00
|
|
|
#if -t
|
|
|
|
class #(-p)_Debug extends #(-p)
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2011-08-14 15:36:15 +02:00
|
|
|
#ifnot -t
|
|
|
|
class #(-p)
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2011-04-18 19:02:30 +02:00
|
|
|
{
|
2011-08-14 15:36:15 +02:00
|
|
|
#ifnot -t
|
2012-04-29 22:57:46 +02:00
|
|
|
const TOKEN_NONE = -1;
|
|
|
|
const TOKEN_INVALID = #(YYBADCH);
|
|
|
|
|
|
|
|
const TOKEN_MAP_SIZE = #(YYMAXLEX);
|
|
|
|
|
2011-05-31 16:33:11 +02:00
|
|
|
const YYLAST = #(YYLAST);
|
|
|
|
const YY2TBLSTATE = #(YY2TBLSTATE);
|
|
|
|
const YYGLAST = #(YYGLAST);
|
|
|
|
const YYNLSTATES = #(YYNLSTATES);
|
|
|
|
const YYUNEXPECTED = #(YYUNEXPECTED);
|
|
|
|
const YYDEFAULT = #(YYDEFAULT);
|
2011-04-18 19:02:30 +02:00
|
|
|
|
|
|
|
// {{{ Tokens
|
2011-05-31 16:33:11 +02:00
|
|
|
#tokenval
|
2011-04-18 19:02:30 +02:00
|
|
|
const %s = %n;
|
2011-05-31 16:33:11 +02:00
|
|
|
#endtokenval
|
2011-04-18 19:02:30 +02:00
|
|
|
// }}}
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
/* @var array Map of token ids to their respective names */
|
|
|
|
protected static $terminals = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar terminals
|
2011-04-18 19:02:30 +02:00
|
|
|
, "???"
|
|
|
|
);
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
/* @var Map which translates lexer tokens to internal tokens */
|
|
|
|
protected static $translate = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yytranslate
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yyaction = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yyaction
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yycheck = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yycheck
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yybase = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yybase
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yydefault = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yydefault
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yygoto = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yygoto
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yygcheck = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yygcheck
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yygbase = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yygbase
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yygdefault = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yygdefault
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yylhs = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yylhs
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yylen = array(
|
2011-05-31 16:33:11 +02:00
|
|
|
#listvar yylen
|
2011-04-18 19:02:30 +02:00
|
|
|
);
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected $yyval;
|
|
|
|
protected $yyastk;
|
|
|
|
protected $yysp;
|
|
|
|
protected $lexer;
|
2012-04-25 20:04:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a parser instance.
|
|
|
|
*
|
|
|
|
* @param PHPParser_Lexer $lexer A lexer
|
|
|
|
*/
|
|
|
|
public function __construct(PHPParser_Lexer $lexer) {
|
|
|
|
$this->lexer = $lexer;
|
|
|
|
}
|
2011-08-14 15:36:15 +02:00
|
|
|
#endif
|
2011-05-31 16:33:11 +02:00
|
|
|
#if -t
|
2011-08-14 15:36:15 +02:00
|
|
|
protected static $yyproduction = array(
|
|
|
|
#production-strings;
|
|
|
|
);
|
|
|
|
|
2011-04-18 19:02:30 +02:00
|
|
|
protected function yyprintln($msg) {
|
|
|
|
echo $msg, "\n";
|
|
|
|
}
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
protected function YYTRACE_NEWSTATE($state, $tokenId) {
|
2011-05-31 16:33:11 +02:00
|
|
|
$this->yyprintln(
|
|
|
|
'% State ' . $state
|
2012-04-29 22:57:46 +02:00
|
|
|
. ', Lookahead ' . ($tokenId == self::TOKEN_NONE ? '--none--' : self::$terminals[$tokenId])
|
2011-05-31 16:33:11 +02:00
|
|
|
);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
protected function YYTRACE_READ($tokenId) {
|
|
|
|
$this->yyprintln('% Reading ' . self::$terminals[$tokenId]);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
protected function YYTRACE_SHIFT($tokenId) {
|
|
|
|
$this->yyprintln('% Shift ' . self::$terminals[$tokenId]);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected function YYTRACE_ACCEPT() {
|
2011-05-29 20:51:15 +02:00
|
|
|
$this->yyprintln('% Accepted.');
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected function YYTRACE_REDUCE($n) {
|
2011-05-29 20:51:15 +02:00
|
|
|
$this->yyprintln('% Reduce by (' . $n . ') ' . self::$yyproduction[$n]);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected function YYTRACE_POP($state) {
|
2011-05-29 20:51:15 +02:00
|
|
|
$this->yyprintln('% Recovering, uncovers state ' . $state);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
protected function YYTRACE_DISCARD($tokenId) {
|
|
|
|
$this->yyprintln('% Discard ' . self::$terminals[$tokenId]);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
|
|
|
|
2011-04-18 19:02:30 +02:00
|
|
|
/**
|
2011-05-31 16:33:11 +02:00
|
|
|
#ifnot -t
|
|
|
|
* Parses PHP code into a node tree.
|
|
|
|
#endif
|
|
|
|
#if -t
|
|
|
|
* Parses PHP code into a node tree and prints out debugging information.
|
|
|
|
#endif
|
|
|
|
*
|
2012-04-25 20:04:46 +02:00
|
|
|
* @param string $code The source code to parse
|
2011-05-31 16:33:11 +02:00
|
|
|
*
|
|
|
|
* @return array Array of statements
|
2011-04-18 19:02:30 +02:00
|
|
|
*/
|
2012-04-25 20:04:46 +02:00
|
|
|
public function parse($code) {
|
|
|
|
$this->lexer->startLexing($code);
|
2011-06-12 17:19:12 +02:00
|
|
|
|
2011-06-28 14:11:12 +02:00
|
|
|
$this->yysp = 0; // Stack pos
|
2012-04-29 22:57:46 +02:00
|
|
|
$stateStack = array($state = 0); // State stack
|
2011-06-28 14:11:12 +02:00
|
|
|
$this->yyastk = array(); // AST stack (?)
|
|
|
|
$yylstk = array($yyline = 1); // Line stack
|
2011-07-03 16:35:45 +02:00
|
|
|
$yydstk = array($yyDC = null); // Doc comment stack
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
$tokenId = self::TOKEN_NONE;
|
2011-04-18 19:02:30 +02:00
|
|
|
|
|
|
|
for (;;) {
|
2011-05-31 16:33:11 +02:00
|
|
|
#if -t
|
2012-04-29 22:57:46 +02:00
|
|
|
$this->YYTRACE_NEWSTATE($state, $tokenId);
|
|
|
|
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2012-04-29 22:57:46 +02:00
|
|
|
if (self::$yybase[$state] == 0) {
|
|
|
|
$yyn = self::$yydefault[$state];
|
2011-04-18 19:02:30 +02:00
|
|
|
} else {
|
2012-04-29 22:57:46 +02:00
|
|
|
if ($tokenId === self::TOKEN_NONE) {
|
|
|
|
// fetch the next token id from the lexer and fetch additional info by-ref
|
|
|
|
$origTokenId = $this->lexer->getNextToken($tokenValue, $yyline, $yyDC);
|
|
|
|
|
|
|
|
// map the lexer token id to the internally used token id's
|
|
|
|
$tokenId = $origTokenId >= 0 && $origTokenId < self::TOKEN_MAP_SIZE
|
|
|
|
? self::$translate[$origTokenId]
|
|
|
|
: self::TOKEN_INVALID;
|
|
|
|
|
|
|
|
if ($tokenId === self::TOKEN_INVALID) {
|
|
|
|
throw new RangeException(sprintf(
|
|
|
|
'The lexer returned an invalid token (id=%d, value=%s)',
|
|
|
|
$origTokenId, $tokenValue
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-06-28 14:11:12 +02:00
|
|
|
$yylstk[$this->yysp] = $yyline;
|
2011-07-03 16:35:45 +02:00
|
|
|
$yydstk[$this->yysp] = $yyDC;
|
2011-05-31 16:33:11 +02:00
|
|
|
#if -t
|
2012-04-29 22:57:46 +02:00
|
|
|
|
|
|
|
$this->YYTRACE_READ($tokenId);
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
2012-04-29 22:57:46 +02:00
|
|
|
|
|
|
|
if ((($yyn = self::$yybase[$state] + $tokenId) >= 0
|
|
|
|
&& $yyn < self::YYLAST && self::$yycheck[$yyn] == $tokenId
|
|
|
|
|| ($state < self::YY2TBLSTATE
|
|
|
|
&& ($yyn = self::$yybase[$state + self::YYNLSTATES] + $tokenId) >= 0
|
2011-04-18 19:02:30 +02:00
|
|
|
&& $yyn < self::YYLAST
|
2012-04-29 22:57:46 +02:00
|
|
|
&& self::$yycheck[$yyn] == $tokenId))
|
2011-04-18 19:02:30 +02:00
|
|
|
&& ($yyn = self::$yyaction[$yyn]) != self::YYDEFAULT) {
|
|
|
|
/*
|
|
|
|
* >= YYNLSTATE: shift and reduce
|
|
|
|
* > 0: shift
|
|
|
|
* = 0: accept
|
|
|
|
* < 0: reduce
|
|
|
|
* = -YYUNEXPECTED: error
|
|
|
|
*/
|
|
|
|
if ($yyn > 0) {
|
|
|
|
/* shift */
|
2011-05-31 16:33:11 +02:00
|
|
|
#if -t
|
2012-04-29 22:57:46 +02:00
|
|
|
$this->YYTRACE_SHIFT($tokenId);
|
|
|
|
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2011-04-20 13:40:29 +02:00
|
|
|
++$this->yysp;
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
$stateStack[$this->yysp] = $state = $yyn;
|
|
|
|
$this->yyastk[$this->yysp] = $tokenValue;
|
2011-06-28 14:11:12 +02:00
|
|
|
$yylstk[$this->yysp] = $yyline;
|
2011-07-03 16:35:45 +02:00
|
|
|
$yydstk[$this->yysp] = $yyDC;
|
2012-04-29 22:57:46 +02:00
|
|
|
$tokenId = self::TOKEN_NONE;
|
2011-04-18 19:02:30 +02:00
|
|
|
|
|
|
|
if ($yyn < self::YYNLSTATES)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* $yyn >= YYNLSTATES means shift-and-reduce */
|
|
|
|
$yyn -= self::YYNLSTATES;
|
|
|
|
} else {
|
|
|
|
$yyn = -$yyn;
|
|
|
|
}
|
|
|
|
} else {
|
2012-04-29 22:57:46 +02:00
|
|
|
$yyn = self::$yydefault[$state];
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
/* reduce/error */
|
|
|
|
if ($yyn == 0) {
|
|
|
|
/* accept */
|
2011-05-31 16:33:11 +02:00
|
|
|
#if -t
|
2011-04-18 19:02:30 +02:00
|
|
|
$this->YYTRACE_ACCEPT();
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2011-04-20 13:40:29 +02:00
|
|
|
return $this->yyval;
|
2011-04-18 19:02:30 +02:00
|
|
|
} elseif ($yyn != self::YYUNEXPECTED) {
|
|
|
|
/* reduce */
|
2011-05-31 16:33:11 +02:00
|
|
|
#if -t
|
2011-04-18 19:02:30 +02:00
|
|
|
$this->YYTRACE_REDUCE($yyn);
|
2011-05-31 16:33:11 +02:00
|
|
|
#endif
|
2011-06-03 17:44:23 +02:00
|
|
|
try {
|
2011-07-03 16:35:45 +02:00
|
|
|
$this->{'yyn' . $yyn}(
|
|
|
|
$yylstk[$this->yysp - self::$yylen[$yyn]],
|
|
|
|
$yydstk[$this->yysp - self::$yylen[$yyn]]
|
|
|
|
);
|
2011-06-05 18:52:41 +02:00
|
|
|
} catch (PHPParser_Error $e) {
|
2011-11-27 12:53:48 +01:00
|
|
|
if (-1 === $e->getRawLine()) {
|
|
|
|
$e->setRawLine($yyline);
|
|
|
|
}
|
2011-06-03 17:44:23 +02:00
|
|
|
|
|
|
|
throw $e;
|
|
|
|
}
|
2011-04-20 13:40:29 +02:00
|
|
|
|
|
|
|
/* Goto - shift nonterminal */
|
|
|
|
$this->yysp -= self::$yylen[$yyn];
|
|
|
|
$yyn = self::$yylhs[$yyn];
|
2012-04-29 22:57:46 +02:00
|
|
|
if (($yyp = self::$yygbase[$yyn] + $stateStack[$this->yysp]) >= 0
|
2011-04-20 13:40:29 +02:00
|
|
|
&& $yyp < self::YYGLAST
|
|
|
|
&& self::$yygcheck[$yyp] == $yyn) {
|
2012-04-29 22:57:46 +02:00
|
|
|
$state = self::$yygoto[$yyp];
|
2011-04-18 19:02:30 +02:00
|
|
|
} else {
|
2012-04-29 22:57:46 +02:00
|
|
|
$state = self::$yygdefault[$yyn];
|
2011-04-20 13:40:29 +02:00
|
|
|
}
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2011-04-20 13:40:29 +02:00
|
|
|
++$this->yysp;
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
$stateStack[$this->yysp] = $state;
|
2011-04-20 13:40:29 +02:00
|
|
|
$this->yyastk[$this->yysp] = $this->yyval;
|
2011-06-28 14:11:12 +02:00
|
|
|
$yylstk[$this->yysp] = $yyline;
|
2011-07-03 16:35:45 +02:00
|
|
|
$yydstk[$this->yysp] = $yyDC;
|
2011-04-18 19:02:30 +02:00
|
|
|
} else {
|
|
|
|
/* error */
|
2011-06-27 19:14:37 +02:00
|
|
|
throw new PHPParser_Error(
|
2012-04-29 22:57:46 +02:00
|
|
|
'Unexpected token ' . self::$terminals[$tokenId],
|
2011-06-28 14:11:12 +02:00
|
|
|
$yyline
|
2011-06-27 19:14:37 +02:00
|
|
|
);
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
|
2012-04-29 22:57:46 +02:00
|
|
|
if ($state < self::YYNLSTATES)
|
2011-04-18 19:02:30 +02:00
|
|
|
break;
|
|
|
|
/* >= YYNLSTATES means shift-and-reduce */
|
2012-04-29 22:57:46 +02:00
|
|
|
$yyn = $state - self::YYNLSTATES;
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-14 15:36:15 +02:00
|
|
|
#ifnot -t
|
2011-05-31 16:33:11 +02:00
|
|
|
#reduce
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected function yyn%n($line, $docComment) {
|
2011-04-18 19:02:30 +02:00
|
|
|
%b
|
|
|
|
}
|
2011-05-31 16:33:11 +02:00
|
|
|
#noact
|
2011-04-20 13:40:29 +02:00
|
|
|
|
2011-08-14 15:36:15 +02:00
|
|
|
protected function yyn%n() {
|
2011-04-20 13:40:29 +02:00
|
|
|
$this->yyval = $this->yyastk[$this->yysp];
|
|
|
|
}
|
2011-05-31 16:33:11 +02:00
|
|
|
#endreduce
|
2011-08-14 15:36:15 +02:00
|
|
|
#endif
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|
2011-05-31 16:33:11 +02:00
|
|
|
#tailcode;
|