PageRenderTime 64ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/php-pear-CodeGen-PECL-1.1.3/CodeGen_PECL-1.1.3/PECL/Tools/ProtoParser.php

#
PHP | 1364 lines | 865 code | 42 blank | 457 comment | 124 complexity | 6b97e1fcb5ab96a8fdec223e7059db56 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* Driver template for the PHP_CodeGen_PECL_Tools_ProtoParser_rGenerator parser generator. (PHP port of LEMON)
  3. */
  4. /**
  5. * This can be used to store both the string representation of
  6. * a token, and any useful meta-data associated with the token.
  7. *
  8. * meta-data should be stored as an array
  9. */
  10. class CodeGen_PECL_Tools_ProtoParser_yyToken implements ArrayAccess
  11. {
  12. public $string = '';
  13. public $metadata = array();
  14. function __construct($s, $m = array())
  15. {
  16. if ($s instanceof CodeGen_PECL_Tools_ProtoParser_yyToken) {
  17. $this->string = $s->string;
  18. $this->metadata = $s->metadata;
  19. } else {
  20. $this->string = (string) $s;
  21. if ($m instanceof CodeGen_PECL_Tools_ProtoParser_yyToken) {
  22. $this->metadata = $m->metadata;
  23. } elseif (is_array($m)) {
  24. $this->metadata = $m;
  25. }
  26. }
  27. }
  28. function __toString()
  29. {
  30. return $this->_string;
  31. }
  32. function offsetExists($offset)
  33. {
  34. return isset($this->metadata[$offset]);
  35. }
  36. function offsetGet($offset)
  37. {
  38. return $this->metadata[$offset];
  39. }
  40. function offsetSet($offset, $value)
  41. {
  42. if ($offset === null) {
  43. if (isset($value[0])) {
  44. $x = ($value instanceof CodeGen_PECL_Tools_ProtoParser_yyToken) ?
  45. $value->metadata : $value;
  46. $this->metadata = array_merge($this->metadata, $x);
  47. return;
  48. }
  49. $offset = count($this->metadata);
  50. }
  51. if ($value === null) {
  52. return;
  53. }
  54. if ($value instanceof CodeGen_PECL_Tools_ProtoParser_yyToken) {
  55. if ($value->metadata) {
  56. $this->metadata[$offset] = $value->metadata;
  57. }
  58. } elseif ($value) {
  59. $this->metadata[$offset] = $value;
  60. }
  61. }
  62. function offsetUnset($offset)
  63. {
  64. unset($this->metadata[$offset]);
  65. }
  66. }
  67. /** The following structure represents a single element of the
  68. * parser's stack. Information stored includes:
  69. *
  70. * + The state number for the parser at this level of the stack.
  71. *
  72. * + The value of the token stored at this level of the stack.
  73. * (In other words, the "major" token.)
  74. *
  75. * + The semantic value stored at this level of the stack. This is
  76. * the information used by the action routines in the grammar.
  77. * It is sometimes called the "minor" token.
  78. */
  79. class CodeGen_PECL_Tools_ProtoParser_yyStackEntry
  80. {
  81. public $stateno; /* The state-number */
  82. public $major; /* The major token value. This is the code
  83. ** number for the token at this stack level */
  84. public $minor; /* The user-supplied minor token value. This
  85. ** is the value of the token */
  86. };
  87. // code external to the class is included here
  88. // declare_class is output here
  89. #line 2 "ProtoParser.y"
  90. class CodeGen_PECL_Tools_ProtoParser#line 102 "ProtoParser.php"
  91. {
  92. /* First off, code is included which follows the "include_class" declaration
  93. ** in the input file. */
  94. #line 3 "ProtoParser.y"
  95. protected $extension;
  96. protected $function;
  97. protected $optParams;
  98. function __construct(CodeGen_PECL_Extension $extension, CodeGen_PECL_Element_Function $function)
  99. {
  100. $this->extension = $extension;
  101. $this->function = $function;
  102. $this->optParams = array();
  103. }
  104. #line 119 "ProtoParser.php"
  105. /* Next is all token values, as class constants
  106. */
  107. /*
  108. ** These constants (all generated automatically by the parser generator)
  109. ** specify the various kinds of tokens (terminals) that the parser
  110. ** understands.
  111. **
  112. ** Each symbol here is a terminal symbol in the grammar.
  113. */
  114. const SEMICOLON = 1;
  115. const NAME = 2;
  116. const PAR_OPEN = 3;
  117. const PAR_CLOSE = 4;
  118. const VOID = 5;
  119. const AMPERSAND = 6;
  120. const BOOL = 7;
  121. const INT = 8;
  122. const FLOAT = 9;
  123. const STRING = 10;
  124. const ARRAY_ = 11;
  125. const CLASS_ = 12;
  126. const RESOURCE = 13;
  127. const MIXED = 14;
  128. const CALLBACK = 15;
  129. const STREAM = 16;
  130. const SQUARE_OPEN = 17;
  131. const SQUARE_CLOSE = 18;
  132. const ELLIPSE = 19;
  133. const COMMA = 20;
  134. const EQ = 21;
  135. const TRUE_ = 22;
  136. const FALSE_ = 23;
  137. const NULL_ = 24;
  138. const NUMVAL = 25;
  139. const STRVAL = 26;
  140. const YY_NO_ACTION = 102;
  141. const YY_ACCEPT_ACTION = 101;
  142. const YY_ERROR_ACTION = 100;
  143. /* Next are that tables used to determine what action to take based on the
  144. ** current state and lookahead token. These tables are used to implement
  145. ** functions that take a state number and lookahead value and return an
  146. ** action integer.
  147. **
  148. ** Suppose the action integer is N. Then the action is determined as
  149. ** follows
  150. **
  151. ** 0 <= N < self::YYNSTATE Shift N. That is,
  152. ** push the lookahead
  153. ** token onto the stack
  154. ** and goto state N.
  155. **
  156. ** self::YYNSTATE <= N < self::YYNSTATE+self::YYNRULE Reduce by rule N-YYNSTATE.
  157. **
  158. ** N == self::YYNSTATE+self::YYNRULE A syntax error has occurred.
  159. **
  160. ** N == self::YYNSTATE+self::YYNRULE+1 The parser accepts its
  161. ** input. (and concludes parsing)
  162. **
  163. ** N == self::YYNSTATE+self::YYNRULE+2 No such action. Denotes unused
  164. ** slots in the yy_action[] table.
  165. **
  166. ** The action table is constructed as a single large static array $yy_action.
  167. ** Given state S and lookahead X, the action is computed as
  168. **
  169. ** self::$yy_action[self::$yy_shift_ofst[S] + X ]
  170. **
  171. ** If the index value self::$yy_shift_ofst[S]+X is out of range or if the value
  172. ** self::$yy_lookahead[self::$yy_shift_ofst[S]+X] is not equal to X or if
  173. ** self::$yy_shift_ofst[S] is equal to self::YY_SHIFT_USE_DFLT, it means that
  174. ** the action is not in the table and that self::$yy_default[S] should be used instead.
  175. **
  176. ** The formula above is for computing the action when the lookahead is
  177. ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
  178. ** a reduce action) then the static $yy_reduce_ofst array is used in place of
  179. ** the static $yy_shift_ofst array and self::YY_REDUCE_USE_DFLT is used in place of
  180. ** self::YY_SHIFT_USE_DFLT.
  181. **
  182. ** The following are the tables generated in this section:
  183. **
  184. ** self::$yy_action A single table containing all actions.
  185. ** self::$yy_lookahead A table containing the lookahead for each entry in
  186. ** yy_action. Used to detect hash collisions.
  187. ** self::$yy_shift_ofst For each state, the offset into self::$yy_action for
  188. ** shifting terminals.
  189. ** self::$yy_reduce_ofst For each state, the offset into self::$yy_action for
  190. ** shifting non-terminals after a reduce.
  191. ** self::$yy_default Default action for each state.
  192. */
  193. const YY_SZ_ACTTAB = 100;
  194. static public $yy_action = array(
  195. /* 0 */ 36, 17, 29, 41, 53, 50, 44, 23, 22, 54,
  196. /* 10 */ 47, 48, 4, 34, 37, 29, 41, 53, 50, 44,
  197. /* 20 */ 23, 22, 54, 47, 48, 29, 41, 53, 50, 44,
  198. /* 30 */ 23, 22, 54, 47, 48, 25, 1, 42, 29, 41,
  199. /* 40 */ 53, 50, 44, 23, 22, 54, 47, 48, 40, 3,
  200. /* 50 */ 21, 12, 10, 8, 33, 16, 32, 18, 101, 11,
  201. /* 60 */ 24, 59, 35, 13, 12, 9, 27, 43, 57, 58,
  202. /* 70 */ 56, 55, 52, 12, 13, 27, 6, 12, 13, 45,
  203. /* 80 */ 7, 16, 16, 26, 2, 39, 49, 20, 30, 46,
  204. /* 90 */ 31, 5, 19, 51, 14, 38, 80, 15, 27, 28,
  205. );
  206. static public $yy_lookahead = array(
  207. /* 0 */ 5, 3, 7, 8, 9, 10, 11, 12, 13, 14,
  208. /* 10 */ 15, 16, 17, 5, 19, 7, 8, 9, 10, 11,
  209. /* 20 */ 12, 13, 14, 15, 16, 7, 8, 9, 10, 11,
  210. /* 30 */ 12, 13, 14, 15, 16, 18, 3, 19, 7, 8,
  211. /* 40 */ 9, 10, 11, 12, 13, 14, 15, 16, 2, 20,
  212. /* 50 */ 31, 32, 33, 34, 35, 17, 18, 11, 28, 29,
  213. /* 60 */ 30, 4, 32, 33, 32, 33, 6, 35, 22, 23,
  214. /* 70 */ 24, 25, 26, 32, 33, 6, 35, 32, 33, 19,
  215. /* 80 */ 35, 17, 17, 18, 20, 18, 2, 2, 19, 2,
  216. /* 90 */ 4, 21, 2, 37, 36, 1, 38, 36, 6, 36,
  217. );
  218. const YY_SHIFT_USE_DFLT = -6;
  219. const YY_SHIFT_MAX = 24;
  220. static public $yy_shift_ofst = array(
  221. /* 0 */ 8, -5, 18, 31, 31, 46, 38, 65, 64, 60,
  222. /* 10 */ 69, 94, 90, 92, 67, 17, 29, 57, -2, 70,
  223. /* 20 */ 33, 86, 84, 87, 85,
  224. );
  225. const YY_REDUCE_USE_DFLT = -1;
  226. const YY_REDUCE_MAX = 8;
  227. static public $yy_reduce_ofst = array(
  228. /* 0 */ 30, 19, 32, 45, 41, 56, 58, 61, 63,
  229. );
  230. static public $yyExpectedTokens = array(
  231. /* 0 */ array(5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ),
  232. /* 1 */ array(5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, ),
  233. /* 2 */ array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, ),
  234. /* 3 */ array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ),
  235. /* 4 */ array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ),
  236. /* 5 */ array(2, 11, 22, 23, 24, 25, 26, ),
  237. /* 6 */ array(17, 18, ),
  238. /* 7 */ array(17, 18, ),
  239. /* 8 */ array(17, 20, ),
  240. /* 9 */ array(6, 19, ),
  241. /* 10 */ array(6, 19, ),
  242. /* 11 */ array(1, ),
  243. /* 12 */ array(2, ),
  244. /* 13 */ array(6, ),
  245. /* 14 */ array(18, ),
  246. /* 15 */ array(18, ),
  247. /* 16 */ array(20, ),
  248. /* 17 */ array(4, ),
  249. /* 18 */ array(3, ),
  250. /* 19 */ array(21, ),
  251. /* 20 */ array(3, ),
  252. /* 21 */ array(4, ),
  253. /* 22 */ array(2, ),
  254. /* 23 */ array(2, ),
  255. /* 24 */ array(2, ),
  256. /* 25 */ array(),
  257. /* 26 */ array(),
  258. /* 27 */ array(),
  259. /* 28 */ array(),
  260. /* 29 */ array(),
  261. /* 30 */ array(),
  262. /* 31 */ array(),
  263. /* 32 */ array(),
  264. /* 33 */ array(),
  265. /* 34 */ array(),
  266. /* 35 */ array(),
  267. /* 36 */ array(),
  268. /* 37 */ array(),
  269. /* 38 */ array(),
  270. /* 39 */ array(),
  271. /* 40 */ array(),
  272. /* 41 */ array(),
  273. /* 42 */ array(),
  274. /* 43 */ array(),
  275. /* 44 */ array(),
  276. /* 45 */ array(),
  277. /* 46 */ array(),
  278. /* 47 */ array(),
  279. /* 48 */ array(),
  280. /* 49 */ array(),
  281. /* 50 */ array(),
  282. /* 51 */ array(),
  283. /* 52 */ array(),
  284. /* 53 */ array(),
  285. /* 54 */ array(),
  286. /* 55 */ array(),
  287. /* 56 */ array(),
  288. /* 57 */ array(),
  289. /* 58 */ array(),
  290. /* 59 */ array(),
  291. );
  292. static public $yy_default = array(
  293. /* 0 */ 100, 83, 100, 100, 100, 100, 100, 100, 77, 65,
  294. /* 10 */ 65, 60, 100, 65, 100, 100, 100, 100, 100, 91,
  295. /* 20 */ 100, 100, 100, 100, 100, 90, 89, 66, 87, 67,
  296. /* 30 */ 81, 62, 78, 88, 63, 64, 82, 80, 61, 79,
  297. /* 40 */ 99, 68, 84, 86, 71, 85, 72, 75, 76, 73,
  298. /* 50 */ 70, 92, 97, 69, 74, 96, 95, 93, 94, 98,
  299. );
  300. /* The next thing included is series of defines which control
  301. ** various aspects of the generated parser.
  302. ** self::YYNOCODE is a number which corresponds
  303. ** to no legal terminal or nonterminal number. This
  304. ** number is used to fill in empty slots of the hash
  305. ** table.
  306. ** self::YYFALLBACK If defined, this indicates that one or more tokens
  307. ** have fall-back values which should be used if the
  308. ** original value of the token will not parse.
  309. ** self::YYSTACKDEPTH is the maximum depth of the parser's stack.
  310. ** self::YYNSTATE the combined number of states.
  311. ** self::YYNRULE the number of rules in the grammar
  312. ** self::YYERRORSYMBOL is the code number of the error symbol. If not
  313. ** defined, then do no error processing.
  314. */
  315. const YYNOCODE = 39;
  316. const YYSTACKDEPTH = 100;
  317. const YYNSTATE = 60;
  318. const YYNRULE = 40;
  319. const YYERRORSYMBOL = 27;
  320. const YYERRSYMDT = 'yy0';
  321. const YYFALLBACK = 0;
  322. /** The next table maps tokens into fallback tokens. If a construct
  323. * like the following:
  324. *
  325. * %fallback ID X Y Z.
  326. *
  327. * appears in the grammer, then ID becomes a fallback token for X, Y,
  328. * and Z. Whenever one of the tokens X, Y, or Z is input to the parser
  329. * but it does not parse, the type of the token is changed to ID and
  330. * the parse is retried before an error is thrown.
  331. */
  332. static public $yyFallback = array(
  333. );
  334. /**
  335. * Turn parser tracing on by giving a stream to which to write the trace
  336. * and a prompt to preface each trace message. Tracing is turned off
  337. * by making either argument NULL
  338. *
  339. * Inputs:
  340. *
  341. * - A stream resource to which trace output should be written.
  342. * If NULL, then tracing is turned off.
  343. * - A prefix string written at the beginning of every
  344. * line of trace output. If NULL, then tracing is
  345. * turned off.
  346. *
  347. * Outputs:
  348. *
  349. * - None.
  350. * @param resource
  351. * @param string
  352. */
  353. static function Trace($TraceFILE, $zTracePrompt)
  354. {
  355. if (!$TraceFILE) {
  356. $zTracePrompt = 0;
  357. } elseif (!$zTracePrompt) {
  358. $TraceFILE = 0;
  359. }
  360. self::$yyTraceFILE = $TraceFILE;
  361. self::$yyTracePrompt = $zTracePrompt;
  362. }
  363. /**
  364. * Output debug information to output (php://output stream)
  365. */
  366. static function PrintTrace()
  367. {
  368. self::$yyTraceFILE = fopen('php://output', 'w');
  369. self::$yyTracePrompt = '';
  370. }
  371. /**
  372. * @var resource|0
  373. */
  374. static public $yyTraceFILE;
  375. /**
  376. * String to prepend to debug output
  377. * @var string|0
  378. */
  379. static public $yyTracePrompt;
  380. /**
  381. * @var int
  382. */
  383. public $yyidx; /* Index of top element in stack */
  384. /**
  385. * @var int
  386. */
  387. public $yyerrcnt; /* Shifts left before out of the error */
  388. /**
  389. * @var array
  390. */
  391. public $yystack = array(); /* The parser's stack */
  392. /**
  393. * For tracing shifts, the names of all terminals and nonterminals
  394. * are required. The following table supplies these names
  395. * @var array
  396. */
  397. static public $yyTokenName = array(
  398. '$', 'SEMICOLON', 'NAME', 'PAR_OPEN',
  399. 'PAR_CLOSE', 'VOID', 'AMPERSAND', 'BOOL',
  400. 'INT', 'FLOAT', 'STRING', 'ARRAY_',
  401. 'CLASS_', 'RESOURCE', 'MIXED', 'CALLBACK',
  402. 'STREAM', 'SQUARE_OPEN', 'SQUARE_CLOSE', 'ELLIPSE',
  403. 'COMMA', 'EQ', 'TRUE_', 'FALSE_',
  404. 'NULL_', 'NUMVAL', 'STRVAL', 'error',
  405. 'proto_line', 'proto', 'rettype', 'param_spec',
  406. 'typespec', 'typename', 'param_list', 'param',
  407. 'optional_params', 'default',
  408. );
  409. /**
  410. * For tracing reduce actions, the names of all rules are required.
  411. * @var array
  412. */
  413. static public $yyRuleName = array(
  414. /* 0 */ "proto_line ::= proto",
  415. /* 1 */ "proto_line ::= proto SEMICOLON",
  416. /* 2 */ "proto ::= rettype NAME PAR_OPEN param_spec PAR_CLOSE",
  417. /* 3 */ "rettype ::= VOID",
  418. /* 4 */ "rettype ::= typespec",
  419. /* 5 */ "typespec ::= typename",
  420. /* 6 */ "typespec ::= typename AMPERSAND",
  421. /* 7 */ "typename ::= BOOL",
  422. /* 8 */ "typename ::= INT",
  423. /* 9 */ "typename ::= FLOAT",
  424. /* 10 */ "typename ::= STRING",
  425. /* 11 */ "typename ::= ARRAY_",
  426. /* 12 */ "typename ::= CLASS_ NAME",
  427. /* 13 */ "typename ::= RESOURCE NAME",
  428. /* 14 */ "typename ::= MIXED",
  429. /* 15 */ "typename ::= CALLBACK",
  430. /* 16 */ "typename ::= STREAM",
  431. /* 17 */ "param_spec ::= param_list",
  432. /* 18 */ "param_spec ::= SQUARE_OPEN param SQUARE_CLOSE",
  433. /* 19 */ "param_spec ::= SQUARE_OPEN param optional_params SQUARE_CLOSE",
  434. /* 20 */ "param_spec ::= ELLIPSE",
  435. /* 21 */ "param_spec ::= typename ELLIPSE",
  436. /* 22 */ "param_spec ::= VOID",
  437. /* 23 */ "param_spec ::=",
  438. /* 24 */ "param_list ::= param_list COMMA ELLIPSE",
  439. /* 25 */ "param_list ::= param_list COMMA typename ELLIPSE",
  440. /* 26 */ "param_list ::= param_list COMMA param",
  441. /* 27 */ "param_list ::= param_list optional_params",
  442. /* 28 */ "param_list ::= param",
  443. /* 29 */ "optional_params ::= SQUARE_OPEN COMMA param SQUARE_CLOSE",
  444. /* 30 */ "optional_params ::= SQUARE_OPEN COMMA param optional_params SQUARE_CLOSE",
  445. /* 31 */ "param ::= typespec NAME",
  446. /* 32 */ "param ::= typespec NAME EQ default",
  447. /* 33 */ "default ::= TRUE_",
  448. /* 34 */ "default ::= FALSE_",
  449. /* 35 */ "default ::= NULL_",
  450. /* 36 */ "default ::= NUMVAL",
  451. /* 37 */ "default ::= STRVAL",
  452. /* 38 */ "default ::= ARRAY_ PAR_OPEN PAR_CLOSE",
  453. /* 39 */ "default ::= NAME",
  454. );
  455. /**
  456. * This function returns the symbolic name associated with a token
  457. * value.
  458. * @param int
  459. * @return string
  460. */
  461. function tokenName($tokenType)
  462. {
  463. if ($tokenType === 0) {
  464. return 'End of Input';
  465. }
  466. if ($tokenType > 0 && $tokenType < count(self::$yyTokenName)) {
  467. return self::$yyTokenName[$tokenType];
  468. } else {
  469. return "Unknown";
  470. }
  471. }
  472. /**
  473. * The following function deletes the value associated with a
  474. * symbol. The symbol can be either a terminal or nonterminal.
  475. * @param int the symbol code
  476. * @param mixed the symbol's value
  477. */
  478. static function yy_destructor($yymajor, $yypminor)
  479. {
  480. switch ($yymajor) {
  481. /* Here is inserted the actions which take place when a
  482. ** terminal or non-terminal is destroyed. This can happen
  483. ** when the symbol is popped from the stack during a
  484. ** reduce or during error processing or when a parser is
  485. ** being destroyed before it is finished parsing.
  486. **
  487. ** Note: during a reduce, the only symbols destroyed are those
  488. ** which appear on the RHS of the rule, but which are not used
  489. ** inside the C code.
  490. */
  491. default: break; /* If no destructor action specified: do nothing */
  492. }
  493. }
  494. /**
  495. * Pop the parser's stack once.
  496. *
  497. * If there is a destructor routine associated with the token which
  498. * is popped from the stack, then call it.
  499. *
  500. * Return the major token number for the symbol popped.
  501. * @param CodeGen_PECL_Tools_ProtoParser_yyParser
  502. * @return int
  503. */
  504. function yy_pop_parser_stack()
  505. {
  506. if (!count($this->yystack)) {
  507. return;
  508. }
  509. $yytos = array_pop($this->yystack);
  510. if (self::$yyTraceFILE && $this->yyidx >= 0) {
  511. fwrite(self::$yyTraceFILE,
  512. self::$yyTracePrompt . 'Popping ' . self::$yyTokenName[$yytos->major] .
  513. "\n");
  514. }
  515. $yymajor = $yytos->major;
  516. self::yy_destructor($yymajor, $yytos->minor);
  517. $this->yyidx--;
  518. return $yymajor;
  519. }
  520. /**
  521. * Deallocate and destroy a parser. Destructors are all called for
  522. * all stack elements before shutting the parser down.
  523. */
  524. function __destruct()
  525. {
  526. while ($this->yyidx >= 0) {
  527. $this->yy_pop_parser_stack();
  528. }
  529. if (is_resource(self::$yyTraceFILE)) {
  530. fclose(self::$yyTraceFILE);
  531. }
  532. }
  533. /**
  534. * Based on the current state and parser stack, get a list of all
  535. * possible lookahead tokens
  536. * @param int
  537. * @return array
  538. */
  539. function yy_get_expected_tokens($token)
  540. {
  541. $state = $this->yystack[$this->yyidx]->stateno;
  542. $expected = self::$yyExpectedTokens[$state];
  543. if (in_array($token, self::$yyExpectedTokens[$state], true)) {
  544. return $expected;
  545. }
  546. $stack = $this->yystack;
  547. $yyidx = $this->yyidx;
  548. do {
  549. $yyact = $this->yy_find_shift_action($token);
  550. if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
  551. // reduce action
  552. $done = 0;
  553. do {
  554. if ($done++ == 100) {
  555. $this->yyidx = $yyidx;
  556. $this->yystack = $stack;
  557. // too much recursion prevents proper detection
  558. // so give up
  559. return array_unique($expected);
  560. }
  561. $yyruleno = $yyact - self::YYNSTATE;
  562. $this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs'];
  563. $nextstate = $this->yy_find_reduce_action(
  564. $this->yystack[$this->yyidx]->stateno,
  565. self::$yyRuleInfo[$yyruleno]['lhs']);
  566. if (isset(self::$yyExpectedTokens[$nextstate])) {
  567. $expected += self::$yyExpectedTokens[$nextstate];
  568. if (in_array($token,
  569. self::$yyExpectedTokens[$nextstate], true)) {
  570. $this->yyidx = $yyidx;
  571. $this->yystack = $stack;
  572. return array_unique($expected);
  573. }
  574. }
  575. if ($nextstate < self::YYNSTATE) {
  576. // we need to shift a non-terminal
  577. $this->yyidx++;
  578. $x = new CodeGen_PECL_Tools_ProtoParser_yyStackEntry;
  579. $x->stateno = $nextstate;
  580. $x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
  581. $this->yystack[$this->yyidx] = $x;
  582. continue 2;
  583. } elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
  584. $this->yyidx = $yyidx;
  585. $this->yystack = $stack;
  586. // the last token was just ignored, we can't accept
  587. // by ignoring input, this is in essence ignoring a
  588. // syntax error!
  589. return array_unique($expected);
  590. } elseif ($nextstate === self::YY_NO_ACTION) {
  591. $this->yyidx = $yyidx;
  592. $this->yystack = $stack;
  593. // input accepted, but not shifted (I guess)
  594. return $expected;
  595. } else {
  596. $yyact = $nextstate;
  597. }
  598. } while (true);
  599. }
  600. break;
  601. } while (true);
  602. return array_unique($expected);
  603. }
  604. /**
  605. * Based on the parser state and current parser stack, determine whether
  606. * the lookahead token is possible.
  607. *
  608. * The parser will convert the token value to an error token if not. This
  609. * catches some unusual edge cases where the parser would fail.
  610. * @param int
  611. * @return bool
  612. */
  613. function yy_is_expected_token($token)
  614. {
  615. if ($token === 0) {
  616. return true; // 0 is not part of this
  617. }
  618. $state = $this->yystack[$this->yyidx]->stateno;
  619. if (in_array($token, self::$yyExpectedTokens[$state], true)) {
  620. return true;
  621. }
  622. $stack = $this->yystack;
  623. $yyidx = $this->yyidx;
  624. do {
  625. $yyact = $this->yy_find_shift_action($token);
  626. if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) {
  627. // reduce action
  628. $done = 0;
  629. do {
  630. if ($done++ == 100) {
  631. $this->yyidx = $yyidx;
  632. $this->yystack = $stack;
  633. // too much recursion prevents proper detection
  634. // so give up
  635. return true;
  636. }
  637. $yyruleno = $yyact - self::YYNSTATE;
  638. $this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs'];
  639. $nextstate = $this->yy_find_reduce_action(
  640. $this->yystack[$this->yyidx]->stateno,
  641. self::$yyRuleInfo[$yyruleno]['lhs']);
  642. if (isset(self::$yyExpectedTokens[$nextstate]) &&
  643. in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
  644. $this->yyidx = $yyidx;
  645. $this->yystack = $stack;
  646. return true;
  647. }
  648. if ($nextstate < self::YYNSTATE) {
  649. // we need to shift a non-terminal
  650. $this->yyidx++;
  651. $x = new CodeGen_PECL_Tools_ProtoParser_yyStackEntry;
  652. $x->stateno = $nextstate;
  653. $x->major = self::$yyRuleInfo[$yyruleno]['lhs'];
  654. $this->yystack[$this->yyidx] = $x;
  655. continue 2;
  656. } elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) {
  657. $this->yyidx = $yyidx;
  658. $this->yystack = $stack;
  659. if (!$token) {
  660. // end of input: this is valid
  661. return true;
  662. }
  663. // the last token was just ignored, we can't accept
  664. // by ignoring input, this is in essence ignoring a
  665. // syntax error!
  666. return false;
  667. } elseif ($nextstate === self::YY_NO_ACTION) {
  668. $this->yyidx = $yyidx;
  669. $this->yystack = $stack;
  670. // input accepted, but not shifted (I guess)
  671. return true;
  672. } else {
  673. $yyact = $nextstate;
  674. }
  675. } while (true);
  676. }
  677. break;
  678. } while (true);
  679. $this->yyidx = $yyidx;
  680. $this->yystack = $stack;
  681. return true;
  682. }
  683. /**
  684. * Find the appropriate action for a parser given the terminal
  685. * look-ahead token iLookAhead.
  686. *
  687. * If the look-ahead token is YYNOCODE, then check to see if the action is
  688. * independent of the look-ahead. If it is, return the action, otherwise
  689. * return YY_NO_ACTION.
  690. * @param int The look-ahead token
  691. */
  692. function yy_find_shift_action($iLookAhead)
  693. {
  694. $stateno = $this->yystack[$this->yyidx]->stateno;
  695. /* if ($this->yyidx < 0) return self::YY_NO_ACTION; */
  696. if (!isset(self::$yy_shift_ofst[$stateno])) {
  697. // no shift actions
  698. return self::$yy_default[$stateno];
  699. }
  700. $i = self::$yy_shift_ofst[$stateno];
  701. if ($i === self::YY_SHIFT_USE_DFLT) {
  702. return self::$yy_default[$stateno];
  703. }
  704. if ($iLookAhead == self::YYNOCODE) {
  705. return self::YY_NO_ACTION;
  706. }
  707. $i += $iLookAhead;
  708. if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
  709. self::$yy_lookahead[$i] != $iLookAhead) {
  710. if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
  711. && ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
  712. if (self::$yyTraceFILE) {
  713. fwrite(self::$yyTraceFILE, self::$yyTracePrompt . "FALLBACK " .
  714. self::$yyTokenName[$iLookAhead] . " => " .
  715. self::$yyTokenName[$iFallback] . "\n");
  716. }
  717. return $this->yy_find_shift_action($iFallback);
  718. }
  719. return self::$yy_default[$stateno];
  720. } else {
  721. return self::$yy_action[$i];
  722. }
  723. }
  724. /**
  725. * Find the appropriate action for a parser given the non-terminal
  726. * look-ahead token $iLookAhead.
  727. *
  728. * If the look-ahead token is self::YYNOCODE, then check to see if the action is
  729. * independent of the look-ahead. If it is, return the action, otherwise
  730. * return self::YY_NO_ACTION.
  731. * @param int Current state number
  732. * @param int The look-ahead token
  733. */
  734. function yy_find_reduce_action($stateno, $iLookAhead)
  735. {
  736. /* $stateno = $this->yystack[$this->yyidx]->stateno; */
  737. if (!isset(self::$yy_reduce_ofst[$stateno])) {
  738. return self::$yy_default[$stateno];
  739. }
  740. $i = self::$yy_reduce_ofst[$stateno];
  741. if ($i == self::YY_REDUCE_USE_DFLT) {
  742. return self::$yy_default[$stateno];
  743. }
  744. if ($iLookAhead == self::YYNOCODE) {
  745. return self::YY_NO_ACTION;
  746. }
  747. $i += $iLookAhead;
  748. if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
  749. self::$yy_lookahead[$i] != $iLookAhead) {
  750. return self::$yy_default[$stateno];
  751. } else {
  752. return self::$yy_action[$i];
  753. }
  754. }
  755. /**
  756. * Perform a shift action.
  757. * @param int The new state to shift in
  758. * @param int The major token to shift in
  759. * @param mixed the minor token to shift in
  760. */
  761. function yy_shift($yyNewState, $yyMajor, $yypMinor)
  762. {
  763. $this->yyidx++;
  764. if ($this->yyidx >= self::YYSTACKDEPTH) {
  765. $this->yyidx--;
  766. if (self::$yyTraceFILE) {
  767. fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt);
  768. }
  769. while ($this->yyidx >= 0) {
  770. $this->yy_pop_parser_stack();
  771. }
  772. /* Here code is inserted which will execute if the parser
  773. ** stack ever overflows */
  774. return;
  775. }
  776. $yytos = new CodeGen_PECL_Tools_ProtoParser_yyStackEntry;
  777. $yytos->stateno = $yyNewState;
  778. $yytos->major = $yyMajor;
  779. $yytos->minor = $yypMinor;
  780. array_push($this->yystack, $yytos);
  781. if (self::$yyTraceFILE && $this->yyidx > 0) {
  782. fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt,
  783. $yyNewState);
  784. fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt);
  785. for($i = 1; $i <= $this->yyidx; $i++) {
  786. fprintf(self::$yyTraceFILE, " %s",
  787. self::$yyTokenName[$this->yystack[$i]->major]);
  788. }
  789. fwrite(self::$yyTraceFILE,"\n");
  790. }
  791. }
  792. /**
  793. * The following table contains information about every rule that
  794. * is used during the reduce.
  795. *
  796. * <pre>
  797. * array(
  798. * array(
  799. * int $lhs; Symbol on the left-hand side of the rule
  800. * int $nrhs; Number of right-hand side symbols in the rule
  801. * ),...
  802. * );
  803. * </pre>
  804. */
  805. static public $yyRuleInfo = array(
  806. array( 'lhs' => 28, 'rhs' => 1 ),
  807. array( 'lhs' => 28, 'rhs' => 2 ),
  808. array( 'lhs' => 29, 'rhs' => 5 ),
  809. array( 'lhs' => 30, 'rhs' => 1 ),
  810. array( 'lhs' => 30, 'rhs' => 1 ),
  811. array( 'lhs' => 32, 'rhs' => 1 ),
  812. array( 'lhs' => 32, 'rhs' => 2 ),
  813. array( 'lhs' => 33, 'rhs' => 1 ),
  814. array( 'lhs' => 33, 'rhs' => 1 ),
  815. array( 'lhs' => 33, 'rhs' => 1 ),
  816. array( 'lhs' => 33, 'rhs' => 1 ),
  817. array( 'lhs' => 33, 'rhs' => 1 ),
  818. array( 'lhs' => 33, 'rhs' => 2 ),
  819. array( 'lhs' => 33, 'rhs' => 2 ),
  820. array( 'lhs' => 33, 'rhs' => 1 ),
  821. array( 'lhs' => 33, 'rhs' => 1 ),
  822. array( 'lhs' => 33, 'rhs' => 1 ),
  823. array( 'lhs' => 31, 'rhs' => 1 ),
  824. array( 'lhs' => 31, 'rhs' => 3 ),
  825. array( 'lhs' => 31, 'rhs' => 4 ),
  826. array( 'lhs' => 31, 'rhs' => 1 ),
  827. array( 'lhs' => 31, 'rhs' => 2 ),
  828. array( 'lhs' => 31, 'rhs' => 1 ),
  829. array( 'lhs' => 31, 'rhs' => 0 ),
  830. array( 'lhs' => 34, 'rhs' => 3 ),
  831. array( 'lhs' => 34, 'rhs' => 4 ),
  832. array( 'lhs' => 34, 'rhs' => 3 ),
  833. array( 'lhs' => 34, 'rhs' => 2 ),
  834. array( 'lhs' => 34, 'rhs' => 1 ),
  835. array( 'lhs' => 36, 'rhs' => 4 ),
  836. array( 'lhs' => 36, 'rhs' => 5 ),
  837. array( 'lhs' => 35, 'rhs' => 2 ),
  838. array( 'lhs' => 35, 'rhs' => 4 ),
  839. array( 'lhs' => 37, 'rhs' => 1 ),
  840. array( 'lhs' => 37, 'rhs' => 1 ),
  841. array( 'lhs' => 37, 'rhs' => 1 ),
  842. array( 'lhs' => 37, 'rhs' => 1 ),
  843. array( 'lhs' => 37, 'rhs' => 1 ),
  844. array( 'lhs' => 37, 'rhs' => 3 ),
  845. array( 'lhs' => 37, 'rhs' => 1 ),
  846. );
  847. /**
  848. * The following table contains a mapping of reduce action to method name
  849. * that handles the reduction.
  850. *
  851. * If a rule is not set, it has no handler.
  852. */
  853. static public $yyReduceMap = array(
  854. 2 => 2,
  855. 3 => 3,
  856. 4 => 4,
  857. 5 => 4,
  858. 36 => 4,
  859. 6 => 6,
  860. 7 => 7,
  861. 8 => 8,
  862. 9 => 9,
  863. 10 => 10,
  864. 11 => 11,
  865. 12 => 12,
  866. 13 => 13,
  867. 14 => 14,
  868. 15 => 15,
  869. 16 => 16,
  870. 18 => 18,
  871. 19 => 19,
  872. 20 => 20,
  873. 21 => 21,
  874. 24 => 24,
  875. 25 => 25,
  876. 26 => 26,
  877. 28 => 26,
  878. 27 => 27,
  879. 29 => 29,
  880. 30 => 30,
  881. 31 => 31,
  882. 32 => 32,
  883. 33 => 33,
  884. 34 => 34,
  885. 35 => 35,
  886. 37 => 37,
  887. 38 => 38,
  888. 39 => 39,
  889. );
  890. /* Beginning here are the reduction cases. A typical example
  891. ** follows:
  892. ** #line <lineno> <grammarfile>
  893. ** function yy_r0($yymsp){ ... } // User supplied code
  894. ** #line <lineno> <thisfile>
  895. */
  896. #line 27 "ProtoParser.y"
  897. function yy_r2(){
  898. $this->function->setReturns($this->yystack[$this->yyidx + -4]->minor);
  899. $this->function->setName($this->yystack[$this->yyidx + -3]->minor);
  900. }
  901. #line 937 "ProtoParser.php"
  902. #line 32 "ProtoParser.y"
  903. function yy_r3(){ $this->_retvalue = array("type" => "void"); }
  904. #line 940 "ProtoParser.php"
  905. #line 33 "ProtoParser.y"
  906. function yy_r4(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
  907. #line 943 "ProtoParser.php"
  908. #line 36 "ProtoParser.y"
  909. function yy_r6(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; $this->_retvalue["byRef"] = true; }
  910. #line 946 "ProtoParser.php"
  911. #line 38 "ProtoParser.y"
  912. function yy_r7(){ $this->_retvalue = array("type" => "bool"); }
  913. #line 949 "ProtoParser.php"
  914. #line 39 "ProtoParser.y"
  915. function yy_r8(){ $this->_retvalue = array("type" => "int"); }
  916. #line 952 "ProtoParser.php"
  917. #line 40 "ProtoParser.y"
  918. function yy_r9(){ $this->_retvalue = array("type" => "float"); }
  919. #line 955 "ProtoParser.php"
  920. #line 41 "ProtoParser.y"
  921. function yy_r10(){ $this->_retvalue = array("type" => "string"); }
  922. #line 958 "ProtoParser.php"
  923. #line 42 "ProtoParser.y"
  924. function yy_r11(){ $this->_retvalue = array("type" => "array"); }
  925. #line 961 "ProtoParser.php"
  926. #line 43 "ProtoParser.y"
  927. function yy_r12(){ $this->_retvalue = array("type" => "object", "subtype" => $this->yystack[$this->yyidx + 0]->minor); }
  928. #line 964 "ProtoParser.php"
  929. #line 44 "ProtoParser.y"
  930. function yy_r13(){ $this->_retvalue = array("type" => "resource", "subtype" => $this->yystack[$this->yyidx + 0]->minor); }
  931. #line 967 "ProtoParser.php"
  932. #line 45 "ProtoParser.y"
  933. function yy_r14(){ $this->_retvalue = array("type" => "mixed"); }
  934. #line 970 "ProtoParser.php"
  935. #line 46 "ProtoParser.y"
  936. function yy_r15(){ $this->_retvalue = array("type" => "callback"); }
  937. #line 973 "ProtoParser.php"
  938. #line 47 "ProtoParser.y"
  939. function yy_r16(){ $this->_retvalue = array("type" => "stream"); }
  940. #line 976 "ProtoParser.php"
  941. #line 50 "ProtoParser.y"
  942. function yy_r18(){
  943. $this->yystack[$this->yyidx + -1]->minor["optional"] = true;
  944. $stat = $this->function->addParam($this->yystack[$this->yyidx + -1]->minor);
  945. if ($stat !== true) {
  946. throw new Exception($stat->getMessage());
  947. }
  948. }
  949. #line 985 "ProtoParser.php"
  950. #line 57 "ProtoParser.y"
  951. function yy_r19(){
  952. $this->yystack[$this->yyidx + -2]->minor["optional"] = true;
  953. $stat = $this->function->addParam($this->yystack[$this->yyidx + -2]->minor);
  954. if ($stat !== true) {
  955. throw new Exception($stat->getMessage());
  956. }
  957. foreach ($this->optParams as $param) {
  958. $stat = $this->function->addParam($param);
  959. if ($stat !== true) {
  960. throw new Exception($stat->getMessage());
  961. }
  962. }
  963. }
  964. #line 1000 "ProtoParser.php"
  965. #line 70 "ProtoParser.y"
  966. function yy_r20(){
  967. $this->function->setVarargs(true);
  968. }
  969. #line 1005 "ProtoParser.php"
  970. #line 73 "ProtoParser.y"
  971. function yy_r21(){
  972. $stat = $this->function->setVarargsType($this->yystack[$this->yyidx + -1]->minor["type"]);
  973. if ($stat !== true) {
  974. throw new Exception($stat->getMessage());
  975. }
  976. $this->function->setVarargs(true);
  977. }
  978. #line 1014 "ProtoParser.php"
  979. #line 83 "ProtoParser.y"
  980. function yy_r24(){
  981. $this->function->setVarargs(true);
  982. }
  983. #line 1019 "ProtoParser.php"
  984. #line 86 "ProtoParser.y"
  985. function yy_r25(){
  986. $stat = $this->function->setVarargsType($this->yystack[$this->yyidx + -1]->minor["type"]);
  987. if ($stat !== true) {
  988. throw new Exception($stat->getMessage());
  989. }
  990. $this->function->setVarargs(true);
  991. }
  992. #line 1028 "ProtoParser.php"
  993. #line 93 "ProtoParser.y"
  994. function yy_r26(){
  995. $stat = $this->function->addParam($this->yystack[$this->yyidx + 0]->minor);
  996. if ($stat !== true) {
  997. throw new Exception($stat->getMessage());
  998. }
  999. }
  1000. #line 1036 "ProtoParser.php"
  1001. #line 99 "ProtoParser.y"
  1002. function yy_r27(){
  1003. foreach ($this->optParams as $param) {
  1004. $stat = $this->function->addParam($param);
  1005. if ($stat !== true) {
  1006. throw new Exception($stat->getMessage());
  1007. }
  1008. }
  1009. }
  1010. #line 1046 "ProtoParser.php"
  1011. #line 113 "ProtoParser.y"
  1012. function yy_r29(){
  1013. $this->yystack[$this->yyidx + -1]->minor["optional"] = true;
  1014. array_unshift($this->optParams, $this->yystack[$this->yyidx + -1]->minor);
  1015. }
  1016. #line 1052 "ProtoParser.php"
  1017. #line 117 "ProtoParser.y"
  1018. function yy_r30(){
  1019. $this->yystack[$this->yyidx + -2]->minor["optional"] = true;
  1020. array_unshift($this->optParams, $this->yystack[$this->yyidx + -2]->minor);
  1021. }
  1022. #line 1058 "ProtoParser.php"
  1023. #line 122 "ProtoParser.y"
  1024. function yy_r31(){
  1025. $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
  1026. $this->_retvalue["name"] = $this->yystack[$this->yyidx + 0]->minor;
  1027. }
  1028. #line 1064 "ProtoParser.php"
  1029. #line 126 "ProtoParser.y"
  1030. function yy_r32(){
  1031. $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor;
  1032. $this->_retvalue["name"] = $this->yystack[$this->yyidx + -2]->minor;
  1033. $this->_retvalue["default"] = $this->yystack[$this->yyidx + 0]->minor;
  1034. $this->_retvalue["optional"] = true;
  1035. }
  1036. #line 1072 "ProtoParser.php"
  1037. #line 133 "ProtoParser.y"
  1038. function yy_r33(){ $this->_retvalue = "true"; }
  1039. #line 1075 "ProtoParser.php"
  1040. #line 134 "ProtoParser.y"
  1041. function yy_r34(){ $this->_retvalue = "false"; }
  1042. #line 1078 "ProtoParser.php"
  1043. #line 135 "ProtoParser.y"
  1044. function yy_r35(){ $this->_retvalue = "null"; }
  1045. #line 1081 "ProtoParser.php"
  1046. #line 137 "ProtoParser.y"
  1047. function yy_r37(){ $this->_retvalue = '"'.$this->yystack[$this->yyidx + 0]->minor.'"'; }
  1048. #line 1084 "ProtoParser.php"
  1049. #line 138 "ProtoParser.y"
  1050. function yy_r38(){ $this->_retvalue = "array()"; }
  1051. #line 1087 "ProtoParser.php"
  1052. #line 139 "ProtoParser.y"
  1053. function yy_r39(){
  1054. $constant = $this->extension->getConstant($this->yystack[$this->yyidx + 0]->minor);
  1055. if ($constant) {
  1056. $this->_retvalue = $constant;
  1057. } else {
  1058. throw new Exception("invalid default value '".$this->yystack[$this->yyidx + 0]->minor."'");
  1059. }
  1060. }
  1061. #line 1097 "ProtoParser.php"
  1062. /**
  1063. * placeholder for the left hand side in a reduce operation.
  1064. *
  1065. * For a parser with a rule like this:
  1066. * <pre>
  1067. * rule(A) ::= B. { A = 1; }
  1068. * </pre>
  1069. *
  1070. * The parser will translate to something like:
  1071. *
  1072. * <code>
  1073. * function yy_r0(){$this->_retvalue = 1;}
  1074. * </code>
  1075. */
  1076. private $_retvalue;
  1077. /**
  1078. * Perform a reduce action and the shift that must immediately
  1079. * follow the reduce.
  1080. *
  1081. * For a rule such as:
  1082. *
  1083. * <pre>
  1084. * A ::= B blah C. { dosomething(); }
  1085. * </pre>
  1086. *
  1087. * This function will first call the action, if any, ("dosomething();" in our
  1088. * example), and then it will pop three states from the stack,
  1089. * one for each entry on the right-hand side of the expression
  1090. * (B, blah, and C in our example rule), and then push the result of the action
  1091. * back on to the stack with the resulting state reduced to (as described in the .out
  1092. * file)
  1093. * @param int Number of the rule by which to reduce
  1094. */
  1095. function yy_reduce($yyruleno)
  1096. {
  1097. //int $yygoto; /* The next state */
  1098. //int $yyact; /* The next action */
  1099. //mixed $yygotominor; /* The LHS of the rule reduced */
  1100. //CodeGen_PECL_Tools_ProtoParser_yyStackEntry $yymsp; /* The top of the parser's stack */
  1101. //int $yysize; /* Amount to pop the stack */
  1102. $yymsp = $this->yystack[$this->yyidx];
  1103. if (self::$yyTraceFILE && $yyruleno >= 0
  1104. && $yyruleno < count(self::$yyRuleName)) {
  1105. fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n",
  1106. self::$yyTracePrompt, $yyruleno,
  1107. self::$yyRuleName[$yyruleno]);
  1108. }
  1109. $this->_retvalue = $yy_lefthand_side = null;
  1110. if (array_key_exists($yyruleno, self::$yyReduceMap)) {
  1111. // call the action
  1112. $this->_retvalue = null;
  1113. $this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
  1114. $yy_lefthand_side = $this->_retvalue;
  1115. }
  1116. $yygoto = self::$yyRuleInfo[$yyruleno]['lhs'];
  1117. $yysize = self::$yyRuleInfo[$yyruleno]['rhs'];
  1118. $this->yyidx -= $yysize;
  1119. for($i = $yysize; $i; $i--) {
  1120. // pop all of the right-hand side parameters
  1121. array_pop($this->yystack);
  1122. }
  1123. $yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
  1124. if ($yyact < self::YYNSTATE) {
  1125. /* If we are not debugging and the reduce action popped at least
  1126. ** one element off the stack, then we can push the new element back
  1127. ** onto the stack here, and skip the stack overflow test in yy_shift().
  1128. ** That gives a significant speed improvement. */
  1129. if (!self::$yyTraceFILE && $yysize) {
  1130. $this->yyidx++;
  1131. $x = new CodeGen_PECL_Tools_ProtoParser_yyStackEntry;
  1132. $x->stateno = $yyact;
  1133. $x->major = $yygoto;
  1134. $x->minor = $yy_lefthand_side;
  1135. $this->yystack[$this->yyidx] = $x;
  1136. } else {
  1137. $this->yy_shift($yyact, $yygoto, $yy_lefthand_side);
  1138. }
  1139. } elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) {
  1140. $this->yy_accept();
  1141. }
  1142. }
  1143. /**
  1144. * The following code executes when the parse fails
  1145. *
  1146. * Code from %parse_fail is inserted here
  1147. */
  1148. function yy_parse_failed()
  1149. {
  1150. if (self::$yyTraceFILE) {
  1151. fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt);
  1152. }
  1153. while ($this->yyidx >= 0) {
  1154. $this->yy_pop_parser_stack();
  1155. }
  1156. /* Here code is inserted which will be executed whenever the
  1157. ** parser fails */
  1158. }
  1159. /**
  1160. * The following code executes when a syntax error first occurs.
  1161. *
  1162. * %syntax_error code is inserted here
  1163. * @param int The major type of the error token
  1164. * @param mixed The minor type of the error token
  1165. */
  1166. function yy_syntax_error($yymajor, $TOKEN)
  1167. {
  1168. #line 15 "ProtoParser.y"
  1169. $expect = array();
  1170. foreach ($this->yy_get_expected_tokens($yymajor) as $token) {
  1171. $expect[] = self::$yyTokenName[$token];
  1172. }
  1173. throw new Exception('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN
  1174. . '), expected one of: ' . implode(',', $expect));
  1175. #line 1218 "ProtoParser.php"
  1176. }
  1177. /**
  1178. * The following is executed when the parser accepts
  1179. *
  1180. * %parse_accept code is inserted here
  1181. */
  1182. function yy_accept()
  1183. {
  1184. if (self::$yyTraceFILE) {
  1185. fprintf(self::$yyTraceFILE, "%sAccept!\n", self::$yyTracePrompt);
  1186. }
  1187. while ($this->yyidx >= 0) {
  1188. $stack = $this->yy_pop_parser_stack();
  1189. }
  1190. /* Here code is inserted which will be executed whenever the
  1191. ** parser accepts */
  1192. }
  1193. /**
  1194. * The main parser program.
  1195. *
  1196. * The first argument is the major token number. The second is
  1197. * the token value string as scanned from the input.
  1198. *
  1199. * @param int the token number
  1200. * @param mixed the token value
  1201. * @param mixed any extra arguments that should be passed to handlers
  1202. */
  1203. function doParse($yymajor, $yytokenvalue)
  1204. {
  1205. // $yyact; /* The parser action. */
  1206. // $yyendofinput; /* True if we are at the end of input */
  1207. $yyerrorhit = 0; /* True if yymajor has invoked an error */
  1208. /* (re)initialize the parser, if necessary */
  1209. if ($this->yyidx === null || $this->yyidx < 0) {
  1210. /* if ($yymajor == 0) return; // not sure why this was here... */
  1211. $this->yyidx = 0;
  1212. $this->yyerrcnt = -1;
  1213. $x = new CodeGen_PECL_Tools_ProtoParser_yyStackEntry;
  1214. $x->stateno = 0;
  1215. $x->major = 0;
  1216. $this->yystack = array();
  1217. array_push($this->yystack, $x);
  1218. }
  1219. $yyendofinput = ($yymajor==0);
  1220. if (self::$yyTraceFILE) {
  1221. fprintf(self::$yyTraceFILE, "%sInput %s\n",
  1222. self::$yyTracePrompt, self::$yyTokenName[$yymajor]);
  1223. }
  1224. do {
  1225. $yyact = $this->yy_find_shift_action($yymajor);
  1226. if ($yymajor < self::YYERRORSYMBOL &&
  1227. !$this->yy_is_expected_token($yymajor)) {
  1228. // force a syntax error
  1229. $yyact = self::YY_ERROR_ACTION;
  1230. }
  1231. if ($yyact < self::YYNSTATE) {
  1232. $this->yy_shift($yyact, $yymajor, $yytokenvalue);
  1233. $this->yyerrcnt--;
  1234. if ($yyendofinput && $this->yyidx >= 0) {
  1235. $yymajor = 0;
  1236. } else {
  1237. $yymajor = self::YYNOCODE;
  1238. }
  1239. } elseif ($yyact < self::YYNSTATE + self::YYNRULE) {
  1240. $this->yy_reduce($yyact - self::YYNSTATE);
  1241. } elseif ($yyact == self::YY_ERROR_ACTION) {
  1242. if (self::$yyTraceFILE) {
  1243. fprintf(self::$yyTraceFILE, "%sSyntax Error!\n",
  1244. self::$yyTracePrompt);
  1245. }
  1246. if (self::YYERRORSYMBOL) {
  1247. /* A syntax error has occurred.
  1248. ** The response to an error depends upon whether or not the
  1249. ** grammar defines an error token "ERROR".
  1250. **
  1251. ** This is what we do if the grammar does define ERROR:
  1252. **
  1253. ** * Call the %syntax_error function.
  1254. **
  1255. ** * Begin popping the stack until we enter a state where
  1256. ** it is legal to shift the error symbol, then shift
  1257. ** the error symbol.
  1258. **
  1259. ** * Set the error count to three.
  1260. **
  1261. ** * Begin accepting and shifting new tokens. No new error
  1262. ** processing will occur until three tokens have been
  1263. ** shifted successfully.
  1264. **
  1265. */
  1266. if ($this->yyerrcnt < 0) {
  1267. $this->yy_syntax_error($yymajor, $yytokenvalue);
  1268. }
  1269. $yymx = $this->yystack[$this->yyidx]->major;
  1270. if ($yymx == self::YYERRORSYMBOL || $yyerrorhit ){
  1271. if (self::$yyTraceFILE) {
  1272. fprintf(self::$yyTraceFILE, "%sDiscard input token %s\n",
  1273. self::$yyTracePrompt, self::$yyTokenName[$yymajor]);
  1274. }
  1275. $this->yy_destructor($yymajor, $yytokenvalue);
  1276. $yymajor = self::YYNOCODE;
  1277. } else {
  1278. while ($this->yyidx >= 0 &&
  1279. $yymx != self::YYERRORSYMBOL &&
  1280. ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE
  1281. ){
  1282. $this->yy_pop_parser_stack();
  1283. }
  1284. if ($this->yyidx < 0 || $yymajor==0) {
  1285. $this->yy_destructor($yymajor, $yytokenvalue);
  1286. $this->yy_parse_failed();
  1287. $yymajor = self::YYNOCODE

Large files files are truncated, but you can click here to view the full file