PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_5_3/lcov_data/Zend - zend_language_scanner.l
Test: PHP Code Coverage
Date: 2009-11-21 Instrumented lines: 851
Code covered: 93.2 % Executed lines: 793
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | Zend Engine                                                          |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 2.00 of the Zend license,     |
       8                 :    | that is bundled with this package in the file LICENSE, and is        |
       9                 :    | available through the world-wide-web at the following url:           |
      10                 :    | http://www.zend.com/license/2_00.txt.                                |
      11                 :    | If you did not receive a copy of the Zend license and are unable to  |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@zend.com so we can mail you a copy immediately.              |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Authors: Marcus Boerger <helly@php.net>                              |
      16                 :    |          Nuno Lopes <nlopess@php.net>                                |
      17                 :    |          Scott MacVicar <scottmac@php.net>                           |
      18                 :    | Flex version authors:                                                |
      19                 :    |          Andi Gutmans <andi@zend.com>                                |
      20                 :    |          Zeev Suraski <zeev@zend.com>                                |
      21                 :    +----------------------------------------------------------------------+
      22                 : */
      23                 : 
      24                 : /* $Id: zend_language_scanner.l 290862 2009-11-17 11:18:40Z felipe $ */
      25                 : 
      26                 : #if 0
      27                 : # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
      28                 : #else
      29                 : # define YYDEBUG(s, c)
      30                 : #endif
      31                 : 
      32                 : #include "zend_language_scanner_defs.h"
      33                 : 
      34                 : #include <errno.h>
      35                 : #include "zend.h"
      36                 : #include "zend_alloc.h"
      37                 : #include <zend_language_parser.h>
      38                 : #include "zend_compile.h"
      39                 : #include "zend_language_scanner.h"
      40                 : #include "zend_highlight.h"
      41                 : #include "zend_constants.h"
      42                 : #include "zend_variables.h"
      43                 : #include "zend_operators.h"
      44                 : #include "zend_API.h"
      45                 : #include "zend_strtod.h"
      46                 : #include "zend_exceptions.h"
      47                 : #include "tsrm_virtual_cwd.h"
      48                 : #include "tsrm_config_common.h"
      49                 : 
      50                 : #define YYCTYPE   unsigned char
      51                 : #define YYFILL(n) { if ((YYCURSOR + n) >= (YYLIMIT + ZEND_MMAP_AHEAD)) { return 0; } }
      52                 : #define YYCURSOR  SCNG(yy_cursor)
      53                 : #define YYLIMIT   SCNG(yy_limit)
      54                 : #define YYMARKER  SCNG(yy_marker)
      55                 : 
      56                 : #define YYGETCONDITION()  SCNG(yy_state)
      57                 : #define YYSETCONDITION(s) SCNG(yy_state) = s
      58                 : 
      59                 : #define STATE(name)  yyc##name
      60                 : 
      61                 : /* emulate flex constructs */
      62                 : #define BEGIN(state) YYSETCONDITION(STATE(state))
      63                 : #define YYSTATE      YYGETCONDITION()
      64                 : #define yytext       ((char*)SCNG(yy_text))
      65                 : #define yyleng       SCNG(yy_leng)
      66                 : #define yyless(x)    do { YYCURSOR = (unsigned char*)yytext + x; \
      67                 :                           yyleng   = (unsigned int)x; } while(0)
      68                 : #define yymore()     goto yymore_restart
      69                 : 
      70                 : /* perform sanity check. If this message is triggered you should
      71                 :    increase the ZEND_MMAP_AHEAD value in the zend_streams.h file */
      72                 : /*!max:re2c */
      73                 : #if ZEND_MMAP_AHEAD < YYMAXFILL
      74                 : # error ZEND_MMAP_AHEAD should be greater than or equal to YYMAXFILL
      75                 : #endif
      76                 : 
      77                 : #ifdef HAVE_STDARG_H
      78                 : # include <stdarg.h>
      79                 : #endif
      80                 : 
      81                 : #ifdef HAVE_UNISTD_H
      82                 : # include <unistd.h>
      83                 : #endif
      84                 : 
      85                 : /* Globals Macros */
      86                 : #define SCNG    LANG_SCNG
      87                 : #ifdef ZTS
      88                 : ZEND_API ts_rsrc_id language_scanner_globals_id;
      89                 : #else
      90                 : ZEND_API zend_php_scanner_globals language_scanner_globals;
      91                 : #endif
      92                 : 
      93                 : #define HANDLE_NEWLINES(s, l)                                                                                                   \
      94                 : do {                                                                                                                                                    \
      95                 :         char *p = (s), *boundary = p+(l);                                                                                       \
      96                 :                                                                                                                                                                 \
      97                 :         while (p<boundary) {                                                                                                         \
      98                 :                 if (*p == '\n' || (*p == '\r' && (*(p+1) != '\n'))) {                                   \
      99                 :                         CG(zend_lineno)++;                                                                                                      \
     100                 :                 }                                                                                                                                               \
     101                 :                 p++;                                                                                                                                    \
     102                 :         }                                                                                                                                                       \
     103                 : } while (0)
     104                 : 
     105                 : #define HANDLE_NEWLINE(c) \
     106                 : { \
     107                 :         if (c == '\n' || c == '\r') { \
     108                 :                 CG(zend_lineno)++; \
     109                 :         } \
     110                 : }
     111                 : 
     112                 : /* To save initial string length after scanning to first variable, CG(doc_comment_len) can be reused */
     113                 : #define SET_DOUBLE_QUOTES_SCANNED_LENGTH(len) CG(doc_comment_len) = (len)
     114                 : #define GET_DOUBLE_QUOTES_SCANNED_LENGTH()    CG(doc_comment_len)
     115                 : 
     116                 : #define IS_LABEL_START(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || (c) == '_' || (c) >= 0x7F)
     117                 : 
     118                 : #define ZEND_IS_OCT(c)  ((c)>='0' && (c)<='7')
     119                 : #define ZEND_IS_HEX(c)  (((c)>='0' && (c)<='9') || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F'))
     120                 : 
     121                 : BEGIN_EXTERN_C()
     122                 : 
     123                 : static void _yy_push_state(int new_state TSRMLS_DC)
     124          132763 : {
     125          132763 :         zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION(), sizeof(int));
     126          132763 :         YYSETCONDITION(new_state);
     127          132763 : }
     128                 : 
     129                 : #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
     130                 : 
     131                 : static void yy_pop_state(TSRMLS_D)
     132          132690 : {
     133                 :         int *stack_state;
     134          132690 :         zend_stack_top(&SCNG(state_stack), (void **) &stack_state);
     135          132690 :         YYSETCONDITION(*stack_state);
     136          132690 :         zend_stack_del_top(&SCNG(state_stack));
     137          132690 : }
     138                 : 
     139                 : static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC)
     140           26366 : {
     141           26366 :         YYCURSOR       = (YYCTYPE*)str;
     142           26366 :         SCNG(yy_start) = YYCURSOR;
     143           26366 :         YYLIMIT        = YYCURSOR + len;
     144           26366 : }
     145                 : 
     146                 : void startup_scanner(TSRMLS_D)
     147           17619 : {
     148           17619 :         CG(heredoc) = NULL;
     149           17619 :         CG(heredoc_len) = 0;
     150           17619 :         CG(doc_comment) = NULL;
     151           17619 :         CG(doc_comment_len) = 0;
     152           17619 :         zend_stack_init(&SCNG(state_stack));
     153           17619 : }
     154                 : 
     155                 : void shutdown_scanner(TSRMLS_D)
     156           17651 : {
     157           17651 :         if (CG(heredoc)) {
     158               2 :                 efree(CG(heredoc));
     159               2 :                 CG(heredoc_len)=0;
     160                 :         }
     161           17651 :         zend_stack_destroy(&SCNG(state_stack));
     162           17651 :         RESET_DOC_COMMENT();
     163           17651 : }
     164                 : 
     165                 : ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
     166           26390 : {
     167           26390 :         lex_state->yy_leng   = SCNG(yy_leng);
     168           26390 :         lex_state->yy_start  = SCNG(yy_start);
     169           26390 :         lex_state->yy_text   = SCNG(yy_text);
     170           26390 :         lex_state->yy_cursor = SCNG(yy_cursor);
     171           26390 :         lex_state->yy_marker = SCNG(yy_marker);
     172           26390 :         lex_state->yy_limit  = SCNG(yy_limit);
     173                 : 
     174           26390 :         lex_state->state_stack = SCNG(state_stack);
     175           26390 :         zend_stack_init(&SCNG(state_stack));
     176                 : 
     177           26390 :         lex_state->in = SCNG(yy_in);
     178           26390 :         lex_state->yy_state = YYSTATE;
     179           26390 :         lex_state->filename = zend_get_compiled_filename(TSRMLS_C);
     180           26390 :         lex_state->lineno = CG(zend_lineno);
     181                 : 
     182                 : #ifdef ZEND_MULTIBYTE
     183                 :         lex_state->script_org = SCNG(script_org);
     184                 :         lex_state->script_org_size = SCNG(script_org_size);
     185                 :         lex_state->script_filtered = SCNG(script_filtered);
     186                 :         lex_state->script_filtered_size = SCNG(script_filtered_size);
     187                 :         lex_state->input_filter = SCNG(input_filter);
     188                 :         lex_state->output_filter = SCNG(output_filter);
     189                 :         lex_state->script_encoding = SCNG(script_encoding);
     190                 :         lex_state->internal_encoding = SCNG(internal_encoding);
     191                 : #endif /* ZEND_MULTIBYTE */
     192           26390 : }
     193                 : 
     194                 : ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
     195           26227 : {
     196           26227 :         SCNG(yy_leng)   = lex_state->yy_leng;
     197           26227 :         SCNG(yy_start)  = lex_state->yy_start;
     198           26227 :         SCNG(yy_text)   = lex_state->yy_text;
     199           26227 :         SCNG(yy_cursor) = lex_state->yy_cursor;
     200           26227 :         SCNG(yy_marker) = lex_state->yy_marker;
     201           26227 :         SCNG(yy_limit)  = lex_state->yy_limit;
     202                 : 
     203           26227 :         zend_stack_destroy(&SCNG(state_stack));
     204           26227 :         SCNG(state_stack) = lex_state->state_stack;
     205                 : 
     206           26227 :         SCNG(yy_in) = lex_state->in;
     207           26227 :         YYSETCONDITION(lex_state->yy_state);
     208           26227 :         CG(zend_lineno) = lex_state->lineno;
     209           26227 :         zend_restore_compiled_filename(lex_state->filename TSRMLS_CC);
     210                 : #ifdef ZEND_MULTIBYTE
     211                 :         if (SCNG(script_org)) {
     212                 :                 efree(SCNG(script_org));
     213                 :                 SCNG(script_org) = NULL;
     214                 :         }
     215                 :         if (SCNG(script_filtered)) {
     216                 :                 efree(SCNG(script_filtered));
     217                 :                 SCNG(script_filtered) = NULL;
     218                 :         }
     219                 :         SCNG(script_org) = lex_state->script_org;
     220                 :         SCNG(script_org_size) = lex_state->script_org_size;
     221                 :         SCNG(script_filtered) = lex_state->script_filtered;
     222                 :         SCNG(script_filtered_size) = lex_state->script_filtered_size;
     223                 :         SCNG(input_filter) = lex_state->input_filter;
     224                 :         SCNG(output_filter) = lex_state->output_filter;
     225                 :         SCNG(script_encoding) = lex_state->script_encoding;
     226                 :         SCNG(internal_encoding) = lex_state->internal_encoding;
     227                 : #endif /* ZEND_MULTIBYTE */
     228           26227 : }
     229                 : 
     230                 : ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
     231           25166 : {
     232           25166 :         zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
     233                 :         /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
     234           25166 :         file_handle->opened_path = NULL;
     235           25166 :         if (file_handle->free_filename) {
     236               0 :                 file_handle->filename = NULL;
     237                 :         }
     238           25166 : }
     239                 : 
     240                 : 
     241                 : ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
     242           25338 : {
     243           25338 :         char *file_path = NULL, *buf;
     244                 :         size_t size;
     245                 : 
     246           25338 :         if (zend_stream_fixup(file_handle, &buf, &size TSRMLS_CC) == FAILURE) {
     247              30 :                 return FAILURE;
     248                 :         }
     249                 : 
     250           25308 :         zend_llist_add_element(&CG(open_files), file_handle);
     251           25308 :         if (file_handle->handle.stream.handle >= (void*)file_handle && file_handle->handle.stream.handle <= (void*)(file_handle+1)) {
     252           17795 :                 zend_file_handle *fh = (zend_file_handle*)zend_llist_get_last(&CG(open_files));
     253           17795 :                 size_t diff = (char*)file_handle->handle.stream.handle - (char*)file_handle;
     254           17795 :                 fh->handle.stream.handle = (void*)(((char*)fh) + diff);
     255           17795 :                 file_handle->handle.stream.handle = fh->handle.stream.handle;
     256                 :         }
     257                 : 
     258                 :         /* Reset the scanner for scanning the new file */
     259           25308 :         SCNG(yy_in) = file_handle;
     260                 : 
     261           25308 :         if (size != -1) {
     262                 : #ifdef ZEND_MULTIBYTE
     263                 :                 if (zend_multibyte_read_script((unsigned char *)buf, size TSRMLS_CC) != 0) {
     264                 :                         return FAILURE;
     265                 :                 }
     266                 : 
     267                 :                 SCNG(yy_in) = NULL;
     268                 : 
     269                 :                 zend_multibyte_set_filter(NULL TSRMLS_CC);
     270                 : 
     271                 :                 if (!SCNG(input_filter)) {
     272                 :                         SCNG(script_filtered) = (unsigned char*)emalloc(SCNG(script_org_size)+1);
     273                 :                         memcpy(SCNG(script_filtered), SCNG(script_org), SCNG(script_org_size)+1);
     274                 :                         SCNG(script_filtered_size) = SCNG(script_org_size);
     275                 :                 } else {
     276                 :                         SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC);
     277                 :                 }
     278                 : 
     279                 :                 yy_scan_buffer((char *)SCNG(script_filtered), SCNG(script_filtered_size) TSRMLS_CC);
     280                 : #else /* !ZEND_MULTIBYTE */
     281           25308 :                 yy_scan_buffer(buf, size TSRMLS_CC);
     282                 : #endif /* ZEND_MULTIBYTE */
     283                 :         } else {
     284               0 :                 zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
     285                 :         }
     286                 : 
     287           25308 :         BEGIN(INITIAL);
     288                 : 
     289           25308 :         if (file_handle->opened_path) {
     290           25281 :                 file_path = file_handle->opened_path;
     291                 :         } else {
     292              27 :                 file_path = file_handle->filename;
     293                 :         }
     294                 : 
     295           25308 :         zend_set_compiled_filename(file_path TSRMLS_CC);
     296                 : 
     297           25308 :         if (CG(start_lineno)) {
     298           17236 :                 CG(zend_lineno) = CG(start_lineno);
     299           17236 :                 CG(start_lineno) = 0;
     300                 :         } else {
     301            8072 :                 CG(zend_lineno) = 1;
     302                 :         }
     303                 : 
     304           25308 :         CG(increment_lineno) = 0;
     305           25308 :         return SUCCESS;
     306                 : }
     307                 : END_EXTERN_C()
     308                 : 
     309                 : 
     310                 : ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC)
     311           25307 : {
     312                 :         zend_lex_state original_lex_state;
     313           25307 :         zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
     314           25307 :         zend_op_array *original_active_op_array = CG(active_op_array);
     315           25307 :         zend_op_array *retval=NULL;
     316                 :         int compiler_result;
     317           25307 :         zend_bool compilation_successful=0;
     318                 :         znode retval_znode;
     319           25307 :         zend_bool original_in_compilation = CG(in_compilation);
     320                 : 
     321           25307 :         retval_znode.op_type = IS_CONST;
     322           25307 :         retval_znode.u.constant.type = IS_LONG;
     323           25307 :         retval_znode.u.constant.value.lval = 1;
     324           25307 :         Z_UNSET_ISREF(retval_znode.u.constant);
     325           25307 :         Z_SET_REFCOUNT(retval_znode.u.constant, 1);
     326                 : 
     327           25307 :         zend_save_lexical_state(&original_lex_state TSRMLS_CC);
     328                 : 
     329           25307 :         retval = op_array; /* success oriented */
     330                 : 
     331           25307 :         if (open_file_for_scanning(file_handle TSRMLS_CC)==FAILURE) {
     332              26 :                 if (type==ZEND_REQUIRE) {
     333               0 :                         zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC);
     334               0 :                         zend_bailout();
     335                 :                 } else {
     336              26 :                         zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC);
     337                 :                 }
     338              26 :                 compilation_successful=0;
     339                 :         } else {
     340           25281 :                 init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
     341           25281 :                 CG(in_compilation) = 1;
     342           25281 :                 CG(active_op_array) = op_array;
     343           25281 :                 compiler_result = zendparse(TSRMLS_C);
     344           25146 :                 zend_do_return(&retval_znode, 0 TSRMLS_CC);
     345           25146 :                 CG(in_compilation) = original_in_compilation;
     346           25146 :                 if (compiler_result==1) { /* parser error */
     347              24 :                         zend_bailout();
     348                 :                 }
     349           25122 :                 compilation_successful=1;
     350                 :         }
     351                 : 
     352           25148 :         if (retval) {
     353           25148 :                 CG(active_op_array) = original_active_op_array;
     354           25148 :                 if (compilation_successful) {
     355           25122 :                         pass_two(op_array TSRMLS_CC);
     356           25119 :                         zend_release_labels(TSRMLS_C);
     357                 :                 } else {
     358              26 :                         efree(op_array);
     359              26 :                         retval = NULL;
     360                 :                 }
     361                 :         }
     362           25145 :         zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
     363           25145 :         return retval;
     364                 : }
     365                 : 
     366                 : 
     367                 : zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
     368            2722 : {
     369                 :         zend_file_handle file_handle;
     370                 :         zval tmp;
     371                 :         zend_op_array *retval;
     372            2722 :         char *opened_path = NULL;
     373                 : 
     374            2722 :         if (filename->type != IS_STRING) {
     375               0 :                 tmp = *filename;
     376               0 :                 zval_copy_ctor(&tmp);
     377               0 :                 convert_to_string(&tmp);
     378               0 :                 filename = &tmp;
     379                 :         }
     380            2722 :         file_handle.filename = filename->value.str.val;
     381            2722 :         file_handle.free_filename = 0;
     382            2722 :         file_handle.type = ZEND_HANDLE_FILENAME;
     383            2722 :         file_handle.opened_path = NULL;
     384            2722 :         file_handle.handle.fp = NULL;
     385                 : 
     386            2722 :         retval = zend_compile_file(&file_handle, type TSRMLS_CC);
     387            2717 :         if (retval && file_handle.handle.stream.handle) {
     388            2691 :                 int dummy = 1;
     389                 : 
     390            2691 :                 if (!file_handle.opened_path) {
     391              17 :                         file_handle.opened_path = opened_path = estrndup(filename->value.str.val, filename->value.str.len);
     392                 :                 }
     393                 : 
     394            2691 :                 zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL);
     395                 : 
     396            2691 :                 if (opened_path) {
     397              17 :                         efree(opened_path);
     398                 :                 }
     399                 :         }
     400            2717 :         zend_destroy_file_handle(&file_handle TSRMLS_CC);
     401                 : 
     402            2717 :         if (filename==&tmp) {
     403               0 :                 zval_dtor(&tmp);
     404                 :         }
     405            2717 :         return retval;
     406                 : }
     407                 : 
     408                 : ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC)
     409            1058 : {
     410                 :         /* enforce two trailing NULLs for flex... */
     411            1058 :         str->value.str.val = safe_erealloc(str->value.str.val, 1, str->value.str.len, ZEND_MMAP_AHEAD);
     412                 : 
     413            1058 :         memset(str->value.str.val + str->value.str.len, 0, ZEND_MMAP_AHEAD);
     414                 : 
     415            1058 :         SCNG(yy_in)=NULL;
     416                 : 
     417                 : #ifdef ZEND_MULTIBYTE
     418                 :         SCNG(script_org) = (unsigned char *)estrdup(str->value.str.val);
     419                 :         SCNG(script_org_size) = str->value.str.len;
     420                 : 
     421                 :         zend_multibyte_set_filter(CG(internal_encoding) TSRMLS_CC);
     422                 : 
     423                 :         if (!SCNG(input_filter)) {
     424                 :                 SCNG(script_filtered) = (unsigned char*)emalloc(SCNG(script_org_size)+1);
     425                 :                 memcpy(SCNG(script_filtered), SCNG(script_org), SCNG(script_org_size)+1);
     426                 :                 SCNG(script_filtered_size) = SCNG(script_org_size);
     427                 :         } else {
     428                 :                 SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC);
     429                 :         }
     430                 : 
     431                 :         yy_scan_buffer((char *)SCNG(script_filtered), SCNG(script_filtered_size) TSRMLS_CC);    
     432                 : #else /* !ZEND_MULTIBYTE */
     433            1058 :         yy_scan_buffer(str->value.str.val, str->value.str.len TSRMLS_CC);
     434                 : #endif /* ZEND_MULTIBYTE */
     435                 : 
     436            1058 :         zend_set_compiled_filename(filename TSRMLS_CC);
     437            1058 :         CG(zend_lineno) = 1;
     438            1058 :         CG(increment_lineno) = 0;
     439            1058 :         return SUCCESS;
     440                 : }
     441                 : 
     442                 : 
     443                 : ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D)
     444             271 : {
     445             271 :         size_t offset = SCNG(yy_cursor) - SCNG(yy_start);
     446                 : #ifdef ZEND_MULTIBYTE
     447                 :         if (SCNG(input_filter)) {
     448                 :                 size_t original_offset = offset, length = 0; do {
     449                 :                         unsigned char *p = NULL;
     450                 :                         SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC);
     451                 :                         if (!p) {
     452                 :                                 break;
     453                 :                         }
     454                 :                         efree(p);
     455                 :                         if (length > original_offset) {
     456                 :                                 offset--;
     457                 :                         } else if (length < original_offset) {
     458                 :                                 offset++;
     459                 :                         }
     460                 :                 } while (original_offset != length);
     461                 :         }
     462                 : #endif
     463             271 :         return offset;
     464                 : }
     465                 : 
     466                 : 
     467                 : zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
     468             979 : {
     469                 :         zend_lex_state original_lex_state;
     470             979 :         zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array));
     471             979 :         zend_op_array *original_active_op_array = CG(active_op_array);
     472                 :         zend_op_array *retval;
     473                 :         zval tmp;
     474                 :         int compiler_result;
     475             979 :         zend_bool original_in_compilation = CG(in_compilation);
     476                 : 
     477             979 :         if (source_string->value.str.len==0) {
     478               0 :                 efree(op_array);
     479               0 :                 return NULL;
     480                 :         }
     481                 : 
     482             979 :         CG(in_compilation) = 1;
     483                 : 
     484             979 :         tmp = *source_string;
     485             979 :         zval_copy_ctor(&tmp);
     486             979 :         convert_to_string(&tmp);
     487             979 :         source_string = &tmp;
     488                 : 
     489             979 :         zend_save_lexical_state(&original_lex_state TSRMLS_CC);
     490             979 :         if (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC)==FAILURE) {
     491               0 :                 efree(op_array);
     492               0 :                 retval = NULL;
     493                 :         } else {
     494             979 :                 zend_bool orig_interactive = CG(interactive);
     495                 : 
     496             979 :                 CG(interactive) = 0;
     497             979 :                 init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
     498             979 :                 CG(interactive) = orig_interactive;
     499             979 :                 CG(active_op_array) = op_array;
     500             979 :                 BEGIN(ST_IN_SCRIPTING);
     501             979 :                 compiler_result = zendparse(TSRMLS_C);
     502                 : 
     503                 : #ifdef ZEND_MULTIBYTE
     504                 :                 if (SCNG(script_org)) {
     505                 :                         efree(SCNG(script_org));
     506                 :                         SCNG(script_org) = NULL;
     507                 :                 }
     508                 :                 if (SCNG(script_filtered)) {
     509                 :                         efree(SCNG(script_filtered));
     510                 :                         SCNG(script_filtered) = NULL;
     511                 :                 }
     512                 : #endif /* ZEND_MULTIBYTE */
     513                 : 
     514             978 :                 if (compiler_result==1) {
     515               7 :                         CG(active_op_array) = original_active_op_array;
     516               7 :                         CG(unclean_shutdown)=1;
     517               7 :                         retval = NULL;
     518                 :                 } else {
     519             971 :                         zend_do_return(NULL, 0 TSRMLS_CC);
     520             971 :                         CG(active_op_array) = original_active_op_array;
     521             971 :                         pass_two(op_array TSRMLS_CC);
     522             971 :                         zend_release_labels(TSRMLS_C);
     523             971 :                         retval = op_array;
     524                 :                 }
     525                 :         }
     526             978 :         zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
     527             978 :         zval_dtor(&tmp);
     528             978 :         CG(in_compilation) = original_in_compilation;
     529             978 :         return retval;
     530                 : }
     531                 : 
     532                 : 
     533                 : BEGIN_EXTERN_C()
     534                 : int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC)
     535              20 : {
     536                 :         zend_lex_state original_lex_state;
     537                 :         zend_file_handle file_handle;
     538                 : 
     539              20 :         file_handle.type = ZEND_HANDLE_FILENAME;
     540              20 :         file_handle.filename = filename;
     541              20 :         file_handle.free_filename = 0;
     542              20 :         file_handle.opened_path = NULL;
     543              20 :         zend_save_lexical_state(&original_lex_state TSRMLS_CC);
     544              20 :         if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) {
     545               2 :                 zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename TSRMLS_CC);
     546               2 :                 zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
     547               2 :                 return FAILURE;
     548                 :         }
     549              18 :         zend_highlight(syntax_highlighter_ini TSRMLS_CC);
     550                 : #ifdef ZEND_MULTIBYTE
     551                 :         if (SCNG(script_org)) {
     552                 :                 efree(SCNG(script_org));
     553                 :                 SCNG(script_org) = NULL;
     554                 :         }
     555                 :         if (SCNG(script_filtered)) {
     556                 :                 efree(SCNG(script_filtered));
     557                 :                 SCNG(script_filtered) = NULL;
     558                 :         }
     559                 : #endif /* ZEND_MULTIBYTE */
     560              18 :         zend_destroy_file_handle(&file_handle TSRMLS_CC);
     561              18 :         zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
     562              18 :         return SUCCESS;
     563                 : }
     564                 : 
     565                 : int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC)
     566              12 : {
     567                 :         zend_lex_state original_lex_state;
     568              12 :         zval tmp = *str;
     569                 : 
     570              12 :         str = &tmp;
     571              12 :         zval_copy_ctor(str);
     572              12 :         zend_save_lexical_state(&original_lex_state TSRMLS_CC);
     573              12 :         if (zend_prepare_string_for_scanning(str, str_name TSRMLS_CC)==FAILURE) {
     574               0 :                 zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
     575               0 :                 return FAILURE;
     576                 :         }
     577              12 :         BEGIN(INITIAL);
     578              12 :         zend_highlight(syntax_highlighter_ini TSRMLS_CC);
     579                 : #ifdef ZEND_MULTIBYTE
     580                 :         if (SCNG(script_org)) {
     581                 :                 efree(SCNG(script_org));
     582                 :                 SCNG(script_org) = NULL;
     583                 :         }
     584                 :         if (SCNG(script_filtered)) {
     585                 :                 efree(SCNG(script_filtered));
     586                 :                 SCNG(script_filtered) = NULL;
     587                 :         }
     588                 : #endif /* ZEND_MULTIBYTE */
     589              12 :         zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
     590              12 :         zval_dtor(str);
     591              12 :         return SUCCESS;
     592                 : }
     593                 : END_EXTERN_C()
     594                 : 
     595                 : #ifdef ZEND_MULTIBYTE
     596                 : 
     597                 : BEGIN_EXTERN_C()
     598                 : ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, zend_encoding *old_encoding TSRMLS_DC)
     599                 : {
     600                 :         size_t original_offset, offset, free_flag, new_len, length;
     601                 :         unsigned char *p;
     602                 : 
     603                 :         /* calculate current position */
     604                 :         offset = original_offset = YYCURSOR - SCNG(yy_start);
     605                 :         if (old_input_filter && offset > 0) {
     606                 :                 zend_encoding *new_encoding = SCNG(script_encoding);
     607                 :                 zend_encoding_filter new_filter = SCNG(input_filter);
     608                 :                 SCNG(script_encoding) = old_encoding;
     609                 :                 SCNG(input_filter) = old_input_filter;
     610                 :                 offset = zend_get_scanned_file_offset(TSRMLS_C);
     611                 :                 SCNG(script_encoding) = new_encoding;
     612                 :                 SCNG(input_filter) = new_filter;
     613                 :         }
     614                 : 
     615                 :         /* convert and set */
     616                 :         if (!SCNG(input_filter)) {
     617                 :                 length = SCNG(script_org_size) - offset;
     618                 :                 p = SCNG(script_org) + offset;
     619                 :                 free_flag = 0;
     620                 :         } else {
     621                 :                 SCNG(input_filter)(&p, &length, SCNG(script_org) + offset, SCNG(script_org_size) - offset TSRMLS_CC);
     622                 :                 free_flag = 1;
     623                 :         }
     624                 : 
     625                 :         new_len = original_offset + length;
     626                 : 
     627                 :         if (new_len > YYLIMIT - SCNG(yy_start)) {
     628                 :                 unsigned char *new_yy_start = erealloc(SCNG(yy_start), new_len);
     629                 :                 SCNG(yy_cursor) = new_yy_start + (SCNG(yy_cursor) - SCNG(yy_start));
     630                 :                 SCNG(yy_marker) = new_yy_start + (SCNG(yy_marker) - SCNG(yy_start));
     631                 :                 SCNG(yy_text) = new_yy_start + (SCNG(yy_text) - SCNG(yy_start));
     632                 :                 SCNG(yy_start) = new_yy_start;
     633                 :                 SCNG(script_filtered) = new_yy_start;
     634                 :                 SCNG(script_filtered_size) = new_len;
     635                 :         }
     636                 : 
     637                 :         SCNG(yy_limit) = SCNG(yy_start) + new_len;
     638                 :         memmove(SCNG(yy_start) + original_offset, p, length);
     639                 : 
     640                 :         if (free_flag) {
     641                 :                 efree(p);
     642                 :         }
     643                 : }
     644                 : 
     645                 : 
     646                 : ZEND_API int zend_multibyte_yyinput(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC)
     647                 : {
     648                 :         size_t n;
     649                 : 
     650                 :         if (CG(interactive) == 0) {
     651                 :                 if (zend_stream_fixup(file_handle, &buf, &len TSRMLS_CC) == FAILURE) {
     652                 :                         return FAILURE;
     653                 :                 }
     654                 :                 n = len;
     655                 :                 return n;
     656                 :         }
     657                 : 
     658                 :         /* interactive */
     659                 :         if (SCNG(script_org)) {
     660                 :                 efree(SCNG(script_org));
     661                 :         }
     662                 :         if (SCNG(script_filtered)) {
     663                 :                 efree(SCNG(script_filtered));
     664                 :         }
     665                 :         SCNG(script_org) = NULL;
     666                 :         SCNG(script_org_size) = 0;
     667                 : 
     668                 :         /* TODO: support widechars */
     669                 :         if (zend_stream_fixup(file_handle, &buf, &len TSRMLS_CC) == FAILURE) {
     670                 :                 return FAILURE;
     671                 :         }
     672                 :         n = len;
     673                 : 
     674                 :         SCNG(script_org_size) = n;
     675                 :         SCNG(script_org) = (unsigned char*)emalloc(SCNG(script_org_size) + 1);
     676                 :         memcpy(SCNG(script_org), buf, n);
     677                 : 
     678                 :         return n;
     679                 : }
     680                 : 
     681                 : 
     682                 : ZEND_API int zend_multibyte_read_script(unsigned char *buf, size_t n TSRMLS_DC)
     683                 : {
     684                 :         if (SCNG(script_org)) {
     685                 :                 efree(SCNG(script_org));
     686                 :                 SCNG(script_org) = NULL;
     687                 :         }
     688                 :         SCNG(script_org_size) = n;      
     689                 :         
     690                 :         SCNG(script_org) = (unsigned char*)emalloc(SCNG(script_org_size) + 1);
     691                 :         memcpy(SCNG(script_org), buf, n);
     692                 :         *(SCNG(script_org)+SCNG(script_org_size)) = '\0';
     693                 : 
     694                 :         return 0;
     695                 : }
     696                 : 
     697                 : 
     698                 : # define zend_copy_value(zendlval, yytext, yyleng) \
     699                 :         if (SCNG(output_filter)) { \
     700                 :                 size_t sz = 0; \
     701                 :                 SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); \
     702                 :                 zendlval->value.str.len = sz; \
     703                 :         } else { \
     704                 :                 zendlval->value.str.val = (char *) estrndup(yytext, yyleng); \
     705                 :                 zendlval->value.str.len = yyleng; \
     706                 :         }
     707                 : #else /* ZEND_MULTIBYTE */
     708                 : # define zend_copy_value(zendlval, yytext, yyleng) \
     709                 :         zendlval->value.str.val = (char *)estrndup(yytext, yyleng); \
     710                 :         zendlval->value.str.len = yyleng;
     711                 : #endif /* ZEND_MULTIBYTE */
     712                 : 
     713                 : static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC)
     714          174105 : {
     715                 :         register char *s, *t;
     716                 :         char *end;
     717                 : 
     718          174105 :         ZVAL_STRINGL(zendlval, str, len, 1);
     719                 : 
     720                 :         /* convert escape sequences */
     721          174105 :         s = t = zendlval->value.str.val;
     722          174105 :         end = s+zendlval->value.str.len;
     723         3347931 :         while (s<end) {
     724         2999725 :                 if (*s=='\\') {
     725           52506 :                         s++;
     726           52506 :                         if (s >= end) {
     727               4 :                                 *t++ = '\\';
     728               4 :                                 break;
     729                 :                         }
     730                 : 
     731           52502 :                         switch(*s) {
     732                 :                                 case 'n':
     733           42918 :                                         *t++ = '\n';
     734           42918 :                                         zendlval->value.str.len--;
     735           42918 :                                         break;
     736                 :                                 case 'r':
     737            3477 :                                         *t++ = '\r';
     738            3477 :                                         zendlval->value.str.len--;
     739            3477 :                                         break;
     740                 :                                 case 't':
     741             622 :                                         *t++ = '\t';
     742             622 :                                         zendlval->value.str.len--;
     743             622 :                                         break;
     744                 :                                 case 'f':
     745              72 :                                         *t++ = '\f';
     746              72 :                                         zendlval->value.str.len--;
     747              72 :                                         break;
     748                 :                                 case 'v':
     749             106 :                                         *t++ = '\v';
     750             106 :                                         zendlval->value.str.len--;
     751             106 :                                         break;
     752                 :                                 case '"':
     753                 :                                 case '`':
     754            1073 :                                         if (*s != quote_type) {
     755               4 :                                                 *t++ = '\\';
     756               4 :                                                 *t++ = *s;
     757               4 :                                                 break;
     758                 :                                         }
     759                 :                                 case '\\':
     760                 :                                 case '$':
     761            2149 :                                         *t++ = *s;
     762            2149 :                                         zendlval->value.str.len--;
     763            2149 :                                         break;
     764                 :                                 case 'x':
     765                 :                                 case 'X':
     766            3467 :                                         if (ZEND_IS_HEX(*(s+1))) {
     767            1723 :                                                 char hex_buf[3] = { 0, 0, 0 };
     768                 : 
     769            1723 :                                                 zendlval->value.str.len--; /* for the 'x' */
     770                 : 
     771            1723 :                                                 hex_buf[0] = *(++s);
     772            1723 :                                                 zendlval->value.str.len--;
     773            1723 :                                                 if (ZEND_IS_HEX(*(s+1))) {
     774            1695 :                                                         hex_buf[1] = *(++s);
     775            1695 :                                                         zendlval->value.str.len--;
     776                 :                                                 }
     777            1723 :                                                 *t++ = (char) strtol(hex_buf, NULL, 16);
     778                 :                                         } else {
     779              21 :                                                 *t++ = '\\';
     780              21 :                                                 *t++ = *s;
     781                 :                                         }
     782            1744 :                                         break;
     783                 :                                 default:
     784                 :                                         /* check for an octal */
     785            2155 :                                         if (ZEND_IS_OCT(*s)) {
     786             745 :                                                 char octal_buf[4] = { 0, 0, 0, 0 };
     787                 : 
     788             745 :                                                 octal_buf[0] = *s;
     789             745 :                                                 zendlval->value.str.len--;
     790             745 :                                                 if (ZEND_IS_OCT(*(s+1))) {
     791             207 :                                                         octal_buf[1] = *(++s);
     792             207 :                                                         zendlval->value.str.len--;
     793             207 :                                                         if (ZEND_IS_OCT(*(s+1))) {
     794             182 :                                                                 octal_buf[2] = *(++s);
     795             182 :                                                                 zendlval->value.str.len--;
     796                 :                                                         }
     797                 :                                                 }
     798             745 :                                                 *t++ = (char) strtol(octal_buf, NULL, 8);
     799                 :                                         } else {
     800             665 :                                                 *t++ = '\\';
     801             665 :                                                 *t++ = *s;
     802                 :                                         }
     803                 :                                         break;
     804                 :                         }
     805                 :                 } else {
     806         2947219 :                         *t++ = *s;
     807                 :                 }
     808                 : 
     809         2999721 :                 if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) {
     810           10127 :                         CG(zend_lineno)++;
     811                 :                 }
     812         2999721 :                 s++;
     813                 :         }
     814          174105 :         *t = 0;
     815                 : #ifdef ZEND_MULTIBYTE
     816                 :         if (SCNG(output_filter)) {
     817                 :                 size_t sz = 0;
     818                 :                 s = zendlval->value.str.val;
     819                 :                 SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)s, (size_t)zendlval->value.str.len TSRMLS_CC);
     820                 :                 zendlval->value.str.len = sz;
     821                 :                 efree(s);
     822                 :         }
     823                 : #endif /* ZEND_MULTIBYTE */
     824          174105 : }
     825                 : 
     826                 : 
     827                 : int lex_scan(zval *zendlval TSRMLS_DC)
     828         5935882 : {
     829         5935882 : restart:
     830         5935882 :         SCNG(yy_text) = YYCURSOR;
     831                 : 
     832         5935888 : yymore_restart:
     833                 : 
     834                 : /*!re2c
     835                 : re2c:yyfill:check = 0;
     836                 : LNUM    [0-9]+
     837                 : DNUM    ([0-9]*"."[0-9]+)|([0-9]+"."[0-9]*)
     838                 : EXPONENT_DNUM   (({LNUM}|{DNUM})[eE][+-]?{LNUM})
     839                 : HNUM    "0x"[0-9a-fA-F]+
     840                 : LABEL   [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
     841                 : WHITESPACE [ \n\r\t]+
     842                 : TABS_AND_SPACES [ \t]*
     843                 : TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
     844                 : ANY_CHAR [^]
     845                 : NEWLINE ("\r"|"\n"|"\r\n")
     846                 : 
     847                 : /* compute yyleng before each rule */
     848                 : <!*> := yyleng = YYCURSOR - SCNG(yy_text);
     849                 : 
     850                 : 
     851                 : <ST_IN_SCRIPTING>"exit" {
     852            1358 :         return T_EXIT;
     853                 : }
     854                 : 
     855                 : <ST_IN_SCRIPTING>"die" {
     856           10963 :         return T_EXIT;
     857                 : }
     858                 : 
     859                 : <ST_IN_SCRIPTING>"function" {
     860           28783 :         return T_FUNCTION;
     861                 : }
     862                 : 
     863                 : <ST_IN_SCRIPTING>"const" {
     864             226 :         return T_CONST;
     865                 : }
     866                 : 
     867                 : <ST_IN_SCRIPTING>"return" {
     868           32556 :         return T_RETURN;
     869                 : }
     870                 : 
     871                 : <ST_IN_SCRIPTING>"try" {
     872            1855 :         return T_TRY;
     873                 : }
     874                 : 
     875                 : <ST_IN_SCRIPTING>"catch" {
     876            1862 :         return T_CATCH;
     877                 : }
     878                 : 
     879                 : <ST_IN_SCRIPTING>"throw" {
     880             238 :         return T_THROW;
     881                 : }
     882                 : 
     883                 : <ST_IN_SCRIPTING>"if" {
     884           57138 :         return T_IF;
     885                 : }
     886                 : 
     887                 : <ST_IN_SCRIPTING>"elseif" {
     888            1649 :         return T_ELSEIF;
     889                 : }
     890                 : 
     891                 : <ST_IN_SCRIPTING>"endif" {
     892               4 :         return T_ENDIF;
     893                 : }
     894                 : 
     895                 : <ST_IN_SCRIPTING>"else" {
     896           15145 :         return T_ELSE;
     897                 : }
     898                 : 
     899                 : <ST_IN_SCRIPTING>"while" {
     900             999 :         return T_WHILE;
     901                 : }
     902                 : 
     903                 : <ST_IN_SCRIPTING>"endwhile" {
     904               1 :         return T_ENDWHILE;
     905                 : }
     906                 : 
     907                 : <ST_IN_SCRIPTING>"do" {
     908             263 :         return T_DO;
     909                 : }
     910                 : 
     911                 : <ST_IN_SCRIPTING>"for" {
     912            1885 :         return T_FOR;
     913                 : }
     914                 : 
     915                 : <ST_IN_SCRIPTING>"endfor" {
     916               3 :         return T_ENDFOR;
     917                 : }
     918                 : 
     919                 : <ST_IN_SCRIPTING>"foreach" {
     920            8660 :         return T_FOREACH;
     921                 : }
     922                 : 
     923                 : <ST_IN_SCRIPTING>"endforeach" {
     924               0 :         return T_ENDFOREACH;
     925                 : }
     926                 : 
     927                 : <ST_IN_SCRIPTING>"declare" {
     928              12 :         return T_DECLARE;
     929                 : }
     930                 : 
     931                 : <ST_IN_SCRIPTING>"enddeclare" {
     932               0 :         return T_ENDDECLARE;
     933                 : }
     934                 : 
     935                 : <ST_IN_SCRIPTING>"instanceof" {
     936              61 :         return T_INSTANCEOF;
     937                 : }
     938                 : 
     939                 : <ST_IN_SCRIPTING>"as" {
     940            8689 :         return T_AS;
     941                 : }
     942                 : 
     943                 : <ST_IN_SCRIPTING>"switch" {
     944             441 :         return T_SWITCH;
     945                 : }
     946                 : 
     947                 : <ST_IN_SCRIPTING>"endswitch" {
     948               1 :         return T_ENDSWITCH;
     949                 : }
     950                 : 
     951                 : <ST_IN_SCRIPTING>"case" {
     952            1478 :         return T_CASE;
     953                 : }
     954                 : 
     955                 : <ST_IN_SCRIPTING>"default" {
     956             265 :         return T_DEFAULT;
     957                 : }
     958                 : 
     959                 : <ST_IN_SCRIPTING>"break" {
     960            1638 :         return T_BREAK;
     961                 : }
     962                 : 
     963                 : <ST_IN_SCRIPTING>"continue" {
     964             219 :         return T_CONTINUE;
     965                 : }
     966                 : 
     967                 : <ST_IN_SCRIPTING>"goto" {
     968              24 :         return T_GOTO;
     969                 : }
     970                 : 
     971                 : <ST_IN_SCRIPTING>"echo" {
     972           26377 :         return T_ECHO;
     973                 : }
     974                 : 
     975                 : <ST_IN_SCRIPTING>"print" {
     976            3003 :         return T_PRINT;
     977                 : }
     978                 : 
     979                 : <ST_IN_SCRIPTING>"class" {
     980            6099 :         return T_CLASS;
     981                 : }
     982                 : 
     983                 : <ST_IN_SCRIPTING>"interface" {
     984             156 :         return T_INTERFACE;
     985                 : }
     986                 : 
     987                 : <ST_IN_SCRIPTING>"extends" {
     988            2025 :         return T_EXTENDS;
     989                 : }
     990                 : 
     991                 : <ST_IN_SCRIPTING>"implements" {
     992             244 :         return T_IMPLEMENTS;
     993                 : }
     994                 : 
     995                 : <ST_IN_SCRIPTING>"->" {
     996           35107 :         yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
     997           35107 :         return T_OBJECT_OPERATOR;
     998                 : }
     999                 : 
    1000                 : <ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>{WHITESPACE}+ {
    1001         1746639 :         zendlval->value.str.val = yytext; /* no copying - intentional */
    1002         1746639 :         zendlval->value.str.len = yyleng;
    1003         1746639 :         zendlval->type = IS_STRING;
    1004         1746639 :         HANDLE_NEWLINES(yytext, yyleng);
    1005         1746639 :         return T_WHITESPACE;
    1006                 : }
    1007                 : 
    1008                 : <ST_LOOKING_FOR_PROPERTY>"->" {
    1009              59 :         return T_OBJECT_OPERATOR;
    1010                 : }
    1011                 : 
    1012                 : <ST_LOOKING_FOR_PROPERTY>{LABEL} {
    1013           35061 :         yy_pop_state(TSRMLS_C);
    1014           35061 :         zend_copy_value(zendlval, yytext, yyleng);
    1015           35061 :         zendlval->type = IS_STRING;
    1016           35061 :         return T_STRING;
    1017                 : }
    1018                 : 
    1019                 : <ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} {
    1020             105 :         yyless(0);
    1021             105 :         yy_pop_state(TSRMLS_C);
    1022             105 :         goto restart;
    1023                 : }
    1024                 : 
    1025                 : <ST_IN_SCRIPTING>"::" {
    1026           17915 :         return T_PAAMAYIM_NEKUDOTAYIM;
    1027                 : }
    1028                 : 
    1029                 : <ST_IN_SCRIPTING>"\\" {
    1030             482 :         return T_NS_SEPARATOR;
    1031                 : }
    1032                 : 
    1033                 : <ST_IN_SCRIPTING>"new" {
    1034           10263 :         return T_NEW;
    1035                 : }
    1036                 : 
    1037                 : <ST_IN_SCRIPTING>"clone" {
    1038              76 :         return T_CLONE;
    1039                 : }
    1040                 : 
    1041                 : <ST_IN_SCRIPTING>"var" {
    1042             123 :         return T_VAR;
    1043                 : }
    1044                 : 
    1045                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("int"|"integer"){TABS_AND_SPACES}")" {
    1046            4516 :         return T_INT_CAST;
    1047                 : }
    1048                 : 
    1049                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("real"|"double"|"float"){TABS_AND_SPACES}")" {
    1050              22 :         return T_DOUBLE_CAST;
    1051                 : }
    1052                 : 
    1053                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"string"{TABS_AND_SPACES}")" {
    1054             380 :         return T_STRING_CAST;
    1055                 : }
    1056                 : 
    1057                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"binary"{TABS_AND_SPACES}")" {
    1058             929 :         return T_STRING_CAST;
    1059                 : }
    1060                 : 
    1061                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"array"{TABS_AND_SPACES}")" {
    1062              10 :         return T_ARRAY_CAST;
    1063                 : }
    1064                 : 
    1065                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"object"{TABS_AND_SPACES}")" {
    1066             144 :         return T_OBJECT_CAST;
    1067                 : }
    1068                 : 
    1069                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" {
    1070             242 :         return T_BOOL_CAST;
    1071                 : }
    1072                 : 
    1073                 : <ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("unset"){TABS_AND_SPACES}")" {
    1074               1 :         return T_UNSET_CAST;
    1075                 : }
    1076                 : 
    1077                 : <ST_IN_SCRIPTING>"eval" {
    1078            1897 :         return T_EVAL;
    1079                 : }
    1080                 : 
    1081                 : <ST_IN_SCRIPTING>"include" {
    1082            1711 :         return T_INCLUDE;
    1083                 : }
    1084                 : 
    1085                 : <ST_IN_SCRIPTING>"include_once" {
    1086             480 :         return T_INCLUDE_ONCE;
    1087                 : }
    1088                 : 
    1089                 : <ST_IN_SCRIPTING>"require" {
    1090            1232 :         return T_REQUIRE;
    1091                 : }
    1092                 : 
    1093                 : <ST_IN_SCRIPTING>"require_once" {
    1094            5256 :         return T_REQUIRE_ONCE;
    1095                 : }
    1096                 : 
    1097                 : <ST_IN_SCRIPTING>"namespace" {
    1098             185 :         return T_NAMESPACE;
    1099                 : }
    1100                 : 
    1101                 : <ST_IN_SCRIPTING>"use" {
    1102              68 :         return T_USE;
    1103                 : }
    1104                 : 
    1105                 : <ST_IN_SCRIPTING>"global" {
    1106            3789 :         return T_GLOBAL;
    1107                 : }
    1108                 : 
    1109                 : <ST_IN_SCRIPTING>"isset" {
    1110            1887 :         return T_ISSET;
    1111                 : }
    1112                 : 
    1113                 : <ST_IN_SCRIPTING>"empty" {
    1114            5436 :         return T_EMPTY;
    1115                 : }
    1116                 : 
    1117                 : <ST_IN_SCRIPTING>"__halt_compiler" {
    1118             273 :         return T_HALT_COMPILER;
    1119                 : }
    1120                 : 
    1121                 : <ST_IN_SCRIPTING>"static" {
    1122            6845 :         return T_STATIC;
    1123                 : }
    1124                 : 
    1125                 : <ST_IN_SCRIPTING>"abstract" {
    1126             111 :         return T_ABSTRACT;
    1127                 : }
    1128                 : 
    1129                 : <ST_IN_SCRIPTING>"final" {
    1130              36 :         return T_FINAL;
    1131                 : }
    1132                 : 
    1133                 : <ST_IN_SCRIPTING>"private" {
    1134             628 :         return T_PRIVATE;
    1135                 : }
    1136                 : 
    1137                 : <ST_IN_SCRIPTING>"protected" {
    1138             541 :         return T_PROTECTED;
    1139                 : }
    1140                 : 
    1141                 : <ST_IN_SCRIPTING>"public" {
    1142            3380 :         return T_PUBLIC;
    1143                 : }
    1144                 : 
    1145                 : <ST_IN_SCRIPTING>"unset" {
    1146            1419 :         return T_UNSET;
    1147                 : }
    1148                 : 
    1149                 : <ST_IN_SCRIPTING>"=>" {
    1150           28388 :         return T_DOUBLE_ARROW;
    1151                 : }
    1152                 : 
    1153                 : <ST_IN_SCRIPTING>"list" {
    1154             114 :         return T_LIST;
    1155                 : }
    1156                 : 
    1157                 : <ST_IN_SCRIPTING>"array" {
    1158           21747 :         return T_ARRAY;
    1159                 : }
    1160                 : 
    1161                 : <ST_IN_SCRIPTING>"++" {
    1162            5690 :         return T_INC;
    1163                 : }
    1164                 : 
    1165                 : <ST_IN_SCRIPTING>"--" {
    1166              65 :         return T_DEC;
    1167                 : }
    1168                 : 
    1169                 : <ST_IN_SCRIPTING>"===" {
    1170            5202 :         return T_IS_IDENTICAL;
    1171                 : }
    1172                 : 
    1173                 : <ST_IN_SCRIPTING>"!==" {
    1174            6697 :         return T_IS_NOT_IDENTICAL;
    1175                 : }
    1176                 : 
    1177                 : <ST_IN_SCRIPTING>"==" {
    1178            9473 :         return T_IS_EQUAL;
    1179                 : }
    1180                 : 
    1181                 : <ST_IN_SCRIPTING>"!="|"<>" {
    1182            2438 :         return T_IS_NOT_EQUAL;
    1183                 : }
    1184                 : 
    1185                 : <ST_IN_SCRIPTING>"<=" {
    1186            1611 :         return T_IS_SMALLER_OR_EQUAL;
    1187                 : }
    1188                 : 
    1189                 : <ST_IN_SCRIPTING>">=" {
    1190             258 :         return T_IS_GREATER_OR_EQUAL;
    1191                 : }
    1192                 : 
    1193                 : <ST_IN_SCRIPTING>"+=" {
    1194             620 :         return T_PLUS_EQUAL;
    1195                 : }
    1196                 : 
    1197                 : <ST_IN_SCRIPTING>"-=" {
    1198             139 :         return T_MINUS_EQUAL;
    1199                 : }
    1200                 : 
    1201                 : <ST_IN_SCRIPTING>"*=" {
    1202              13 :         return T_MUL_EQUAL;
    1203                 : }
    1204                 : 
    1205                 : <ST_IN_SCRIPTING>"/=" {
    1206               4 :         return T_DIV_EQUAL;
    1207                 : }
    1208                 : 
    1209                 : <ST_IN_SCRIPTING>".=" {
    1210            2416 :         return T_CONCAT_EQUAL;
    1211                 : }
    1212                 : 
    1213                 : <ST_IN_SCRIPTING>"%=" {
    1214               1 :         return T_MOD_EQUAL;
    1215                 : }
    1216                 : 
    1217                 : <ST_IN_SCRIPTING>"<<=" {
    1218               4 :         return T_SL_EQUAL;
    1219                 : }
    1220                 : 
    1221                 : <ST_IN_SCRIPTING>">>=" {
    1222               5 :         return T_SR_EQUAL;
    1223                 : }
    1224                 : 
    1225                 : <ST_IN_SCRIPTING>"&=" {
    1226               3 :         return T_AND_EQUAL;
    1227                 : }
    1228                 : 
    1229                 : <ST_IN_SCRIPTING>"|=" {
    1230              96 :         return T_OR_EQUAL;
    1231                 : }
    1232                 : 
    1233                 : <ST_IN_SCRIPTING>"^=" {
    1234               2 :         return T_XOR_EQUAL;
    1235                 : }
    1236                 : 
    1237                 : <ST_IN_SCRIPTING>"||" {
    1238            1135 :         return T_BOOLEAN_OR;
    1239                 : }
    1240                 : 
    1241                 : <ST_IN_SCRIPTING>"&&" {
    1242            3112 :         return T_BOOLEAN_AND;
    1243                 : }
    1244                 : 
    1245                 : <ST_IN_SCRIPTING>"OR" {
    1246             690 :         return T_LOGICAL_OR;
    1247                 : }
    1248                 : 
    1249                 : <ST_IN_SCRIPTING>"AND" {
    1250              12 :         return T_LOGICAL_AND;
    1251                 : }
    1252                 : 
    1253                 : <ST_IN_SCRIPTING>"XOR" {
    1254               1 :         return T_LOGICAL_XOR;
    1255                 : }
    1256                 : 
    1257                 : <ST_IN_SCRIPTING>"<<" {
    1258             110 :         return T_SL;
    1259                 : }
    1260                 : 
    1261                 : <ST_IN_SCRIPTING>">>" {
    1262              35 :         return T_SR;
    1263                 : }
    1264                 : 
    1265                 : <ST_IN_SCRIPTING>{TOKENS} {
    1266         1926666 :         return yytext[0];
    1267                 : }
    1268                 : 
    1269                 : 
    1270                 : <ST_IN_SCRIPTING>"{" {
    1271           96256 :         yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
    1272           96256 :         return '{';
    1273                 : }
    1274                 : 
    1275                 : 
    1276                 : <ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"${" {
    1277              87 :         yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC);
    1278              87 :         return T_DOLLAR_OPEN_CURLY_BRACES;
    1279                 : }
    1280                 : 
    1281                 : 
    1282                 : <ST_IN_SCRIPTING>"}" {
    1283           96552 :         RESET_DOC_COMMENT();
    1284           96552 :         if (!zend_stack_is_empty(&SCNG(state_stack))) {
    1285           96551 :                 yy_pop_state(TSRMLS_C);
    1286                 :         }
    1287           96552 :         return '}';
    1288                 : }
    1289                 : 
    1290                 : 
    1291                 : <ST_LOOKING_FOR_VARNAME>{LABEL} {
    1292              87 :         zend_copy_value(zendlval, yytext, yyleng);
    1293              87 :         zendlval->type = IS_STRING;
    1294              87 :         yy_pop_state(TSRMLS_C);
    1295              87 :         yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
    1296              87 :         return T_STRING_VARNAME;
    1297                 : }
    1298                 : 
    1299                 : 
    1300                 : <ST_LOOKING_FOR_VARNAME>{ANY_CHAR} {
    1301               0 :         yyless(0);
    1302               0 :         yy_pop_state(TSRMLS_C);
    1303               0 :         yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
    1304               0 :         goto restart;
    1305                 : }
    1306                 : 
    1307                 : 
    1308                 : <ST_IN_SCRIPTING>{LNUM} {
    1309           78519 :         if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */
    1310           77697 :                 zendlval->value.lval = strtol(yytext, NULL, 0);
    1311                 :         } else {
    1312             822 :                 errno = 0;
    1313             822 :                 zendlval->value.lval = strtol(yytext, NULL, 0);
    1314             822 :                 if (errno == ERANGE) { /* Overflow */
    1315             443 :                         if (yytext[0] == '0') { /* octal overflow */
    1316              83 :                                 zendlval->value.dval = zend_oct_strtod(yytext, NULL);
    1317                 :                         } else {
    1318             360 :                                 zendlval->value.dval = zend_strtod(yytext, NULL);
    1319                 :                         }
    1320             443 :                         zendlval->type = IS_DOUBLE;
    1321             443 :                         return T_DNUMBER;
    1322                 :                 }
    1323                 :         }
    1324                 : 
    1325           78076 :         zendlval->type = IS_LONG;
    1326           78076 :         return T_LNUMBER;
    1327                 : }
    1328                 : 
    1329                 : <ST_IN_SCRIPTING>{HNUM} {
    1330            1405 :         char *hex = yytext + 2; /* Skip "0x" */
    1331            1405 :         int len = yyleng - 2;
    1332                 : 
    1333                 :         /* Skip any leading 0s */
    1334            3514 :         while (*hex == '0') {
    1335             704 :                 hex++;
    1336             704 :                 len--;
    1337                 :         }
    1338                 : 
    1339            1405 :         if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) {
    1340            1308 :                 zendlval->value.lval = strtol(hex, NULL, 16);
    1341            1308 :                 zendlval->type = IS_LONG;
    1342            1308 :                 return T_LNUMBER;
    1343                 :         } else {
    1344              97 :                 zendlval->value.dval = zend_hex_strtod(hex, NULL);
    1345              97 :                 zendlval->type = IS_DOUBLE;
    1346              97 :                 return T_DNUMBER;
    1347                 :         }
    1348                 : }
    1349                 : 
    1350                 : <ST_VAR_OFFSET>[0]|([1-9][0-9]*) { /* Offset could be treated as a long */
    1351             608 :         if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) {
    1352             304 :                 zendlval->value.lval = strtol(yytext, NULL, 10);
    1353             304 :                 zendlval->type = IS_LONG;
    1354                 :         } else {
    1355               0 :                 zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
    1356               0 :                 zendlval->value.str.len = yyleng;
    1357               0 :                 zendlval->type = IS_STRING;
    1358                 :         }
    1359             304 :         return T_NUM_STRING;
    1360                 : }
    1361                 : 
    1362                 : <ST_VAR_OFFSET>{LNUM}|{HNUM} { /* Offset must be treated as a string */
    1363               0 :         zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
    1364               0 :         zendlval->value.str.len = yyleng;
    1365               0 :         zendlval->type = IS_STRING;
    1366               0 :         return T_NUM_STRING;
    1367                 : }
    1368                 : 
    1369                 : <ST_IN_SCRIPTING>{DNUM}|{EXPONENT_DNUM} {
    1370            7028 :         zendlval->value.dval = zend_strtod(yytext, NULL);
    1371            7028 :         zendlval->type = IS_DOUBLE;
    1372            7028 :         return T_DNUMBER;
    1373                 : }
    1374                 : 
    1375                 : <ST_IN_SCRIPTING>"__CLASS__" {
    1376              74 :         char *class_name = NULL;
    1377                 : 
    1378              74 :         if (CG(active_class_entry)) {
    1379              73 :                 class_name = CG(active_class_entry)->name;
    1380                 :         }
    1381                 : 
    1382              74 :         if (!class_name) {
    1383               1 :                 class_name = "";
    1384                 :         }
    1385              74 :         zendlval->value.str.len = strlen(class_name);
    1386              74 :         zendlval->value.str.val = estrndup(class_name, zendlval->value.str.len);
    1387              74 :         zendlval->type = IS_STRING;
    1388              74 :         return T_CLASS_C;
    1389                 : }
    1390                 : 
    1391                 : <ST_IN_SCRIPTING>"__FUNCTION__" {
    1392              98 :         char *func_name = NULL;
    1393                 : 
    1394              98 :         if (CG(active_op_array)) {
    1395              97 :                 func_name = CG(active_op_array)->function_name;
    1396                 :         }
    1397                 : 
    1398              98 :         if (!func_name) {
    1399               2 :                 func_name = "";
    1400                 :         }
    1401              98 :         zendlval->value.str.len = strlen(func_name);
    1402              98 :         zendlval->value.str.val = estrndup(func_name, zendlval->value.str.len);
    1403              98 :         zendlval->type = IS_STRING;
    1404              98 :         return T_FUNC_C;
    1405                 : }
    1406                 : 
    1407                 : <ST_IN_SCRIPTING>"__METHOD__" {
    1408             769 :         char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL;
    1409             769 :         char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL;
    1410             769 :         size_t len = 0;
    1411                 : 
    1412             769 :         if (class_name) {
    1413             746 :                 len += strlen(class_name) + 2;
    1414                 :         }
    1415             769 :         if (func_name) {
    1416             767 :                 len += strlen(func_name);
    1417                 :         }
    1418                 : 
    1419             769 :         zendlval->value.str.len = zend_spprintf(&zendlval->value.str.val, 0, "%s%s%s", 
    1420                 :                 class_name ? class_name : "",
    1421                 :                 class_name && func_name ? "::" : "",
    1422                 :                 func_name ? func_name : ""
    1423                 :                 );
    1424             769 :         zendlval->type = IS_STRING;
    1425             769 :         return T_METHOD_C;
    1426                 : }
    1427                 : 
    1428                 : <ST_IN_SCRIPTING>"__LINE__" {
    1429              16 :         zendlval->value.lval = CG(zend_lineno);
    1430              16 :         zendlval->type = IS_LONG;
    1431              16 :         return T_LINE;
    1432                 : }
    1433                 : 
    1434                 : <ST_IN_SCRIPTING>"__FILE__" {
    1435            7553 :         char *filename = zend_get_compiled_filename(TSRMLS_C);
    1436                 : 
    1437            7553 :         if (!filename) {
    1438               0 :                 filename = "";
    1439                 :         }
    1440            7553 :         zendlval->value.str.len = strlen(filename);
    1441            7553 :         zendlval->value.str.val = estrndup(filename, zendlval->value.str.len);
    1442            7553 :         zendlval->type = IS_STRING;
    1443            7553 :         return T_FILE;
    1444                 : }
    1445                 : 
    1446                 : <ST_IN_SCRIPTING>"__DIR__" {
    1447             122 :         char *filename = zend_get_compiled_filename(TSRMLS_C);
    1448             122 :         const size_t filename_len = strlen(filename);
    1449                 :         char *dirname;
    1450                 : 
    1451             122 :         if (!filename) {
    1452               0 :                 filename = "";
    1453                 :         }
    1454                 : 
    1455             122 :         dirname = estrndup(filename, filename_len);
    1456             122 :         zend_dirname(dirname, filename_len);
    1457                 : 
    1458             122 :         if (strcmp(dirname, ".") == 0) {
    1459               0 :                 dirname = erealloc(dirname, MAXPATHLEN);
    1460                 : #if HAVE_GETCWD
    1461               0 :                 VCWD_GETCWD(dirname, MAXPATHLEN);
    1462                 : #elif HAVE_GETWD
    1463                 :                 VCWD_GETWD(dirname);
    1464                 : #endif
    1465                 :         }
    1466                 : 
    1467             122 :         zendlval->value.str.len = strlen(dirname);
    1468             122 :         zendlval->value.str.val = dirname;
    1469             122 :         zendlval->type = IS_STRING;
    1470             122 :         return T_DIR;
    1471                 : }
    1472                 : 
    1473                 : <ST_IN_SCRIPTING>"__NAMESPACE__" {
    1474              33 :         if (CG(current_namespace)) {
    1475              25 :                 *zendlval = *CG(current_namespace);
    1476              25 :                 zval_copy_ctor(zendlval);
    1477                 :         } else {
    1478               8 :                 ZVAL_EMPTY_STRING(zendlval);
    1479                 :         }
    1480              33 :         return T_NS_C;
    1481                 : }
    1482                 : 
    1483                 : <INITIAL>"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"'php'"){WHITESPACE}*">" {
    1484               5 :         YYCTYPE *bracket = zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1));
    1485                 : 
    1486               5 :         if (bracket != SCNG(yy_text)) {
    1487                 :                 /* Handle previously scanned HTML, as possible <script> tags found are assumed to not be PHP's */
    1488               1 :                 YYCURSOR = bracket;
    1489               1 :                 goto inline_html;
    1490                 :         }
    1491                 : 
    1492               4 :         HANDLE_NEWLINES(yytext, yyleng);
    1493               4 :         zendlval->value.str.val = yytext; /* no copying - intentional */
    1494               4 :         zendlval->value.str.len = yyleng;
    1495               4 :         zendlval->type = IS_STRING;
    1496               4 :         BEGIN(ST_IN_SCRIPTING);
    1497               4 :         return T_OPEN_TAG;
    1498                 : }
    1499                 : 
    1500                 : 
    1501                 : <INITIAL>"<%=" {
    1502               2 :         if (CG(asp_tags)) {
    1503               2 :                 zendlval->value.str.val = yytext; /* no copying - intentional */
    1504               2 :                 zendlval->value.str.len = yyleng;
    1505               2 :                 zendlval->type = IS_STRING;
    1506               2 :                 BEGIN(ST_IN_SCRIPTING);
    1507               2 :                 return T_OPEN_TAG_WITH_ECHO;
    1508                 :         } else {
    1509               0 :                 goto inline_char_handler;
    1510                 :         }
    1511                 : }
    1512                 : 
    1513                 : 
    1514                 : <INITIAL>"<?=" {
    1515               4 :         if (CG(short_tags)) {
    1516               3 :                 zendlval->value.str.val = yytext; /* no copying - intentional */
    1517               3 :                 zendlval->value.str.len = yyleng;
    1518               3 :                 zendlval->type = IS_STRING;
    1519               3 :                 BEGIN(ST_IN_SCRIPTING);
    1520               3 :                 return T_OPEN_TAG_WITH_ECHO;
    1521                 :         } else {
    1522               1 :                 goto inline_char_handler;
    1523                 :         }
    1524                 : }
    1525                 : 
    1526                 : 
    1527                 : <INITIAL>"<%" {
    1528               0 :         if (CG(asp_tags)) {
    1529               0 :                 zendlval->value.str.val = yytext; /* no copying - intentional */
    1530               0 :                 zendlval->value.str.len = yyleng;
    1531               0 :                 zendlval->type = IS_STRING;
    1532               0 :                 BEGIN(ST_IN_SCRIPTING);
    1533               0 :                 return T_OPEN_TAG;
    1534                 :         } else {
    1535               0 :                 goto inline_char_handler;
    1536                 :         }
    1537                 : }
    1538                 : 
    1539                 : 
    1540                 : <INITIAL>"<?php"([ \t]|{NEWLINE}) {
    1541           25697 :         zendlval->value.str.val = yytext; /* no copying - intentional */
    1542           25697 :         zendlval->value.str.len = yyleng;
    1543           25697 :         zendlval->type = IS_STRING;
    1544           25697 :         HANDLE_NEWLINE(yytext[yyleng-1]);
    1545           25697 :         BEGIN(ST_IN_SCRIPTING);
    1546           25697 :         return T_OPEN_TAG;
    1547                 : }
    1548                 : 
    1549                 : 
    1550                 : <INITIAL>"<?" {
    1551               5 :         if (CG(short_tags)) {
    1552               4 :                 zendlval->value.str.val = yytext; /* no copying - intentional */
    1553               4 :                 zendlval->value.str.len = yyleng;
    1554               4 :                 zendlval->type = IS_STRING;
    1555               4 :                 BEGIN(ST_IN_SCRIPTING);
    1556               4 :                 return T_OPEN_TAG;
    1557                 :         } else {
    1558               1 :                 goto inline_char_handler;
    1559                 :         }
    1560                 : }
    1561                 : 
    1562                 : <INITIAL>{ANY_CHAR} {
    1563           27662 :         if (YYCURSOR > YYLIMIT) {
    1564           24402 :                 return 0;
    1565                 :         }
    1566                 : 
    1567            3371 : inline_char_handler:
    1568                 : 
    1569                 :         while (1) {
    1570            3371 :                 YYCTYPE *ptr = memchr(YYCURSOR, '<', YYLIMIT - YYCURSOR);
    1571                 : 
    1572            3371 :                 YYCURSOR = ptr ? ptr + 1 : YYLIMIT;
    1573                 : 
    1574            3371 :                 if (YYCURSOR < YYLIMIT) {
    1575             333 :                         switch (*YYCURSOR) {
    1576                 :                                 case '?':
    1577             218 :                                         if (CG(short_tags) || !strncasecmp(YYCURSOR + 1, "php", 3)) { /* Assume [ \t\n\r] follows "php" */
    1578                 :                                                 break;
    1579                 :                                         }
    1580               2 :                                         continue;
    1581                 :                                 case '%':
    1582               4 :                                         if (CG(asp_tags)) {
    1583               2 :                                                 break;
    1584                 :                                         }
    1585               2 :                                         continue;
    1586                 :                                 case 's':
    1587                 :                                 case 'S':
    1588                 :                                         /* Probably NOT an opening PHP <script> tag, so don't end the HTML chunk yet
    1589                 :                                          * If it is, the PHP <script> tag rule checks for any HTML scanned before it */
    1590               6 :                                         YYCURSOR--;
    1591               6 :                                         yymore();
    1592                 :                                 default:
    1593             105 :                                         continue;
    1594                 :                         }
    1595                 : 
    1596             218 :                         YYCURSOR--;
    1597                 :                 }
    1598                 : 
    1599            3256 :                 break;
    1600             109 :         }
    1601                 : 
    1602            3257 : inline_html:
    1603            3257 :         yyleng = YYCURSOR - SCNG(yy_text);
    1604                 : 
    1605                 : #ifdef ZEND_MULTIBYTE
    1606                 :         if (SCNG(output_filter)) {
    1607                 :                 int readsize;
    1608                 :                 size_t sz = 0;
    1609                 :                 readsize = SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC);
    1610                 :                 zendlval->value.str.len = sz;
    1611                 :                 if (readsize < yyleng) {
    1612                 :                         yyless(readsize);
    1613                 :                 }
    1614                 :         } else {
    1615                 :           zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
    1616                 :           zendlval->value.str.len = yyleng;
    1617                 :         }
    1618                 : #else /* !ZEND_MULTIBYTE */
    1619            3257 :         zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
    1620            3257 :         zendlval->value.str.len = yyleng;
    1621                 : #endif
    1622            3257 :         zendlval->type = IS_STRING;
    1623            3257 :         HANDLE_NEWLINES(yytext, yyleng);
    1624            3257 :         return T_INLINE_HTML;
    1625                 : }
    1626                 : 
    1627                 : 
    1628                 : /* Make sure a label character follows "->", otherwise there is no property
    1629                 :  * and "->" will be taken literally
    1630                 :  */
    1631                 : <ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"->"[a-zA-Z_\x7f-\xff] {
    1632              59 :         yyless(yyleng - 3);
    1633              59 :         yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
    1634              59 :         zend_copy_value(zendlval, (yytext+1), (yyleng-1));
    1635              59 :         zendlval->type = IS_STRING;
    1636              59 :         return T_VARIABLE;
    1637                 : }
    1638                 : 
    1639                 : /* A [ always designates a variable offset, regardless of what follows
    1640                 :  */
    1641                 : <ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"[" {
    1642             886 :         yyless(yyleng - 1);
    1643             886 :         yy_push_state(ST_VAR_OFFSET TSRMLS_CC);
    1644             886 :         zend_copy_value(zendlval, (yytext+1), (yyleng-1));
    1645             886 :         zendlval->type = IS_STRING;
    1646             886 :         return T_VARIABLE;
    1647                 : }
    1648                 : 
    1649                 : <ST_IN_SCRIPTING,ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE,ST_VAR_OFFSET>"$"{LABEL} {
    1650          604997 :         zend_copy_value(zendlval, (yytext+1), (yyleng-1));
    1651          604997 :         zendlval->type = IS_STRING;
    1652          604997 :         return T_VARIABLE;
    1653                 : }
    1654                 : 
    1655                 : <ST_VAR_OFFSET>"]" {
    1656             884 :         yy_pop_state(TSRMLS_C);
    1657             884 :         return ']';
    1658                 : }
    1659                 : 
    1660                 : <ST_VAR_OFFSET>{TOKENS}|[{}"`] {
    1661                 :         /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */
    1662             886 :         return yytext[0];
    1663                 : }
    1664                 : 
    1665                 : <ST_VAR_OFFSET>[ \n\r\t\\'#] {
    1666                 :         /* Invalid rule to return a more explicit parse error with proper line number */
    1667               2 :         yyless(0);
    1668               2 :         yy_pop_state(TSRMLS_C);
    1669               2 :         return T_ENCAPSED_AND_WHITESPACE;
    1670                 : }
    1671                 : 
    1672                 : <ST_IN_SCRIPTING,ST_VAR_OFFSET>{LABEL} {
    1673          380428 :         zend_copy_value(zendlval, yytext, yyleng);
    1674          380428 :         zendlval->type = IS_STRING;
    1675          380428 :         return T_STRING;
    1676                 : }
    1677                 : 
    1678                 : 
    1679                 : <ST_IN_SCRIPTING>"#"|"//" {
    1680         1346166 :         while (YYCURSOR < YYLIMIT) {
    1681         1305088 :                 switch (*YYCURSOR++) {
    1682                 :                         case '\r':
    1683             116 :                                 if (*YYCURSOR == '\n') {
    1684             116 :                                         YYCURSOR++;
    1685                 :                                 }
    1686                 :                                 /* fall through */
    1687                 :                         case '\n':
    1688           41066 :                                 CG(zend_lineno)++;
    1689           41066 :                                 break;
    1690                 :                         case '%':
    1691              26 :                                 if (!CG(asp_tags)) {
    1692              26 :                                         continue;
    1693                 :                                 }
    1694                 :                                 /* fall through */
    1695                 :                         case '?':
    1696             512 :                                 if (*YYCURSOR == '>') {
    1697               2 :                                         YYCURSOR--;
    1698               2 :                                         break;
    1699                 :                                 }
    1700                 :                                 /* fall through */
    1701                 :                         default:
    1702         1263994 :                                 continue;
    1703                 :                 }
    1704                 : 
    1705           41068 :                 break;
    1706                 :         }
    1707                 : 
    1708           41073 :         yyleng = YYCURSOR - SCNG(yy_text);
    1709                 : 
    1710           41073 :         return T_COMMENT;
    1711                 : }
    1712                 : 
    1713                 : <ST_IN_SCRIPTING>"/*"|"/**"{WHITESPACE} {
    1714                 :         int doc_com;
    1715                 : 
    1716           22697 :         if (yyleng > 2) {
    1717            2048 :                 doc_com = 1;
    1718            2048 :                 RESET_DOC_COMMENT();
    1719                 :         } else {
    1720           20649 :                 doc_com = 0;
    1721                 :         }
    1722                 : 
    1723         3635049 :         while (YYCURSOR < YYLIMIT) {
    1724         3612351 :                 if (*YYCURSOR++ == '*' && *YYCURSOR == '/') {
    1725           22696 :                         break;
    1726                 :                 }
    1727                 :         }
    1728                 : 
    1729           22697 :         if (YYCURSOR < YYLIMIT) {
    1730           22696 :                 YYCURSOR++;
    1731                 :         } else {
    1732               1 :                 zend_error(E_COMPILE_WARNING, "Unterminated comment starting line %d", CG(zend_lineno));
    1733                 :         }
    1734                 : 
    1735           22697 :         yyleng = YYCURSOR - SCNG(yy_text);
    1736           22697 :         HANDLE_NEWLINES(yytext, yyleng);
    1737                 : 
    1738           22697 :         if (doc_com) {
    1739            2048 :                 CG(doc_comment) = estrndup(yytext, yyleng);
    1740            2048 :                 CG(doc_comment_len) = yyleng;
    1741            2048 :                 return T_DOC_COMMENT;
    1742                 :         }
    1743                 : 
    1744           20649 :         return T_COMMENT;
    1745                 : }
    1746                 : 
    1747                 : <ST_IN_SCRIPTING>("?>"|"</script"{WHITESPACE}*">"){NEWLINE}? {
    1748           24723 :         zendlval->value.str.val = yytext; /* no copying - intentional */
    1749           24723 :         zendlval->value.str.len = yyleng;
    1750           24723 :         zendlval->type = IS_STRING;
    1751           24723 :         BEGIN(INITIAL);
    1752           24723 :         return T_CLOSE_TAG;  /* implicit ';' at php-end tag */
    1753                 : }
    1754                 : 
    1755                 : 
    1756                 : <ST_IN_SCRIPTING>"%>"{NEWLINE}? {
    1757               2 :         if (CG(asp_tags)) {
    1758               2 :                 BEGIN(INITIAL);
    1759               2 :                 zendlval->value.str.len = yyleng;
    1760               2 :                 zendlval->type = IS_STRING;
    1761               2 :                 zendlval->value.str.val = yytext; /* no copying - intentional */
    1762               2 :                 return T_CLOSE_TAG;  /* implicit ';' at php-end tag */
    1763                 :         } else {
    1764               0 :                 yyless(1);
    1765               0 :                 return yytext[0];
    1766                 :         }
    1767                 : }
    1768                 : 
    1769                 : 
    1770                 : <ST_IN_SCRIPTING>b?['] {
    1771                 :         register char *s, *t;
    1772                 :         char *end;
    1773          197348 :         int bprefix = (yytext[0] != '\'') ? 1 : 0;
    1774                 : 
    1775                 :         while (1) {
    1776         1942902 :                 if (YYCURSOR < YYLIMIT) {
    1777         1942902 :                         if (*YYCURSOR == '\'') {
    1778          197348 :                                 YYCURSOR++;
    1779          197348 :                                 yyleng = YYCURSOR - SCNG(yy_text);
    1780                 : 
    1781                 :                                 break;
    1782         1745554 :                         } else if (*YYCURSOR++ == '\\' && YYCURSOR < YYLIMIT) {
    1783           11576 :                                 YYCURSOR++;
    1784                 :                         }
    1785                 :                 } else {
    1786               0 :                         yyleng = YYLIMIT - SCNG(yy_text);
    1787                 : 
    1788                 :                         /* Unclosed single quotes; treat similar to double quotes, but without a separate token
    1789                 :                          * for ' (unrecognized by parser), instead of old flex fallback to "Unexpected character..."
    1790                 :                          * rule, which continued in ST_IN_SCRIPTING state after the quote */
    1791               0 :                         return T_ENCAPSED_AND_WHITESPACE;
    1792                 :                 }
    1793         1745554 :         }
    1794                 : 
    1795          197348 :         zendlval->value.str.val = estrndup(yytext+bprefix+1, yyleng-bprefix-2);
    1796          197348 :         zendlval->value.str.len = yyleng-bprefix-2;
    1797          197348 :         zendlval->type = IS_STRING;
    1798                 : 
    1799                 :         /* convert escape sequences */
    1800          197348 :         s = t = zendlval->value.str.val;
    1801          197348 :         end = s+zendlval->value.str.len;
    1802         2140250 :         while (s<end) {
    1803         1745554 :                 if (*s=='\\') {
    1804           11576 :                         s++;
    1805                 : 
    1806           11576 :                         switch(*s) {
    1807                 :                                 case '\\':
    1808                 :                                 case '\'':
    1809            1288 :                                         *t++ = *s;
    1810            1288 :                                         zendlval->value.str.len--;
    1811            1288 :                                         break;
    1812                 :                                 default:
    1813           10288 :                                         *t++ = '\\';
    1814           10288 :                                         *t++ = *s;
    1815                 :                                         break;
    1816                 :                         }
    1817                 :                 } else {
    1818         1733978 :                         *t++ = *s;
    1819                 :                 }
    1820                 : 
    1821         1745554 :                 if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) {
    1822            1191 :                         CG(zend_lineno)++;
    1823                 :                 }
    1824         1745554 :                 s++;
    1825                 :         }
    1826          197348 :         *t = 0;
    1827                 : 
    1828                 : #ifdef ZEND_MULTIBYTE
    1829                 :         if (SCNG(output_filter)) {
    1830                 :                 size_t sz = 0;
    1831                 :                 s = zendlval->value.str.val;
    1832                 :                 SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)s, (size_t)zendlval->value.str.len TSRMLS_CC);
    1833                 :                 zendlval->value.str.len = sz;
    1834                 :                 efree(s);
    1835                 :         }
    1836                 : #endif /* ZEND_MULTIBYTE */
    1837          197348 :         return T_CONSTANT_ENCAPSED_STRING;
    1838                 : }
    1839                 : 
    1840                 : 
    1841                 : <ST_IN_SCRIPTING>b?["] {
    1842          163782 :         int bprefix = (yytext[0] != '"') ? 1 : 0;
    1843                 : 
    1844         2950208 :         while (YYCURSOR < YYLIMIT) {
    1845         2786425 :                 switch (*YYCURSOR++) {
    1846                 :                         case '"':
    1847          152607 :                                 yyleng = YYCURSOR - SCNG(yy_text);
    1848          152607 :                                 zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC);
    1849          152607 :                                 return T_CONSTANT_ENCAPSED_STRING;
    1850                 :                         case '$':
    1851           11366 :                                 if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') {
    1852                 :                                         break;
    1853                 :                                 }
    1854             391 :                                 continue;
    1855                 :                         case '{':
    1856             352 :                                 if (*YYCURSOR == '$') {
    1857             199 :                                         break;
    1858                 :                                 }
    1859             153 :                                 continue;
    1860                 :                         case '\\':
    1861           45809 :                                 if (YYCURSOR < YYLIMIT) {
    1862           45809 :                                         YYCURSOR++;
    1863                 :                                 }
    1864                 :                                 /* fall through */
    1865                 :                         default:
    1866         2622100 :                                 continue;
    1867                 :                 }
    1868                 : 
    1869           11174 :                 YYCURSOR--;
    1870           11174 :                 break;
    1871                 :         }
    1872                 : 
    1873                 :         /* Remember how much was scanned to save rescanning */
    1874           11175 :         SET_DOUBLE_QUOTES_SCANNED_LENGTH(YYCURSOR - SCNG(yy_text) - yyleng);
    1875                 : 
    1876           11175 :         YYCURSOR = SCNG(yy_text) + yyleng;
    1877                 : 
    1878           11175 :         BEGIN(ST_DOUBLE_QUOTES);
    1879           11175 :         return '"';
    1880                 : }
    1881                 : 
    1882                 : 
    1883                 : <ST_IN_SCRIPTING>b?"<<<"{TABS_AND_SPACES}({LABEL}|([']{LABEL}['])|(["]{LABEL}["])){NEWLINE} {
    1884                 :         char *s;
    1885            1404 :         int bprefix = (yytext[0] != '<') ? 1 : 0;
    1886                 : 
    1887                 :         /* save old heredoc label */
    1888            1404 :         Z_STRVAL_P(zendlval) = CG(heredoc);
    1889            1404 :         Z_STRLEN_P(zendlval) = CG(heredoc_len);
    1890                 : 
    1891            1404 :         CG(zend_lineno)++;
    1892            1404 :         CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0);
    1893            1404 :         s = yytext+bprefix+3;
    1894            2830 :         while ((*s == ' ') || (*s == '\t')) {
    1895              22 :                 s++;
    1896              22 :                 CG(heredoc_len)--;
    1897                 :         }
    1898                 : 
    1899            1404 :         if (*s == '\'') {
    1900              41 :                 s++;
    1901              41 :                 CG(heredoc_len) -= 2;
    1902                 : 
    1903              41 :                 BEGIN(ST_NOWDOC);
    1904                 :         } else {
    1905            1363 :                 if (*s == '"') {
    1906               7 :                         s++;
    1907               7 :                         CG(heredoc_len) -= 2;
    1908                 :                 }
    1909                 : 
    1910            1363 :                 BEGIN(ST_HEREDOC);
    1911                 :         }
    1912                 : 
    1913            1404 :         CG(heredoc) = estrndup(s, CG(heredoc_len));
    1914                 : 
    1915                 :         /* Check for ending label on the next line */
    1916            1404 :         if (CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, CG(heredoc_len))) {
    1917              67 :                 YYCTYPE *end = YYCURSOR + CG(heredoc_len);
    1918                 : 
    1919              67 :                 if (*end == ';') {
    1920              62 :                         end++;
    1921                 :                 }
    1922                 : 
    1923              67 :                 if (*end == '\n' || *end == '\r') {
    1924              63 :                         BEGIN(ST_END_HEREDOC);
    1925                 :                 }
    1926                 :         }
    1927                 : 
    1928            1404 :         return T_START_HEREDOC;
    1929                 : }
    1930                 : 
    1931                 : 
    1932                 : <ST_IN_SCRIPTING>[`] {
    1933             104 :         BEGIN(ST_BACKQUOTE);
    1934             104 :         return '`';
    1935                 : }
    1936                 : 
    1937                 : 
    1938                 : <ST_END_HEREDOC>{ANY_CHAR} {
    1939            1402 :         YYCURSOR += CG(heredoc_len) - 1;
    1940            1402 :         yyleng = CG(heredoc_len);
    1941                 : 
    1942            1402 :         Z_STRVAL_P(zendlval) = CG(heredoc);
    1943            1402 :         Z_STRLEN_P(zendlval) = CG(heredoc_len);
    1944            1402 :         CG(heredoc) = NULL;
    1945            1402 :         CG(heredoc_len) = 0;
    1946            1402 :         BEGIN(ST_IN_SCRIPTING);
    1947            1402 :         return T_END_HEREDOC;
    1948                 : }
    1949                 : 
    1950                 : 
    1951                 : <ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" {
    1952             281 :         zendlval->value.lval = (long) '{';
    1953             281 :         yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
    1954             281 :         yyless(1);
    1955             281 :         return T_CURLY_OPEN;
    1956                 : }
    1957                 : 
    1958                 : 
    1959                 : <ST_DOUBLE_QUOTES>["] {
    1960           11172 :         BEGIN(ST_IN_SCRIPTING);
    1961           11172 :         return '"';
    1962                 : }
    1963                 : 
    1964                 : <ST_BACKQUOTE>[`] {
    1965             104 :         BEGIN(ST_IN_SCRIPTING);
    1966             104 :         return '`';
    1967                 : }
    1968                 : 
    1969                 : 
    1970                 : <ST_DOUBLE_QUOTES>{ANY_CHAR} {
    1971           19567 :         if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) {
    1972            7445 :                 YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1;
    1973            7445 :                 SET_DOUBLE_QUOTES_SCANNED_LENGTH(0);
    1974                 : 
    1975            7445 :                 goto double_quotes_scan_done;
    1976                 :         }
    1977                 : 
    1978           12122 :         if (YYCURSOR > YYLIMIT) {
    1979               1 :                 return 0;
    1980                 :         }
    1981           12121 :         if (yytext[0] == '\\' && YYCURSOR < YYLIMIT) {
    1982            1452 :                 YYCURSOR++;
    1983                 :         }
    1984                 : 
    1985           75966 :         while (YYCURSOR < YYLIMIT) {
    1986           63845 :                 switch (*YYCURSOR++) {
    1987                 :                         case '"':
    1988            6970 :                                 break;
    1989                 :                         case '$':
    1990            5109 :                                 if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') {
    1991                 :                                         break;
    1992                 :                                 }
    1993               1 :                                 continue;
    1994                 :                         case '{':
    1995              57 :                                 if (*YYCURSOR == '$') {
    1996              43 :                                         break;
    1997                 :                                 }
    1998              14 :                                 continue;
    1999                 :                         case '\\':
    2000            4615 :                                 if (YYCURSOR < YYLIMIT) {
    2001            4615 :                                         YYCURSOR++;
    2002                 :                                 }
    2003                 :                                 /* fall through */
    2004                 :                         default:
    2005           51709 :                                 continue;
    2006                 :                 }
    2007                 : 
    2008           12121 :                 YYCURSOR--;
    2009           12121 :                 break;
    2010                 :         }
    2011                 : 
    2012           19566 : double_quotes_scan_done:
    2013           19566 :         yyleng = YYCURSOR - SCNG(yy_text);
    2014                 : 
    2015           19566 :         zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC);
    2016           19566 :         return T_ENCAPSED_AND_WHITESPACE;
    2017                 : }
    2018                 : 
    2019                 : 
    2020                 : <ST_BACKQUOTE>{ANY_CHAR} {
    2021             167 :         if (YYCURSOR > YYLIMIT) {
    2022               0 :                 return 0;
    2023                 :         }
    2024             167 :         if (yytext[0] == '\\' && YYCURSOR < YYLIMIT) {
    2025               0 :                 YYCURSOR++;
    2026                 :         }
    2027                 : 
    2028            2486 :         while (YYCURSOR < YYLIMIT) {
    2029            2319 :                 switch (*YYCURSOR++) {
    2030                 :                         case '`':
    2031              91 :                                 break;
    2032                 :                         case '$':
    2033              76 :                                 if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') {
    2034                 :                                         break;
    2035                 :                                 }
    2036               0 :                                 continue;
    2037                 :                         case '{':
    2038               4 :                                 if (*YYCURSOR == '$') {
    2039               0 :                                         break;
    2040                 :                                 }
    2041               4 :                                 continue;
    2042                 :                         case '\\':
    2043               6 :                                 if (YYCURSOR < YYLIMIT) {
    2044               6 :                                         YYCURSOR++;
    2045                 :                                 }
    2046                 :                                 /* fall through */
    2047                 :                         default:
    2048            2148 :                                 continue;
    2049                 :                 }
    2050                 : 
    2051             167 :                 YYCURSOR--;
    2052             167 :                 break;
    2053                 :         }
    2054                 : 
    2055             167 :         yyleng = YYCURSOR - SCNG(yy_text);
    2056                 : 
    2057             167 :         zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC);
    2058             167 :         return T_ENCAPSED_AND_WHITESPACE;
    2059                 : }
    2060                 : 
    2061                 : 
    2062                 : <ST_HEREDOC>{ANY_CHAR} {
    2063            1765 :         int newline = 0;
    2064                 : 
    2065            1765 :         if (YYCURSOR > YYLIMIT) {
    2066               0 :                 return 0;
    2067                 :         }
    2068                 : 
    2069            1765 :         YYCURSOR--;
    2070                 : 
    2071          318258 :         while (YYCURSOR < YYLIMIT) {
    2072          316493 :                 switch (*YYCURSOR++) {
    2073                 :                         case '\r':
    2074               0 :                                 if (*YYCURSOR == '\n') {
    2075               0 :                                         YYCURSOR++;
    2076                 :                                 }
    2077                 :                                 /* fall through */
    2078                 :                         case '\n':
    2079                 :                                 /* Check for ending label on the next line */
    2080            9397 :                                 if (IS_LABEL_START(*YYCURSOR) && CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, CG(heredoc), CG(heredoc_len))) {
    2081            1307 :                                         YYCTYPE *end = YYCURSOR + CG(heredoc_len);
    2082                 : 
    2083            1307 :                                         if (*end == ';') {
    2084            1286 :                                                 end++;
    2085                 :                                         }
    2086                 : 
    2087            1307 :                                         if (*end == '\n' || *end == '\r') {
    2088                 :                                                 /* newline before label will be subtracted from returned text, but
    2089                 :                                                  * yyleng/yytext will include it, for zend_highlight/strip, tokenizer, etc. */
    2090            1303 :                                                 if (YYCURSOR[-2] == '\r' && YYCURSOR[-1] == '\n') {
    2091               0 :                                                         newline = 2; /* Windows newline */
    2092                 :                                                 } else {
    2093            1303 :                                                         newline = 1;
    2094                 :                                                 }
    2095                 : 
    2096            1303 :                                                 CG(increment_lineno) = 1; /* For newline before label */
    2097            1303 :                                                 BEGIN(ST_END_HEREDOC);
    2098                 : 
    2099            1303 :                                                 goto heredoc_scan_done;
    2100                 :                                         }
    2101                 :                                 }
    2102            8094 :                                 continue;
    2103                 :                         case '$':
    2104             517 :                                 if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') {
    2105                 :                                         break;
    2106                 :                                 }
    2107              78 :                                 continue;
    2108                 :                         case '{':
    2109              48 :                                 if (*YYCURSOR == '$') {
    2110              23 :                                         break;
    2111                 :                                 }
    2112              25 :                                 continue;
    2113                 :                         case '\\':
    2114             624 :                                 if (YYCURSOR < YYLIMIT && *YYCURSOR != '\n' && *YYCURSOR != '\r') {
    2115             616 :                                         YYCURSOR++;
    2116                 :                                 }
    2117                 :                                 /* fall through */
    2118                 :                         default:
    2119          306531 :                                 continue;
    2120                 :                 }
    2121                 : 
    2122             462 :                 YYCURSOR--;
    2123             462 :                 break;
    2124                 :         }
    2125                 : 
    2126            1765 : heredoc_scan_done:
    2127            1765 :         yyleng = YYCURSOR - SCNG(yy_text);
    2128                 : 
    2129            1765 :         zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC);
    2130            1765 :         return T_ENCAPSED_AND_WHITESPACE;
    2131                 : }
    2132                 : 
    2133                 : 
    2134                 : <ST_NOWDOC>{ANY_CHAR} {
    2135              36 :         int newline = 0;
    2136                 : 
    2137              36 :         if (YYCURSOR > YYLIMIT) {
    2138               0 :                 return 0;
    2139                 :         }
    2140                 : 
    2141              36 :         YYCURSOR--;
    2142                 : 
    2143            1402 :         while (YYCURSOR < YYLIMIT) {
    2144            1366 :                 switch (*YYCURSOR++) {
    2145                 :                         case '\r':
    2146               0 :                                 if (*YYCURSOR == '\n') {
    2147               0 :                                         YYCURSOR++;
    2148                 :                                 }
    2149                 :                                 /* fall through */
    2150                 :                         case '\n':
    2151                 :                                 /* Check for ending label on the next line */
    2152              94 :                                 if (IS_LABEL_START(*YYCURSOR) && CG(heredoc_len) < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, CG(heredoc), CG(heredoc_len))) {
    2153              41 :                                         YYCTYPE *end = YYCURSOR + CG(heredoc_len);
    2154                 : 
    2155              41 :                                         if (*end == ';') {
    2156              33 :                                                 end++;
    2157                 :                                         }
    2158                 : 
    2159              41 :                                         if (*end == '\n' || *end == '\r') {
    2160                 :                                                 /* newline before label will be subtracted from returned text, but
    2161                 :                                                  * yyleng/yytext will include it, for zend_highlight/strip, tokenizer, etc. */
    2162              36 :                                                 if (YYCURSOR[-2] == '\r' && YYCURSOR[-1] == '\n') {
    2163               0 :                                                         newline = 2; /* Windows newline */
    2164                 :                                                 } else {
    2165              36 :                                                         newline = 1;
    2166                 :                                                 }
    2167                 : 
    2168              36 :                                                 CG(increment_lineno) = 1; /* For newline before label */
    2169              36 :                                                 BEGIN(ST_END_HEREDOC);
    2170                 : 
    2171              36 :                                                 goto nowdoc_scan_done;
    2172                 :                                         }
    2173                 :                                 }
    2174                 :                                 /* fall through */
    2175                 :                         default:
    2176                 :                                 continue;
    2177                 :                 }
    2178                 :         }
    2179                 : 
    2180              36 : nowdoc_scan_done:
    2181              36 :         yyleng = YYCURSOR - SCNG(yy_text);
    2182                 : 
    2183              36 :         zend_copy_value(zendlval, yytext, yyleng - newline);
    2184              36 :         zendlval->type = IS_STRING;
    2185              36 :         HANDLE_NEWLINES(yytext, yyleng - newline);
    2186              36 :         return T_ENCAPSED_AND_WHITESPACE;
    2187                 : }
    2188                 : 
    2189                 : 
    2190                 : <ST_IN_SCRIPTING,ST_VAR_OFFSET>{ANY_CHAR} {
    2191            1526 :         if (YYCURSOR > YYLIMIT) {
    2192            1526 :                 return 0;
    2193                 :         }
    2194                 : 
    2195               0 :         zend_error(E_COMPILE_WARNING,"Unexpected character in input:  '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE);
    2196               0 :         goto restart;
    2197                 : }
    2198                 : 
    2199                 : */
    2200                 : }

Generated by: LTP GCOV extension version 1.5

Generated at Sat, 21 Nov 2009 12:27:14 +0000 (3 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.