[345] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * Smarty Internal Plugin Configfilelexer |
---|
| 4 | * |
---|
| 5 | * This is the lexer to break the config file source into tokens |
---|
| 6 | * @package Smarty |
---|
| 7 | * @subpackage Config |
---|
| 8 | * @author Uwe Tews |
---|
| 9 | */ |
---|
| 10 | /** |
---|
| 11 | * Smarty Internal Plugin Configfilelexer |
---|
| 12 | */ |
---|
| 13 | class Smarty_Internal_Configfilelexer |
---|
| 14 | { |
---|
| 15 | |
---|
| 16 | public $data; |
---|
| 17 | public $counter; |
---|
| 18 | public $token; |
---|
| 19 | public $value; |
---|
| 20 | public $node; |
---|
| 21 | public $line; |
---|
| 22 | private $state = 1; |
---|
| 23 | public $smarty_token_names = array ( // Text for parser error messages |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | function __construct($data, $smarty) |
---|
| 28 | { |
---|
| 29 | // set instance object |
---|
| 30 | self::instance($this); |
---|
| 31 | $this->data = $data . "\n"; //now all lines are \n-terminated |
---|
| 32 | $this->counter = 0; |
---|
| 33 | $this->line = 1; |
---|
| 34 | $this->smarty = $smarty; |
---|
| 35 | $this->mbstring_overload = ini_get('mbstring.func_overload') & 2; |
---|
| 36 | } |
---|
| 37 | public static function &instance($new_instance = null) |
---|
| 38 | { |
---|
| 39 | static $instance = null; |
---|
| 40 | if (isset($new_instance) && is_object($new_instance)) |
---|
| 41 | $instance = $new_instance; |
---|
| 42 | return $instance; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | private $_yy_state = 1; |
---|
| 48 | private $_yy_stack = array(); |
---|
| 49 | |
---|
| 50 | function yylex() |
---|
| 51 | { |
---|
| 52 | return $this->{'yylex' . $this->_yy_state}(); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | function yypushstate($state) |
---|
| 56 | { |
---|
| 57 | array_push($this->_yy_stack, $this->_yy_state); |
---|
| 58 | $this->_yy_state = $state; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | function yypopstate() |
---|
| 62 | { |
---|
| 63 | $this->_yy_state = array_pop($this->_yy_stack); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | function yybegin($state) |
---|
| 67 | { |
---|
| 68 | $this->_yy_state = $state; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | function yylex1() |
---|
| 75 | { |
---|
| 76 | $tokenMap = array ( |
---|
| 77 | 1 => 0, |
---|
| 78 | 2 => 0, |
---|
| 79 | 3 => 0, |
---|
| 80 | 4 => 0, |
---|
| 81 | 5 => 0, |
---|
| 82 | 6 => 0, |
---|
| 83 | 7 => 0, |
---|
| 84 | 8 => 0, |
---|
| 85 | ); |
---|
| 86 | if ($this->counter >= strlen($this->data)) { |
---|
| 87 | return false; // end of input |
---|
| 88 | } |
---|
| 89 | $yy_global_pattern = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS"; |
---|
| 90 | |
---|
| 91 | do { |
---|
| 92 | if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { |
---|
| 93 | $yysubmatches = $yymatches; |
---|
| 94 | $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
---|
| 95 | if (!count($yymatches)) { |
---|
| 96 | throw new Exception('Error: lexing failed because a rule matched' . |
---|
| 97 | ' an empty string. Input "' . substr($this->data, |
---|
| 98 | $this->counter, 5) . '... state START'); |
---|
| 99 | } |
---|
| 100 | next($yymatches); // skip global match |
---|
| 101 | $this->token = key($yymatches); // token number |
---|
| 102 | if ($tokenMap[$this->token]) { |
---|
| 103 | // extract sub-patterns for passing to lex function |
---|
| 104 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, |
---|
| 105 | $tokenMap[$this->token]); |
---|
| 106 | } else { |
---|
| 107 | $yysubmatches = array(); |
---|
| 108 | } |
---|
| 109 | $this->value = current($yymatches); // token value |
---|
| 110 | $r = $this->{'yy_r1_' . $this->token}($yysubmatches); |
---|
| 111 | if ($r === null) { |
---|
| 112 | $this->counter += strlen($this->value); |
---|
| 113 | $this->line += substr_count($this->value, "\n"); |
---|
| 114 | // accept this token |
---|
| 115 | return true; |
---|
| 116 | } elseif ($r === true) { |
---|
| 117 | // we have changed state |
---|
| 118 | // process this token in the new state |
---|
| 119 | return $this->yylex(); |
---|
| 120 | } elseif ($r === false) { |
---|
| 121 | $this->counter += strlen($this->value); |
---|
| 122 | $this->line += substr_count($this->value, "\n"); |
---|
| 123 | if ($this->counter >= strlen($this->data)) { |
---|
| 124 | return false; // end of input |
---|
| 125 | } |
---|
| 126 | // skip this token |
---|
| 127 | continue; |
---|
| 128 | } } else { |
---|
| 129 | throw new Exception('Unexpected input at line' . $this->line . |
---|
| 130 | ': ' . $this->data[$this->counter]); |
---|
| 131 | } |
---|
| 132 | break; |
---|
| 133 | } while (true); |
---|
| 134 | |
---|
| 135 | } // end function |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | const START = 1; |
---|
| 139 | function yy_r1_1($yy_subpatterns) |
---|
| 140 | { |
---|
| 141 | |
---|
| 142 | $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART; |
---|
| 143 | $this->yypushstate(self::COMMENT); |
---|
| 144 | } |
---|
| 145 | function yy_r1_2($yy_subpatterns) |
---|
| 146 | { |
---|
| 147 | |
---|
| 148 | $this->token = Smarty_Internal_Configfileparser::TPC_OPENB; |
---|
| 149 | $this->yypushstate(self::SECTION); |
---|
| 150 | } |
---|
| 151 | function yy_r1_3($yy_subpatterns) |
---|
| 152 | { |
---|
| 153 | |
---|
| 154 | $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB; |
---|
| 155 | } |
---|
| 156 | function yy_r1_4($yy_subpatterns) |
---|
| 157 | { |
---|
| 158 | |
---|
| 159 | $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL; |
---|
| 160 | $this->yypushstate(self::VALUE); |
---|
| 161 | } |
---|
| 162 | function yy_r1_5($yy_subpatterns) |
---|
| 163 | { |
---|
| 164 | |
---|
| 165 | return false; |
---|
| 166 | } |
---|
| 167 | function yy_r1_6($yy_subpatterns) |
---|
| 168 | { |
---|
| 169 | |
---|
| 170 | $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; |
---|
| 171 | } |
---|
| 172 | function yy_r1_7($yy_subpatterns) |
---|
| 173 | { |
---|
| 174 | |
---|
| 175 | $this->token = Smarty_Internal_Configfileparser::TPC_ID; |
---|
| 176 | } |
---|
| 177 | function yy_r1_8($yy_subpatterns) |
---|
| 178 | { |
---|
| 179 | |
---|
| 180 | $this->token = Smarty_Internal_Configfileparser::TPC_OTHER; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | |
---|
| 185 | function yylex2() |
---|
| 186 | { |
---|
| 187 | $tokenMap = array ( |
---|
| 188 | 1 => 0, |
---|
| 189 | 2 => 0, |
---|
| 190 | 3 => 0, |
---|
| 191 | 4 => 0, |
---|
| 192 | 5 => 0, |
---|
| 193 | 6 => 0, |
---|
| 194 | 7 => 0, |
---|
| 195 | 8 => 0, |
---|
| 196 | 9 => 0, |
---|
| 197 | ); |
---|
| 198 | if ($this->counter >= strlen($this->data)) { |
---|
| 199 | return false; // end of input |
---|
| 200 | } |
---|
| 201 | $yy_global_pattern = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS"; |
---|
| 202 | |
---|
| 203 | do { |
---|
| 204 | if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { |
---|
| 205 | $yysubmatches = $yymatches; |
---|
| 206 | $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
---|
| 207 | if (!count($yymatches)) { |
---|
| 208 | throw new Exception('Error: lexing failed because a rule matched' . |
---|
| 209 | ' an empty string. Input "' . substr($this->data, |
---|
| 210 | $this->counter, 5) . '... state VALUE'); |
---|
| 211 | } |
---|
| 212 | next($yymatches); // skip global match |
---|
| 213 | $this->token = key($yymatches); // token number |
---|
| 214 | if ($tokenMap[$this->token]) { |
---|
| 215 | // extract sub-patterns for passing to lex function |
---|
| 216 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, |
---|
| 217 | $tokenMap[$this->token]); |
---|
| 218 | } else { |
---|
| 219 | $yysubmatches = array(); |
---|
| 220 | } |
---|
| 221 | $this->value = current($yymatches); // token value |
---|
| 222 | $r = $this->{'yy_r2_' . $this->token}($yysubmatches); |
---|
| 223 | if ($r === null) { |
---|
| 224 | $this->counter += strlen($this->value); |
---|
| 225 | $this->line += substr_count($this->value, "\n"); |
---|
| 226 | // accept this token |
---|
| 227 | return true; |
---|
| 228 | } elseif ($r === true) { |
---|
| 229 | // we have changed state |
---|
| 230 | // process this token in the new state |
---|
| 231 | return $this->yylex(); |
---|
| 232 | } elseif ($r === false) { |
---|
| 233 | $this->counter += strlen($this->value); |
---|
| 234 | $this->line += substr_count($this->value, "\n"); |
---|
| 235 | if ($this->counter >= strlen($this->data)) { |
---|
| 236 | return false; // end of input |
---|
| 237 | } |
---|
| 238 | // skip this token |
---|
| 239 | continue; |
---|
| 240 | } } else { |
---|
| 241 | throw new Exception('Unexpected input at line' . $this->line . |
---|
| 242 | ': ' . $this->data[$this->counter]); |
---|
| 243 | } |
---|
| 244 | break; |
---|
| 245 | } while (true); |
---|
| 246 | |
---|
| 247 | } // end function |
---|
| 248 | |
---|
| 249 | |
---|
| 250 | const VALUE = 2; |
---|
| 251 | function yy_r2_1($yy_subpatterns) |
---|
| 252 | { |
---|
| 253 | |
---|
| 254 | return false; |
---|
| 255 | } |
---|
| 256 | function yy_r2_2($yy_subpatterns) |
---|
| 257 | { |
---|
| 258 | |
---|
| 259 | $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT; |
---|
| 260 | $this->yypopstate(); |
---|
| 261 | } |
---|
| 262 | function yy_r2_3($yy_subpatterns) |
---|
| 263 | { |
---|
| 264 | |
---|
| 265 | $this->token = Smarty_Internal_Configfileparser::TPC_INT; |
---|
| 266 | $this->yypopstate(); |
---|
| 267 | } |
---|
| 268 | function yy_r2_4($yy_subpatterns) |
---|
| 269 | { |
---|
| 270 | |
---|
| 271 | $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES; |
---|
| 272 | $this->yypushstate(self::TRIPPLE); |
---|
| 273 | } |
---|
| 274 | function yy_r2_5($yy_subpatterns) |
---|
| 275 | { |
---|
| 276 | |
---|
| 277 | $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING; |
---|
| 278 | $this->yypopstate(); |
---|
| 279 | } |
---|
| 280 | function yy_r2_6($yy_subpatterns) |
---|
| 281 | { |
---|
| 282 | |
---|
| 283 | $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING; |
---|
| 284 | $this->yypopstate(); |
---|
| 285 | } |
---|
| 286 | function yy_r2_7($yy_subpatterns) |
---|
| 287 | { |
---|
| 288 | |
---|
| 289 | if (!$this->smarty->config_booleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no")) ) { |
---|
| 290 | $this->yypopstate(); |
---|
| 291 | $this->yypushstate(self::NAKED_STRING_VALUE); |
---|
| 292 | return true; //reprocess in new state |
---|
| 293 | } else { |
---|
| 294 | $this->token = Smarty_Internal_Configfileparser::TPC_BOOL; |
---|
| 295 | $this->yypopstate(); |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | function yy_r2_8($yy_subpatterns) |
---|
| 299 | { |
---|
| 300 | |
---|
| 301 | $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; |
---|
| 302 | $this->yypopstate(); |
---|
| 303 | } |
---|
| 304 | function yy_r2_9($yy_subpatterns) |
---|
| 305 | { |
---|
| 306 | |
---|
| 307 | $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; |
---|
| 308 | $this->value = ""; |
---|
| 309 | $this->yypopstate(); |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | function yylex3() |
---|
| 315 | { |
---|
| 316 | $tokenMap = array ( |
---|
| 317 | 1 => 0, |
---|
| 318 | ); |
---|
| 319 | if ($this->counter >= strlen($this->data)) { |
---|
| 320 | return false; // end of input |
---|
| 321 | } |
---|
| 322 | $yy_global_pattern = "/\G([^\n]+?(?=[ \t\r]*\n))/iS"; |
---|
| 323 | |
---|
| 324 | do { |
---|
| 325 | if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { |
---|
| 326 | $yysubmatches = $yymatches; |
---|
| 327 | $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
---|
| 328 | if (!count($yymatches)) { |
---|
| 329 | throw new Exception('Error: lexing failed because a rule matched' . |
---|
| 330 | ' an empty string. Input "' . substr($this->data, |
---|
| 331 | $this->counter, 5) . '... state NAKED_STRING_VALUE'); |
---|
| 332 | } |
---|
| 333 | next($yymatches); // skip global match |
---|
| 334 | $this->token = key($yymatches); // token number |
---|
| 335 | if ($tokenMap[$this->token]) { |
---|
| 336 | // extract sub-patterns for passing to lex function |
---|
| 337 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, |
---|
| 338 | $tokenMap[$this->token]); |
---|
| 339 | } else { |
---|
| 340 | $yysubmatches = array(); |
---|
| 341 | } |
---|
| 342 | $this->value = current($yymatches); // token value |
---|
| 343 | $r = $this->{'yy_r3_' . $this->token}($yysubmatches); |
---|
| 344 | if ($r === null) { |
---|
| 345 | $this->counter += strlen($this->value); |
---|
| 346 | $this->line += substr_count($this->value, "\n"); |
---|
| 347 | // accept this token |
---|
| 348 | return true; |
---|
| 349 | } elseif ($r === true) { |
---|
| 350 | // we have changed state |
---|
| 351 | // process this token in the new state |
---|
| 352 | return $this->yylex(); |
---|
| 353 | } elseif ($r === false) { |
---|
| 354 | $this->counter += strlen($this->value); |
---|
| 355 | $this->line += substr_count($this->value, "\n"); |
---|
| 356 | if ($this->counter >= strlen($this->data)) { |
---|
| 357 | return false; // end of input |
---|
| 358 | } |
---|
| 359 | // skip this token |
---|
| 360 | continue; |
---|
| 361 | } } else { |
---|
| 362 | throw new Exception('Unexpected input at line' . $this->line . |
---|
| 363 | ': ' . $this->data[$this->counter]); |
---|
| 364 | } |
---|
| 365 | break; |
---|
| 366 | } while (true); |
---|
| 367 | |
---|
| 368 | } // end function |
---|
| 369 | |
---|
| 370 | |
---|
| 371 | const NAKED_STRING_VALUE = 3; |
---|
| 372 | function yy_r3_1($yy_subpatterns) |
---|
| 373 | { |
---|
| 374 | |
---|
| 375 | $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; |
---|
| 376 | $this->yypopstate(); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | |
---|
| 381 | function yylex4() |
---|
| 382 | { |
---|
| 383 | $tokenMap = array ( |
---|
| 384 | 1 => 0, |
---|
| 385 | 2 => 0, |
---|
| 386 | 3 => 0, |
---|
| 387 | ); |
---|
| 388 | if ($this->counter >= strlen($this->data)) { |
---|
| 389 | return false; // end of input |
---|
| 390 | } |
---|
| 391 | $yy_global_pattern = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS"; |
---|
| 392 | |
---|
| 393 | do { |
---|
| 394 | if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { |
---|
| 395 | $yysubmatches = $yymatches; |
---|
| 396 | $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
---|
| 397 | if (!count($yymatches)) { |
---|
| 398 | throw new Exception('Error: lexing failed because a rule matched' . |
---|
| 399 | ' an empty string. Input "' . substr($this->data, |
---|
| 400 | $this->counter, 5) . '... state COMMENT'); |
---|
| 401 | } |
---|
| 402 | next($yymatches); // skip global match |
---|
| 403 | $this->token = key($yymatches); // token number |
---|
| 404 | if ($tokenMap[$this->token]) { |
---|
| 405 | // extract sub-patterns for passing to lex function |
---|
| 406 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, |
---|
| 407 | $tokenMap[$this->token]); |
---|
| 408 | } else { |
---|
| 409 | $yysubmatches = array(); |
---|
| 410 | } |
---|
| 411 | $this->value = current($yymatches); // token value |
---|
| 412 | $r = $this->{'yy_r4_' . $this->token}($yysubmatches); |
---|
| 413 | if ($r === null) { |
---|
| 414 | $this->counter += strlen($this->value); |
---|
| 415 | $this->line += substr_count($this->value, "\n"); |
---|
| 416 | // accept this token |
---|
| 417 | return true; |
---|
| 418 | } elseif ($r === true) { |
---|
| 419 | // we have changed state |
---|
| 420 | // process this token in the new state |
---|
| 421 | return $this->yylex(); |
---|
| 422 | } elseif ($r === false) { |
---|
| 423 | $this->counter += strlen($this->value); |
---|
| 424 | $this->line += substr_count($this->value, "\n"); |
---|
| 425 | if ($this->counter >= strlen($this->data)) { |
---|
| 426 | return false; // end of input |
---|
| 427 | } |
---|
| 428 | // skip this token |
---|
| 429 | continue; |
---|
| 430 | } } else { |
---|
| 431 | throw new Exception('Unexpected input at line' . $this->line . |
---|
| 432 | ': ' . $this->data[$this->counter]); |
---|
| 433 | } |
---|
| 434 | break; |
---|
| 435 | } while (true); |
---|
| 436 | |
---|
| 437 | } // end function |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | const COMMENT = 4; |
---|
| 441 | function yy_r4_1($yy_subpatterns) |
---|
| 442 | { |
---|
| 443 | |
---|
| 444 | return false; |
---|
| 445 | } |
---|
| 446 | function yy_r4_2($yy_subpatterns) |
---|
| 447 | { |
---|
| 448 | |
---|
| 449 | $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; |
---|
| 450 | } |
---|
| 451 | function yy_r4_3($yy_subpatterns) |
---|
| 452 | { |
---|
| 453 | |
---|
| 454 | $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; |
---|
| 455 | $this->yypopstate(); |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | |
---|
| 459 | |
---|
| 460 | function yylex5() |
---|
| 461 | { |
---|
| 462 | $tokenMap = array ( |
---|
| 463 | 1 => 0, |
---|
| 464 | 2 => 0, |
---|
| 465 | ); |
---|
| 466 | if ($this->counter >= strlen($this->data)) { |
---|
| 467 | return false; // end of input |
---|
| 468 | } |
---|
| 469 | $yy_global_pattern = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/iS"; |
---|
| 470 | |
---|
| 471 | do { |
---|
| 472 | if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { |
---|
| 473 | $yysubmatches = $yymatches; |
---|
| 474 | $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
---|
| 475 | if (!count($yymatches)) { |
---|
| 476 | throw new Exception('Error: lexing failed because a rule matched' . |
---|
| 477 | ' an empty string. Input "' . substr($this->data, |
---|
| 478 | $this->counter, 5) . '... state SECTION'); |
---|
| 479 | } |
---|
| 480 | next($yymatches); // skip global match |
---|
| 481 | $this->token = key($yymatches); // token number |
---|
| 482 | if ($tokenMap[$this->token]) { |
---|
| 483 | // extract sub-patterns for passing to lex function |
---|
| 484 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, |
---|
| 485 | $tokenMap[$this->token]); |
---|
| 486 | } else { |
---|
| 487 | $yysubmatches = array(); |
---|
| 488 | } |
---|
| 489 | $this->value = current($yymatches); // token value |
---|
| 490 | $r = $this->{'yy_r5_' . $this->token}($yysubmatches); |
---|
| 491 | if ($r === null) { |
---|
| 492 | $this->counter += strlen($this->value); |
---|
| 493 | $this->line += substr_count($this->value, "\n"); |
---|
| 494 | // accept this token |
---|
| 495 | return true; |
---|
| 496 | } elseif ($r === true) { |
---|
| 497 | // we have changed state |
---|
| 498 | // process this token in the new state |
---|
| 499 | return $this->yylex(); |
---|
| 500 | } elseif ($r === false) { |
---|
| 501 | $this->counter += strlen($this->value); |
---|
| 502 | $this->line += substr_count($this->value, "\n"); |
---|
| 503 | if ($this->counter >= strlen($this->data)) { |
---|
| 504 | return false; // end of input |
---|
| 505 | } |
---|
| 506 | // skip this token |
---|
| 507 | continue; |
---|
| 508 | } } else { |
---|
| 509 | throw new Exception('Unexpected input at line' . $this->line . |
---|
| 510 | ': ' . $this->data[$this->counter]); |
---|
| 511 | } |
---|
| 512 | break; |
---|
| 513 | } while (true); |
---|
| 514 | |
---|
| 515 | } // end function |
---|
| 516 | |
---|
| 517 | |
---|
| 518 | const SECTION = 5; |
---|
| 519 | function yy_r5_1($yy_subpatterns) |
---|
| 520 | { |
---|
| 521 | |
---|
| 522 | $this->token = Smarty_Internal_Configfileparser::TPC_DOT; |
---|
| 523 | } |
---|
| 524 | function yy_r5_2($yy_subpatterns) |
---|
| 525 | { |
---|
| 526 | |
---|
| 527 | $this->token = Smarty_Internal_Configfileparser::TPC_SECTION; |
---|
| 528 | $this->yypopstate(); |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | function yylex6() |
---|
| 533 | { |
---|
| 534 | $tokenMap = array ( |
---|
| 535 | 1 => 0, |
---|
| 536 | 2 => 0, |
---|
| 537 | ); |
---|
| 538 | if ($this->counter >= strlen($this->data)) { |
---|
| 539 | return false; // end of input |
---|
| 540 | } |
---|
| 541 | $yy_global_pattern = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS"; |
---|
| 542 | |
---|
| 543 | do { |
---|
| 544 | if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { |
---|
| 545 | $yysubmatches = $yymatches; |
---|
| 546 | $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
---|
| 547 | if (!count($yymatches)) { |
---|
| 548 | throw new Exception('Error: lexing failed because a rule matched' . |
---|
| 549 | ' an empty string. Input "' . substr($this->data, |
---|
| 550 | $this->counter, 5) . '... state TRIPPLE'); |
---|
| 551 | } |
---|
| 552 | next($yymatches); // skip global match |
---|
| 553 | $this->token = key($yymatches); // token number |
---|
| 554 | if ($tokenMap[$this->token]) { |
---|
| 555 | // extract sub-patterns for passing to lex function |
---|
| 556 | $yysubmatches = array_slice($yysubmatches, $this->token + 1, |
---|
| 557 | $tokenMap[$this->token]); |
---|
| 558 | } else { |
---|
| 559 | $yysubmatches = array(); |
---|
| 560 | } |
---|
| 561 | $this->value = current($yymatches); // token value |
---|
| 562 | $r = $this->{'yy_r6_' . $this->token}($yysubmatches); |
---|
| 563 | if ($r === null) { |
---|
| 564 | $this->counter += strlen($this->value); |
---|
| 565 | $this->line += substr_count($this->value, "\n"); |
---|
| 566 | // accept this token |
---|
| 567 | return true; |
---|
| 568 | } elseif ($r === true) { |
---|
| 569 | // we have changed state |
---|
| 570 | // process this token in the new state |
---|
| 571 | return $this->yylex(); |
---|
| 572 | } elseif ($r === false) { |
---|
| 573 | $this->counter += strlen($this->value); |
---|
| 574 | $this->line += substr_count($this->value, "\n"); |
---|
| 575 | if ($this->counter >= strlen($this->data)) { |
---|
| 576 | return false; // end of input |
---|
| 577 | } |
---|
| 578 | // skip this token |
---|
| 579 | continue; |
---|
| 580 | } } else { |
---|
| 581 | throw new Exception('Unexpected input at line' . $this->line . |
---|
| 582 | ': ' . $this->data[$this->counter]); |
---|
| 583 | } |
---|
| 584 | break; |
---|
| 585 | } while (true); |
---|
| 586 | |
---|
| 587 | } // end function |
---|
| 588 | |
---|
| 589 | |
---|
| 590 | const TRIPPLE = 6; |
---|
| 591 | function yy_r6_1($yy_subpatterns) |
---|
| 592 | { |
---|
| 593 | |
---|
| 594 | $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END; |
---|
| 595 | $this->yypopstate(); |
---|
| 596 | $this->yypushstate(self::START); |
---|
| 597 | } |
---|
| 598 | function yy_r6_2($yy_subpatterns) |
---|
| 599 | { |
---|
| 600 | |
---|
| 601 | $to = strlen($this->data); |
---|
| 602 | preg_match("/\"\"\"[ \t\r]*[\n#;]/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); |
---|
| 603 | if (isset($match[0][1])) { |
---|
| 604 | $to = $match[0][1]; |
---|
| 605 | } |
---|
| 606 | $this->value = substr($this->data,$this->counter,$to-$this->counter); |
---|
| 607 | $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT; |
---|
| 608 | } |
---|
| 609 | |
---|
| 610 | |
---|
| 611 | } |
---|
| 612 | ?> |
---|