106 public $state_name = array(1 =>
'START', 2 =>
'VALUE', 3 =>
'NAKED_STRING_VALUE', 4 =>
'COMMENT', 5 =>
'SECTION',
143 self::instance($this);
144 $this->data =
$data .
"\n";
146 if (preg_match(
'/^\xEF\xBB\xBF/', $this->data, $match)) {
147 $this->counter += strlen($match[0]);
151 $this->smarty = $compiler->smarty;
152 $this->configBooleanize = $this->smarty->config_booleanize;
155 public static function &
instance($new_instance = null)
157 static $instance = null;
158 if (isset($new_instance) && is_object($new_instance)) {
159 $instance = $new_instance;
166 $this->yyTraceFILE = fopen(
'php://output',
'w');
167 $this->yyTracePrompt =
'<br>';
176 return $this->{
'yylex' . $this->_yy_state}();
181 if ($this->yyTraceFILE) {
182 fprintf($this->yyTraceFILE,
"%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
184 array_push($this->_yy_stack, $this->_yy_state);
185 $this->_yy_state =
$state;
186 if ($this->yyTraceFILE) {
187 fprintf($this->yyTraceFILE,
"%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
193 if ($this->yyTraceFILE) {
194 fprintf($this->yyTraceFILE,
"%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
196 $this->_yy_state = array_pop($this->_yy_stack);
197 if ($this->yyTraceFILE) {
198 fprintf($this->yyTraceFILE,
"%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
204 $this->_yy_state =
$state;
205 if ($this->yyTraceFILE) {
206 fprintf($this->yyTraceFILE,
"%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
212 if (!isset($this->yy_global_pattern1)) {
213 $this->yy_global_pattern1 =
"/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
215 if ($this->counter >= strlen($this->data)) {
220 if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
221 $yysubmatches = $yymatches;
222 if (strlen($yysubmatches[0]) < 200) {
223 $yymatches = preg_grep(
"/(.|\s)+/", $yysubmatches);
225 $yymatches = array_filter($yymatches,
'strlen');
227 if (empty($yymatches)) {
228 throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data, $this->counter, 5) .
'... state START');
231 $this->token = key($yymatches);
232 $this->value = current($yymatches);
233 $r = $this->{
'yy_r1_' . $this->token}();
235 $this->counter += strlen($this->value);
236 $this->line += substr_count($this->value,
"\n");
239 } elseif ($r ===
true) {
242 return $this->
yylex();
243 } elseif ($r ===
false) {
244 $this->counter += strlen($this->value);
245 $this->line += substr_count($this->value,
"\n");
246 if ($this->counter >= strlen($this->data)) {
253 throw new Exception(
'Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
314 if (!isset($this->yy_global_pattern2)) {
315 $this->yy_global_pattern2 =
"/\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)/isS";
317 if ($this->counter >= strlen($this->data)) {
322 if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
323 $yysubmatches = $yymatches;
324 if (strlen($yysubmatches[0]) < 200) {
325 $yymatches = preg_grep(
"/(.|\s)+/", $yysubmatches);
327 $yymatches = array_filter($yymatches,
'strlen');
329 if (empty($yymatches)) {
330 throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data, $this->counter, 5) .
'... state VALUE');
333 $this->token = key($yymatches);
334 $this->value = current($yymatches);
335 $r = $this->{
'yy_r2_' . $this->token}();
337 $this->counter += strlen($this->value);
338 $this->line += substr_count($this->value,
"\n");
341 } elseif ($r ===
true) {
344 return $this->
yylex();
345 } elseif ($r ===
false) {
346 $this->counter += strlen($this->value);
347 $this->line += substr_count($this->value,
"\n");
348 if ($this->counter >= strlen($this->data)) {
355 throw new Exception(
'Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
407 if (!$this->configBooleanize || !in_array(strtolower($this->value), Array(
"true",
"false",
"on",
"off",
"yes",
436 if (!isset($this->yy_global_pattern3)) {
437 $this->yy_global_pattern3 =
"/\G([^\n]+?(?=[ \t\r]*\n))/isS";
439 if ($this->counter >= strlen($this->data)) {
444 if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
445 $yysubmatches = $yymatches;
446 if (strlen($yysubmatches[0]) < 200) {
447 $yymatches = preg_grep(
"/(.|\s)+/", $yysubmatches);
449 $yymatches = array_filter($yymatches,
'strlen');
451 if (empty($yymatches)) {
452 throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data, $this->counter, 5) .
'... state NAKED_STRING_VALUE');
455 $this->token = key($yymatches);
456 $this->value = current($yymatches);
457 $r = $this->{
'yy_r3_' . $this->token}();
459 $this->counter += strlen($this->value);
460 $this->line += substr_count($this->value,
"\n");
463 } elseif ($r ===
true) {
466 return $this->
yylex();
467 } elseif ($r ===
false) {
468 $this->counter += strlen($this->value);
469 $this->line += substr_count($this->value,
"\n");
470 if ($this->counter >= strlen($this->data)) {
477 throw new Exception(
'Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
494 if (!isset($this->yy_global_pattern4)) {
495 $this->yy_global_pattern4 =
"/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
497 if ($this->counter >= strlen($this->data)) {
502 if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
503 $yysubmatches = $yymatches;
504 if (strlen($yysubmatches[0]) < 200) {
505 $yymatches = preg_grep(
"/(.|\s)+/", $yysubmatches);
507 $yymatches = array_filter($yymatches,
'strlen');
509 if (empty($yymatches)) {
510 throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data, $this->counter, 5) .
'... state COMMENT');
513 $this->token = key($yymatches);
514 $this->value = current($yymatches);
515 $r = $this->{
'yy_r4_' . $this->token}();
517 $this->counter += strlen($this->value);
518 $this->line += substr_count($this->value,
"\n");
521 } elseif ($r ===
true) {
524 return $this->
yylex();
525 } elseif ($r ===
false) {
526 $this->counter += strlen($this->value);
527 $this->line += substr_count($this->value,
"\n");
528 if ($this->counter >= strlen($this->data)) {
535 throw new Exception(
'Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
564 if (!isset($this->yy_global_pattern5)) {
565 $this->yy_global_pattern5 =
"/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS";
567 if ($this->counter >= strlen($this->data)) {
572 if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
573 $yysubmatches = $yymatches;
574 if (strlen($yysubmatches[0]) < 200) {
575 $yymatches = preg_grep(
"/(.|\s)+/", $yysubmatches);
577 $yymatches = array_filter($yymatches,
'strlen');
579 if (empty($yymatches)) {
580 throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data, $this->counter, 5) .
'... state SECTION');
583 $this->token = key($yymatches);
584 $this->value = current($yymatches);
585 $r = $this->{
'yy_r5_' . $this->token}();
587 $this->counter += strlen($this->value);
588 $this->line += substr_count($this->value,
"\n");
591 } elseif ($r ===
true) {
594 return $this->
yylex();
595 } elseif ($r ===
false) {
596 $this->counter += strlen($this->value);
597 $this->line += substr_count($this->value,
"\n");
598 if ($this->counter >= strlen($this->data)) {
605 throw new Exception(
'Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
628 if (!isset($this->yy_global_pattern6)) {
629 $this->yy_global_pattern6 =
"/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS";
631 if ($this->counter >= strlen($this->data)) {
636 if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
637 $yysubmatches = $yymatches;
638 if (strlen($yysubmatches[0]) < 200) {
639 $yymatches = preg_grep(
"/(.|\s)+/", $yysubmatches);
641 $yymatches = array_filter($yymatches,
'strlen');
643 if (empty($yymatches)) {
644 throw new Exception(
'Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data, $this->counter, 5) .
'... state TRIPPLE');
647 $this->token = key($yymatches);
648 $this->value = current($yymatches);
649 $r = $this->{
'yy_r6_' . $this->token}();
651 $this->counter += strlen($this->value);
652 $this->line += substr_count($this->value,
"\n");
655 } elseif ($r ===
true) {
658 return $this->
yylex();
659 } elseif ($r ===
false) {
660 $this->counter += strlen($this->value);
661 $this->line += substr_count($this->value,
"\n");
662 if ($this->counter >= strlen($this->data)) {
669 throw new Exception(
'Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
688 $to = strlen($this->data);
689 preg_match(
"/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
690 if (isset($match[0][1])) {
693 $this->compiler->trigger_template_error(
"missing or misspelled literal closing tag");
695 $this->value = substr($this->data, $this->counter, $to - $this->counter);