CodeGen_PECL
[ class tree: CodeGen_PECL ] [ index: CodeGen_PECL ] [ all elements ]

Source for file ProtoParser.php

Documentation is available at ProtoParser.php

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

Documentation generated on Mon, 11 Mar 2019 14:44:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.