1<?php
2/* Driver template for the LEMON parser generator.
3** The author disclaims copyright to this source code.
4*/
5/** The following structure represents a single element of the
6 * parser's stack.  Information stored includes:
7 *
8 *   +  The state number for the parser at this level of the stack.
9 *
10 *   +  The value of the token stored at this level of the stack.
11 *      (In other words, the "major" token.)
12 *
13 *   +  The semantic value stored at this level of the stack.  This is
14 *      the information used by the action routines in the grammar.
15 *      It is sometimes called the "minor" token.
16 */
17class PHPyyStackEntry
18{
19    public $stateno;       /* The state-number */
20    public $major;         /* The major token value.  This is the code
21                     ** number for the token at this stack level */
22    public $minor; /* The user-supplied minor token value.  This
23                     ** is the value of the token  */
24};
25
26/**
27 * The state of the parser is completely contained in an instance of
28 * the following structure
29 */
30class PHPyyParser
31{
32/* First off, code is include which follows the "include" declaration
33** in the input file. */
34#line 3 "PHP.y"
35
36    static public $transTable = array();
37
38    function __construct()
39    {
40        if (!count(self::$transTable)) {
41            $start = 240; // start nice and low to be sure
42            while (token_name($start) == 'UNKNOWN') {
43                $start++;
44            }
45            $hash = array_flip(self::$yyTokenName);
46            $map =
47                array(
48                    ord(',') => self::COMMA,
49                    ord('=') => self::EQUALS,
50                    ord('?') => self::QUESTION,
51                    ord(':') => self::COLON,
52                    ord('|') => self::BAR,
53                    ord('^') => self::CARAT,
54                    ord('&') => self::AMPERSAND,
55                    ord('<') => self::LESSTHAN,
56                    ord('>') => self::GREATERTHAN,
57                    ord('+') => self::PLUS,
58                    ord('-') => self::MINUS,
59                    ord('.') => self::DOT,
60                    ord('*') => self::TIMES,
61                    ord('/') => self::DIVIDE,
62                    ord('%') => self::PERCENT,
63                    ord('!') => self::EXCLAM,
64                    ord('~') => self::TILDE,
65                    ord('@') => self::AT,
66                    ord('[') => self::LBRACKET,
67                    ord('(') => self::LPAREN,
68                    ord(')') => self::RPAREN,
69                    ord(';') => self::SEMI,
70                    ord('{') => self::LCURLY,
71                    ord('}') => self::RCURLY,
72                    ord('`') => self::BACKQUOTE,
73                    ord('$') => self::DOLLAR,
74                    ord(']') => self::RBRACKET,
75                    ord('"') => self::DOUBLEQUOTE,
76                    ord("'") => self::SINGLEQUOTE,
77                );
78            for ($i = $start; $i < self::YYERRORSYMBOL + $start; $i++) {
79                $lt = token_name($i);
80                if (!isset($hash[$lt])) {
81                    continue;
82                }
83                $lt = ($lt == 'T_ML_COMMENT') ? 'T_COMMENT' : $lt;
84                $lt = ($lt == 'T_DOUBLE_COLON') ?  'T_PAAMAYIM_NEKUDOTAYIM' : $lt;
85//                echo "$lt has hash? ".$hash[$lt]."\n";
86//                continue;
87
88                //echo "compare $lt with {$tokens[$i]}\n";
89                $map[$i] = $hash[$lt];
90            }
91            //print_r($map);
92            // set the map to false if nothing in there.
93            self::$transTable = $map;
94        }
95    }
96#line 98 "0"
97
98/* Next is all token values, in a form suitable for use by makeheaders.
99** This section will be null unless lemon is run with the -m switch.
100*/
101/*
102** These constants (all generated automatically by the parser generator)
103** specify the various kinds of tokens (terminals) that the parser
104** understands.
105**
106** Each symbol here is a terminal symbol in the grammar.
107*/
108    const T_INCLUDE                      =  1;
109    const T_INCLUDE_ONCE                 =  2;
110    const T_EVAL                         =  3;
111    const T_REQUIRE                      =  4;
112    const T_REQUIRE_ONCE                 =  5;
113    const COMMA                          =  6;
114    const T_LOGICAL_OR                   =  7;
115    const T_LOGICAL_XOR                  =  8;
116    const T_LOGICAL_AND                  =  9;
117    const T_PRINT                        = 10;
118    const EQUALS                         = 11;
119    const T_PLUS_EQUAL                   = 12;
120    const T_MINUS_EQUAL                  = 13;
121    const T_MUL_EQUAL                    = 14;
122    const T_DIV_EQUAL                    = 15;
123    const T_CONCAT_EQUAL                 = 16;
124    const T_MOD_EQUAL                    = 17;
125    const T_AND_EQUAL                    = 18;
126    const T_OR_EQUAL                     = 19;
127    const T_XOR_EQUAL                    = 20;
128    const T_SL_EQUAL                     = 21;
129    const T_SR_EQUAL                     = 22;
130    const QUESTION                       = 23;
131    const COLON                          = 24;
132    const T_BOOLEAN_OR                   = 25;
133    const T_BOOLEAN_AND                  = 26;
134    const BAR                            = 27;
135    const CARAT                          = 28;
136    const AMPERSAND                      = 29;
137    const T_IS_EQUAL                     = 30;
138    const T_IS_NOT_EQUAL                 = 31;
139    const T_IS_IDENTICAL                 = 32;
140    const T_IS_NOT_IDENTICAL             = 33;
141    const LESSTHAN                       = 34;
142    const T_IS_SMALLER_OR_EQUAL          = 35;
143    const GREATERTHAN                    = 36;
144    const T_IS_GREATER_OR_EQUAL          = 37;
145    const T_SL                           = 38;
146    const T_SR                           = 39;
147    const PLUS                           = 40;
148    const MINUS                          = 41;
149    const DOT                            = 42;
150    const TIMES                          = 43;
151    const DIVIDE                         = 44;
152    const PERCENT                        = 45;
153    const EXCLAM                         = 46;
154    const T_INSTANCEOF                   = 47;
155    const TILDE                          = 48;
156    const T_INC                          = 49;
157    const T_DEC                          = 50;
158    const T_INT_CAST                     = 51;
159    const T_DOUBLE_CAST                  = 52;
160    const T_STRING_CAST                  = 53;
161    const T_ARRAY_CAST                   = 54;
162    const T_OBJECT_CAST                  = 55;
163    const T_BOOL_CAST                    = 56;
164    const T_UNSET_CAST                   = 57;
165    const AT                             = 58;
166    const LBRACKET                       = 59;
167    const T_NEW                          = 60;
168    const T_CLONE                        = 61;
169    const T_ELSEIF                       = 62;
170    const T_ELSE                         = 63;
171    const T_ENDIF                        = 64;
172    const T_STATIC                       = 65;
173    const T_ABSTRACT                     = 66;
174    const T_FINAL                        = 67;
175    const T_PRIVATE                      = 68;
176    const T_PROTECTED                    = 69;
177    const T_PUBLIC                       = 70;
178    const T_HALT_COMPILER                = 71;
179    const LPAREN                         = 72;
180    const RPAREN                         = 73;
181    const SEMI                           = 74;
182    const LCURLY                         = 75;
183    const RCURLY                         = 76;
184    const T_IF                           = 77;
185    const T_WHILE                        = 78;
186    const T_DO                           = 79;
187    const T_FOR                          = 80;
188    const T_SWITCH                       = 81;
189    const T_BREAK                        = 82;
190    const T_CONTINUE                     = 83;
191    const T_RETURN                       = 84;
192    const T_GLOBAL                       = 85;
193    const T_ECHO                         = 86;
194    const T_INLINE_HTML                  = 87;
195    const T_USE                          = 88;
196    const T_UNSET                        = 89;
197    const T_FOREACH                      = 90;
198    const T_AS                           = 91;
199    const T_DECLARE                      = 92;
200    const T_TRY                          = 93;
201    const T_CATCH                        = 94;
202    const T_VARIABLE                     = 95;
203    const T_THROW                        = 96;
204    const T_FUNCTION                     = 97;
205    const T_STRING                       = 98;
206    const T_CLASS                        = 99;
207    const T_EXTENDS                      = 100;
208    const T_INTERFACE                    = 101;
209    const T_IMPLEMENTS                   = 102;
210    const T_LIST                         = 103;
211    const T_EXIT                         = 104;
212    const T_ARRAY                        = 105;
213    const BACKQUOTE                      = 106;
214    const T_LNUMBER                      = 107;
215    const T_DNUMBER                      = 108;
216    const T_CONSTANT_ENCAPSED_STRING     = 109;
217    const T_LINE                         = 110;
218    const T_FILE                         = 111;
219    const T_CLASS_C                      = 112;
220    const T_METHOD_C                     = 113;
221    const T_FUNC_C                       = 114;
222    const T_DOUBLE_ARROW                 = 115;
223    const T_PAAMAYIM_NEKUDOTAYIM         = 116;
224    const T_ENDFOR                       = 117;
225    const T_ENDFOREACH                   = 118;
226    const T_ENDDECLARE                   = 119;
227    const T_ENDSWITCH                    = 120;
228    const T_CASE                         = 121;
229    const T_DEFAULT                      = 122;
230    const T_ENDWHILE                     = 123;
231    const DOLLAR                         = 124;
232    const T_VAR                          = 125;
233    const T_CONST                        = 126;
234    const T_OBJECT_OPERATOR              = 127;
235    const RBRACKET                       = 128;
236    const T_NUM_STRING                   = 129;
237    const T_ENCAPSED_AND_WHITESPACE      = 130;
238    const T_CHARACTER                    = 131;
239    const T_BAD_CHARACTER                = 132;
240    const T_DOLLAR_OPEN_CURLY_BRACES     = 133;
241    const T_STRING_VARNAME               = 134;
242    const T_CURLY_OPEN                   = 135;
243    const T_ISSET                        = 136;
244    const T_EMPTY                        = 137;
245    const DOUBLEQUOTE                    = 138;
246    const SINGLEQUOTE                    = 139;
247    const T_START_HEREDOC                = 140;
248    const T_END_HEREDOC                  = 141;
249    const YY_NO_ACTION = 1040;
250    const YY_ACCEPT_ACTION = 1039;
251    const YY_ERROR_ACTION = 1038;
252
253/* Next are that tables used to determine what action to take based on the
254** current state and lookahead token.  These tables are used to implement
255** functions that take a state number and lookahead value and return an
256** action integer.
257**
258** Suppose the action integer is N.  Then the action is determined as
259** follows
260**
261**   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead
262**                                      token onto the stack and goto state N.
263**
264**   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.
265**
266**   N == YYNSTATE+YYNRULE              A syntax error has occurred.
267**
268**   N == YYNSTATE+YYNRULE+1            The parser accepts its input.
269**
270**   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused
271**                                      slots in the yy_action[] table.
272**
273** The action table is constructed as a single large table named yy_action[].
274** Given state S and lookahead X, the action is computed as
275**
276**      yy_action[ yy_shift_ofst[S] + X ]
277**
278** If the index value yy_shift_ofst[S]+X is out of range or if the value
279** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
280** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
281** and that yy_default[S] should be used instead.
282**
283** The formula above is for computing the action when the lookahead is
284** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
285** a reduce action) then the yy_reduce_ofst[] array is used in place of
286** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
287** YY_SHIFT_USE_DFLT.
288**
289** The following are the tables generated in this section:
290**
291**  yy_action[]        A single table containing all actions.
292**  yy_lookahead[]     A table containing the lookahead for each entry in
293**                     yy_action.  Used to detect hash collisions.
294**  yy_shift_ofst[]    For each state, the offset into yy_action for
295**                     shifting terminals.
296**  yy_reduce_ofst[]   For each state, the offset into yy_action for
297**                     shifting non-terminals after a reduce.
298**  yy_default[]       Default action for each state.
299*/
300