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