com php-src: made lang scanner use zend_int.h and regen erated it: Zend/zend_int.h Zend/zend_language_s canner.c Zend/zend_language_scanner.l
Zend/zend_l anguage_scanner_defs.h

From: Date: Thu, 18 Jul 2013 09:52:15 +0000
Subject: com php-src: made lang scanner use zend_int.h and regen erated it: Zend/zend_int.h Zend/zend_language_s canner.c Zend/zend_language_scanner.l
Zend/zend_l anguage_scanner_defs.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-73641@lists.php.net to get a copy of this message
Commit: 13cb1b7e4ac8f21b798d49c2cee5a0cbd84c3f3d Author: Anatol Belski <ab@php.net> Thu, 18 Jul 2013 02:52:15 -0700 Parents: 4bcc5a87d7703d3e4823d048c193165078d63a71 Branches: str_size_and_int64 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=13cb1b7e4ac8f21b798d49c2cee5a0cbd84c3f3d Log: made lang scanner use zend_int.h and regenerated it Changed paths: M Zend/zend_int.h M Zend/zend_language_scanner.c M Zend/zend_language_scanner.l M Zend/zend_language_scanner_defs.h

diff --git a/Zend/zend_int.h b/Zend/zend_int.h index 3397c14..e9b3723 100644 --- a/Zend/zend_int.h +++ b/Zend/zend_int.h @@ -45,6 +45,7 @@ typedef unsigned long zend_uint_t; # ifdef PHP_WIN32 # define ZEND_ITOA(i, s, len) _i64toa_s((i), (s), (len), 10) # define ZEND_ATOI(i, s) i = _atoi64((s)) +# define ZEND_STRTOL(s0, s1, base) _strtoi64((s0), (s1), (base)) # else # define ZEND_ITOA(i, s, len) \ do { \ @@ -52,8 +53,10 @@ typedef unsigned long zend_uint_t; (s)[st] = '\0'; \ } while (0) # define ZEND_ATOI(i, s) (i) = atoll((s)) +# define ZEND_STRTOL(s0, s1, base) strtoll((s0), (s1), (base)) # endif #else +# define ZEND_STRTOL(s0, s1, base) strtol((s0), (s1), (base)) # ifdef PHP_WIN32 # define ZEND_ITOA(i, s, len) _ltoa_s((i), (s), (len), 10) # define ZEND_ATOI(i, s) i = atol((s)) diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c index deb799a..502d0e1 100644 --- a/Zend/zend_language_scanner.c +++ b/Zend/zend_language_scanner.c @@ -1,5 +1,4 @@ /* Generated by re2c 0.13.5 */ -#line 1 "Zend/zend_language_scanner.l" /* +----------------------------------------------------------------------+ | Zend Engine | @@ -950,7 +949,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo hex_buf[1] = *(++s); zendlval->value.str.len--; } - *t++ = (char) strtol(hex_buf, NULL, 16); + *t++ = (char) ZEND_STRTOL(hex_buf, NULL, 16); } else { *t++ = '\\'; *t++ = *s; @@ -971,7 +970,7 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo zendlval->value.str.len--; } } - *t++ = (char) strtol(octal_buf, NULL, 8); + *t++ = (char) ZEND_STRTOL(octal_buf, NULL, 8); } else { *t++ = '\\'; *t++ = *s; @@ -1006,7 +1005,6 @@ restart: yymore_restart: -#line 1010 "Zend/zend_language_scanner.c" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1105,7 +1103,6 @@ yyc_INITIAL: yy3: YYDEBUG(3, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1807 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -1165,7 +1162,6 @@ inline_html: HANDLE_NEWLINES(yytext, yyleng); return T_INLINE_HTML; } -#line 1169 "Zend/zend_language_scanner.c" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -1183,7 +1179,6 @@ yy5: yy6: YYDEBUG(6, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1795 "Zend/zend_language_scanner.l" { if (CG(short_tags)) { zendlval->value.str.val = yytext; /* no copying - intentional */ @@ -1195,14 +1190,12 @@ yy6: goto inline_char_handler; } } -#line 1199 "Zend/zend_language_scanner.c" yy7: YYDEBUG(7, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) == '=') goto yy43; YYDEBUG(8, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1772 "Zend/zend_language_scanner.l" { if (CG(asp_tags)) { zendlval->value.str.val = yytext; /* no copying - intentional */ @@ -1214,7 +1207,6 @@ yy7: goto inline_char_handler; } } -#line 1218 "Zend/zend_language_scanner.c" yy9: YYDEBUG(9, *YYCURSOR); yych = *++YYCURSOR; @@ -1400,7 +1392,6 @@ yy35: ++YYCURSOR; YYDEBUG(38, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1732 "Zend/zend_language_scanner.l" { YYCTYPE *bracket = (YYCTYPE*)zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1)); @@ -1417,7 +1408,6 @@ yy35: BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG; } -#line 1421 "Zend/zend_language_scanner.c" yy39: YYDEBUG(39, *YYCURSOR); yych = *++YYCURSOR; @@ -1444,7 +1434,6 @@ yy43: ++YYCURSOR; YYDEBUG(44, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1750 "Zend/zend_language_scanner.l" { if (CG(asp_tags)) { zendlval->value.str.val = yytext; /* no copying - intentional */ @@ -1456,13 +1445,11 @@ yy43: goto inline_char_handler; } } -#line 1460 "Zend/zend_language_scanner.c" yy45: YYDEBUG(45, *YYCURSOR); ++YYCURSOR; YYDEBUG(46, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1763 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -1470,7 +1457,6 @@ yy45: BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG_WITH_ECHO; } -#line 1474 "Zend/zend_language_scanner.c" yy47: YYDEBUG(47, *YYCURSOR); yych = *++YYCURSOR; @@ -1497,7 +1483,6 @@ yy50: yy51: YYDEBUG(51, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1785 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -1506,7 +1491,6 @@ yy51: BEGIN(ST_IN_SCRIPTING); return T_OPEN_TAG; } -#line 1510 "Zend/zend_language_scanner.c" yy52: YYDEBUG(52, *YYCURSOR); ++YYCURSOR; @@ -1577,7 +1561,6 @@ yyc_ST_BACKQUOTE: yy56: YYDEBUG(56, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2258 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -1618,7 +1601,6 @@ yy56: zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1622 "Zend/zend_language_scanner.c" yy57: YYDEBUG(57, *YYCURSOR); yych = *++YYCURSOR; @@ -1629,12 +1611,10 @@ yy58: ++YYCURSOR; YYDEBUG(59, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2202 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return '`'; } -#line 1638 "Zend/zend_language_scanner.c" yy60: YYDEBUG(60, *YYCURSOR); yych = *++YYCURSOR; @@ -1644,14 +1624,12 @@ yy61: ++YYCURSOR; YYDEBUG(62, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2189 "Zend/zend_language_scanner.l" { zendlval->value.lval = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1655 "Zend/zend_language_scanner.c" yy63: YYDEBUG(63, *YYCURSOR); yyaccept = 0; @@ -1667,24 +1645,20 @@ yy63: yy65: YYDEBUG(65, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1889 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1677 "Zend/zend_language_scanner.c" yy66: YYDEBUG(66, *YYCURSOR); ++YYCURSOR; YYDEBUG(67, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1465 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1688 "Zend/zend_language_scanner.c" yy68: YYDEBUG(68, *YYCURSOR); yych = *++YYCURSOR; @@ -1698,7 +1672,6 @@ yy70: ++YYCURSOR; YYDEBUG(71, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1881 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); @@ -1706,7 +1679,6 @@ yy70: zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1710 "Zend/zend_language_scanner.c" yy72: YYDEBUG(72, *YYCURSOR); yych = *++YYCURSOR; @@ -1724,7 +1696,6 @@ yy73: ++YYCURSOR; YYDEBUG(74, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1871 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); @@ -1732,7 +1703,6 @@ yy73: zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1736 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_DOUBLE_QUOTES: @@ -1800,7 +1770,6 @@ yy77: yy78: YYDEBUG(78, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2208 "Zend/zend_language_scanner.l" { if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) { YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1; @@ -1849,7 +1818,6 @@ double_quotes_scan_done: zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 1853 "Zend/zend_language_scanner.c" yy79: YYDEBUG(79, *YYCURSOR); yych = *++YYCURSOR; @@ -1860,12 +1828,10 @@ yy80: ++YYCURSOR; YYDEBUG(81, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2197 "Zend/zend_language_scanner.l" { BEGIN(ST_IN_SCRIPTING); return '"'; } -#line 1869 "Zend/zend_language_scanner.c" yy82: YYDEBUG(82, *YYCURSOR); yych = *++YYCURSOR; @@ -1875,14 +1841,12 @@ yy83: ++YYCURSOR; YYDEBUG(84, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2189 "Zend/zend_language_scanner.l" { zendlval->value.lval = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 1886 "Zend/zend_language_scanner.c" yy85: YYDEBUG(85, *YYCURSOR); yyaccept = 0; @@ -1898,24 +1862,20 @@ yy85: yy87: YYDEBUG(87, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1889 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1908 "Zend/zend_language_scanner.c" yy88: YYDEBUG(88, *YYCURSOR); ++YYCURSOR; YYDEBUG(89, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1465 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 1919 "Zend/zend_language_scanner.c" yy90: YYDEBUG(90, *YYCURSOR); yych = *++YYCURSOR; @@ -1929,7 +1889,6 @@ yy92: ++YYCURSOR; YYDEBUG(93, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1881 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); @@ -1937,7 +1896,6 @@ yy92: zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1941 "Zend/zend_language_scanner.c" yy94: YYDEBUG(94, *YYCURSOR); yych = *++YYCURSOR; @@ -1955,7 +1913,6 @@ yy95: ++YYCURSOR; YYDEBUG(96, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1871 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); @@ -1963,7 +1920,6 @@ yy95: zendlval->type = IS_STRING; return T_VARIABLE; } -#line 1967 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_END_HEREDOC: @@ -1974,7 +1930,6 @@ yyc_ST_END_HEREDOC: ++YYCURSOR; YYDEBUG(100, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2175 "Zend/zend_language_scanner.l" { zend_heredoc_label *heredoc_label = zend_ptr_stack_pop(&SCNG(heredoc_label_stack)); @@ -1987,7 +1942,6 @@ yyc_ST_END_HEREDOC: BEGIN(ST_IN_SCRIPTING); return T_END_HEREDOC; } -#line 1991 "Zend/zend_language_scanner.c" /* *********************************** */ yyc_ST_HEREDOC: { @@ -2049,7 +2003,6 @@ yy103: yy104: YYDEBUG(104, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2300 "Zend/zend_language_scanner.l" { int newline = 0; @@ -2122,7 +2075,6 @@ heredoc_scan_done: zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); return T_ENCAPSED_AND_WHITESPACE; } -#line 2126 "Zend/zend_language_scanner.c" yy105: YYDEBUG(105, *YYCURSOR); yych = *++YYCURSOR; @@ -2137,14 +2089,12 @@ yy107: ++YYCURSOR; YYDEBUG(108, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2189 "Zend/zend_language_scanner.l" { zendlval->value.lval = (long) '{'; yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); yyless(1); return T_CURLY_OPEN; } -#line 2148 "Zend/zend_language_scanner.c" yy109: YYDEBUG(109, *YYCURSOR); yyaccept = 0; @@ -2160,24 +2110,20 @@ yy109: yy111: YYDEBUG(111, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1889 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 2170 "Zend/zend_language_scanner.c" yy112: YYDEBUG(112, *YYCURSOR); ++YYCURSOR; YYDEBUG(113, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1465 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); return T_DOLLAR_OPEN_CURLY_BRACES; } -#line 2181 "Zend/zend_language_scanner.c" yy114: YYDEBUG(114, *YYCURSOR); yych = *++YYCURSOR; @@ -2191,7 +2137,6 @@ yy116: ++YYCURSOR; YYDEBUG(117, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1881 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); yy_push_state(ST_VAR_OFFSET TSRMLS_CC); @@ -2199,7 +2144,6 @@ yy116: zendlval->type = IS_STRING; return T_VARIABLE; } -#line 2203 "Zend/zend_language_scanner.c" yy118: YYDEBUG(118, *YYCURSOR); yych = *++YYCURSOR; @@ -2217,7 +2161,6 @@ yy119: ++YYCURSOR; YYDEBUG(120, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1871 "Zend/zend_language_scanner.l" { yyless(yyleng - 3); yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); @@ -2225,7 +2168,6 @@ yy119: zendlval->type = IS_STRING; return T_VARIABLE; } -#line 2229 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_IN_SCRIPTING: @@ -2408,13 +2350,11 @@ yy123: yy124: YYDEBUG(124, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1912 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; return T_STRING; } -#line 2418 "Zend/zend_language_scanner.c" yy125: YYDEBUG(125, *YYCURSOR); yych = *++YYCURSOR; @@ -2646,11 +2586,9 @@ yy138: yy139: YYDEBUG(139, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1454 "Zend/zend_language_scanner.l" { return yytext[0]; } -#line 2654 "Zend/zend_language_scanner.c" yy140: YYDEBUG(140, *YYCURSOR); ++YYCURSOR; @@ -2659,7 +2597,6 @@ yy140: yy141: YYDEBUG(141, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1185 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -2667,7 +2604,6 @@ yy141: HANDLE_NEWLINES(yytext, yyleng); return T_WHITESPACE; } -#line 2671 "Zend/zend_language_scanner.c" yy142: YYDEBUG(142, *YYCURSOR); yych = *++YYCURSOR; @@ -2678,11 +2614,9 @@ yy143: ++YYCURSOR; YYDEBUG(144, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1214 "Zend/zend_language_scanner.l" { return T_NS_SEPARATOR; } -#line 2686 "Zend/zend_language_scanner.c" yy145: YYDEBUG(145, *YYCURSOR); yych = *++YYCURSOR; @@ -2910,18 +2844,15 @@ yy168: ++YYCURSOR; YYDEBUG(169, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1459 "Zend/zend_language_scanner.l" { yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); return '{'; } -#line 2919 "Zend/zend_language_scanner.c" yy170: YYDEBUG(170, *YYCURSOR); ++YYCURSOR; YYDEBUG(171, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1471 "Zend/zend_language_scanner.l" { RESET_DOC_COMMENT(); if (!zend_stack_is_empty(&SCNG(state_stack))) { @@ -2929,7 +2860,6 @@ yy170: } return '}'; } -#line 2933 "Zend/zend_language_scanner.c" yy172: YYDEBUG(172, *YYCURSOR); yyaccept = 2; @@ -2957,13 +2887,12 @@ yy172: yy173: YYDEBUG(173, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1522 "Zend/zend_language_scanner.l" { if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ - zendlval->value.lval = strtol(yytext, NULL, 0); + zendlval->value.lval = ZEND_STRTOL(yytext, NULL, 0); } else { errno = 0; - zendlval->value.lval = strtol(yytext, NULL, 0); + zendlval->value.lval = ZEND_STRTOL(yytext, NULL, 0); if (errno == ERANGE) { /* Overflow */ if (yytext[0] == '0') { /* octal overflow */ zendlval->value.dval = zend_oct_strtod(yytext, NULL); @@ -2978,7 +2907,6 @@ yy173: zendlval->type = IS_LONG; return T_LNUMBER; } -#line 2982 "Zend/zend_language_scanner.c" yy174: YYDEBUG(174, *YYCURSOR); yyaccept = 2; @@ -3006,7 +2934,6 @@ yy176: yy177: YYDEBUG(177, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1919 "Zend/zend_language_scanner.l" { while (YYCURSOR < YYLIMIT) { switch (*YYCURSOR++) { @@ -3040,14 +2967,12 @@ yy177: return T_COMMENT; } -#line 3044 "Zend/zend_language_scanner.c" yy178: YYDEBUG(178, *YYCURSOR); ++YYCURSOR; yy179: YYDEBUG(179, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2010 "Zend/zend_language_scanner.l" { register char *s, *t; char *end; @@ -3115,14 +3040,12 @@ yy179: } return T_CONSTANT_ENCAPSED_STRING; } -#line 3119 "Zend/zend_language_scanner.c" yy180: YYDEBUG(180, *YYCURSOR); ++YYCURSOR; yy181: YYDEBUG(181, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2079 "Zend/zend_language_scanner.l" { int bprefix = (yytext[0] != '"') ? 1 : 0; @@ -3163,24 +3086,20 @@ yy181: BEGIN(ST_DOUBLE_QUOTES); return '"'; } -#line 3167 "Zend/zend_language_scanner.c" yy182: YYDEBUG(182, *YYCURSOR); ++YYCURSOR; YYDEBUG(183, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2169 "Zend/zend_language_scanner.l" { BEGIN(ST_BACKQUOTE); return '`'; } -#line 3178 "Zend/zend_language_scanner.c" yy184: YYDEBUG(184, *YYCURSOR); ++YYCURSOR; YYDEBUG(185, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2432 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -3189,7 +3108,6 @@ yy184: zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); goto restart; } -#line 3193 "Zend/zend_language_scanner.c" yy186: YYDEBUG(186, *YYCURSOR); ++YYCURSOR; @@ -3216,13 +3134,11 @@ yy188: yy190: YYDEBUG(190, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1587 "Zend/zend_language_scanner.l" { zendlval->value.dval = zend_strtod(yytext, NULL); zendlval->type = IS_DOUBLE; return T_DNUMBER; } -#line 3226 "Zend/zend_language_scanner.c" yy191: YYDEBUG(191, *YYCURSOR); yyaccept = 2; @@ -3314,7 +3230,6 @@ yy200: } YYDEBUG(202, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1497 "Zend/zend_language_scanner.l" { char *bin = yytext + 2; /* Skip "0b" */ int len = yyleng - 2; @@ -3329,7 +3244,7 @@ yy200: if (len == 0) { zendlval->value.lval = 0; } else { - zendlval->value.lval = strtol(bin, NULL, 2); + zendlval->value.lval = ZEND_STRTOL(bin, NULL, 2); } zendlval->type = IS_LONG; return T_LNUMBER; @@ -3339,7 +3254,6 @@ yy200: return T_DNUMBER; } } -#line 3343 "Zend/zend_language_scanner.c" yy203: YYDEBUG(203, *YYCURSOR); ++YYCURSOR; @@ -3351,7 +3265,6 @@ yy203: } YYDEBUG(205, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1543 "Zend/zend_language_scanner.l" { char *hex = yytext + 2; /* Skip "0x" */ int len = yyleng - 2; @@ -3366,7 +3279,7 @@ yy203: if (len == 0) { zendlval->value.lval = 0; } else { - zendlval->value.lval = strtol(hex, NULL, 16); + zendlval->value.lval = ZEND_STRTOL(hex, NULL, 16); } zendlval->type = IS_LONG; return T_LNUMBER; @@ -3376,7 +3289,6 @@ yy203: return T_DNUMBER; } } -#line 3380 "Zend/zend_language_scanner.c" yy206: YYDEBUG(206, *YYCURSOR); ++YYCURSOR; @@ -3385,7 +3297,6 @@ yy206: yy207: YYDEBUG(207, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1987 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -3393,7 +3304,6 @@ yy207: BEGIN(INITIAL); return T_CLOSE_TAG; /* implicit ';' at php-end tag */ } -#line 3397 "Zend/zend_language_scanner.c" yy208: YYDEBUG(208, *YYCURSOR); yych = *++YYCURSOR; @@ -3427,13 +3337,11 @@ yy210: yy212: YYDEBUG(212, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1889 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 3437 "Zend/zend_language_scanner.c" yy213: YYDEBUG(213, *YYCURSOR); yych = *++YYCURSOR; @@ -3447,11 +3355,9 @@ yy214: } YYDEBUG(215, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1442 "Zend/zend_language_scanner.l" { return T_LOGICAL_XOR; } -#line 3455 "Zend/zend_language_scanner.c" yy216: YYDEBUG(216, *YYCURSOR); ++YYCURSOR; @@ -3460,61 +3366,49 @@ yy216: } YYDEBUG(217, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1434 "Zend/zend_language_scanner.l" { return T_LOGICAL_OR; } -#line 3468 "Zend/zend_language_scanner.c" yy218: YYDEBUG(218, *YYCURSOR); ++YYCURSOR; YYDEBUG(219, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1422 "Zend/zend_language_scanner.l" { return T_XOR_EQUAL; } -#line 3478 "Zend/zend_language_scanner.c" yy220: YYDEBUG(220, *YYCURSOR); ++YYCURSOR; YYDEBUG(221, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1426 "Zend/zend_language_scanner.l" { return T_BOOLEAN_OR; } -#line 3488 "Zend/zend_language_scanner.c" yy222: YYDEBUG(222, *YYCURSOR); ++YYCURSOR; YYDEBUG(223, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1418 "Zend/zend_language_scanner.l" { return T_OR_EQUAL; } -#line 3498 "Zend/zend_language_scanner.c" yy224: YYDEBUG(224, *YYCURSOR); ++YYCURSOR; YYDEBUG(225, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1430 "Zend/zend_language_scanner.l" { return T_BOOLEAN_AND; } -#line 3508 "Zend/zend_language_scanner.c" yy226: YYDEBUG(226, *YYCURSOR); ++YYCURSOR; YYDEBUG(227, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1414 "Zend/zend_language_scanner.l" { return T_AND_EQUAL; } -#line 3518 "Zend/zend_language_scanner.c" yy228: YYDEBUG(228, *YYCURSOR); ++YYCURSOR; @@ -3523,7 +3417,6 @@ yy228: yy229: YYDEBUG(229, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1996 "Zend/zend_language_scanner.l" { if (CG(asp_tags)) { BEGIN(INITIAL); @@ -3536,17 +3429,14 @@ yy229: return yytext[0]; } } -#line 3540 "Zend/zend_language_scanner.c" yy230: YYDEBUG(230, *YYCURSOR); ++YYCURSOR; YYDEBUG(231, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1402 "Zend/zend_language_scanner.l" { return T_MOD_EQUAL; } -#line 3550 "Zend/zend_language_scanner.c" yy232: YYDEBUG(232, *YYCURSOR); yych = *++YYCURSOR; @@ -3577,11 +3467,9 @@ yy236: ++YYCURSOR; YYDEBUG(237, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1398 "Zend/zend_language_scanner.l" { return T_CONCAT_EQUAL; } -#line 3585 "Zend/zend_language_scanner.c" yy238: YYDEBUG(238, *YYCURSOR); yyaccept = 4; @@ -3590,7 +3478,6 @@ yy238: yy239: YYDEBUG(239, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1953 "Zend/zend_language_scanner.l" { int doc_com; @@ -3624,7 +3511,6 @@ yy239: return T_COMMENT; } -#line 3628 "Zend/zend_language_scanner.c" yy240: YYDEBUG(240, *YYCURSOR); yych = *++YYCURSOR; @@ -3634,11 +3520,9 @@ yy241: ++YYCURSOR; YYDEBUG(242, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1394 "Zend/zend_language_scanner.l" { return T_DIV_EQUAL; } -#line 3642 "Zend/zend_language_scanner.c" yy243: YYDEBUG(243, *YYCURSOR); yych = *++YYCURSOR; @@ -3661,42 +3545,34 @@ yy246: ++YYCURSOR; YYDEBUG(247, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1390 "Zend/zend_language_scanner.l" { return T_MUL_EQUAL; } -#line 3669 "Zend/zend_language_scanner.c" yy248: YYDEBUG(248, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) == '=') goto yy252; YYDEBUG(249, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1450 "Zend/zend_language_scanner.l" { return T_SR; } -#line 3680 "Zend/zend_language_scanner.c" yy250: YYDEBUG(250, *YYCURSOR); ++YYCURSOR; YYDEBUG(251, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1378 "Zend/zend_language_scanner.l" { return T_IS_GREATER_OR_EQUAL; } -#line 3690 "Zend/zend_language_scanner.c" yy252: YYDEBUG(252, *YYCURSOR); ++YYCURSOR; YYDEBUG(253, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1410 "Zend/zend_language_scanner.l" { return T_SR_EQUAL; } -#line 3700 "Zend/zend_language_scanner.c" yy254: YYDEBUG(254, *YYCURSOR); yyaccept = 5; @@ -3707,11 +3583,9 @@ yy254: yy255: YYDEBUG(255, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1446 "Zend/zend_language_scanner.l" { return T_SL; } -#line 3715 "Zend/zend_language_scanner.c" yy256: YYDEBUG(256, *YYCURSOR); yych = *++YYCURSOR; @@ -3723,22 +3597,18 @@ yy257: ++YYCURSOR; YYDEBUG(258, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1374 "Zend/zend_language_scanner.l" { return T_IS_SMALLER_OR_EQUAL; } -#line 3731 "Zend/zend_language_scanner.c" yy259: YYDEBUG(259, *YYCURSOR); ++YYCURSOR; yy260: YYDEBUG(260, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1370 "Zend/zend_language_scanner.l" { return T_IS_NOT_EQUAL; } -#line 3742 "Zend/zend_language_scanner.c" yy261: YYDEBUG(261, *YYCURSOR); yych = *++YYCURSOR; @@ -3789,11 +3659,9 @@ yy268: ++YYCURSOR; YYDEBUG(269, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1406 "Zend/zend_language_scanner.l" { return T_SL_EQUAL; } -#line 3797 "Zend/zend_language_scanner.c" yy270: YYDEBUG(270, *YYCURSOR); ++YYCURSOR; @@ -3898,7 +3766,6 @@ yy279: yy280: YYDEBUG(280, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2121 "Zend/zend_language_scanner.l" { char *s; int bprefix = (yytext[0] != '<') ? 1 : 0; @@ -3945,7 +3812,6 @@ yy280: return T_START_HEREDOC; } -#line 3949 "Zend/zend_language_scanner.c" yy281: YYDEBUG(281, *YYCURSOR); yych = *++YYCURSOR; @@ -3985,31 +3851,25 @@ yy284: ++YYCURSOR; YYDEBUG(286, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1362 "Zend/zend_language_scanner.l" { return T_IS_NOT_IDENTICAL; } -#line 3993 "Zend/zend_language_scanner.c" yy287: YYDEBUG(287, *YYCURSOR); ++YYCURSOR; YYDEBUG(288, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1382 "Zend/zend_language_scanner.l" { return T_PLUS_EQUAL; } -#line 4003 "Zend/zend_language_scanner.c" yy289: YYDEBUG(289, *YYCURSOR); ++YYCURSOR; YYDEBUG(290, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1350 "Zend/zend_language_scanner.l" { return T_INC; } -#line 4013 "Zend/zend_language_scanner.c" yy291: YYDEBUG(291, *YYCURSOR); yych = *++YYCURSOR; @@ -4028,42 +3888,34 @@ yy293: } YYDEBUG(294, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1338 "Zend/zend_language_scanner.l" { return T_LIST; } -#line 4036 "Zend/zend_language_scanner.c" yy295: YYDEBUG(295, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) == '=') goto yy299; YYDEBUG(296, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1366 "Zend/zend_language_scanner.l" { return T_IS_EQUAL; } -#line 4047 "Zend/zend_language_scanner.c" yy297: YYDEBUG(297, *YYCURSOR); ++YYCURSOR; YYDEBUG(298, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1334 "Zend/zend_language_scanner.l" { return T_DOUBLE_ARROW; } -#line 4057 "Zend/zend_language_scanner.c" yy299: YYDEBUG(299, *YYCURSOR); ++YYCURSOR; YYDEBUG(300, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1358 "Zend/zend_language_scanner.l" { return T_IS_IDENTICAL; } -#line 4067 "Zend/zend_language_scanner.c" yy301: YYDEBUG(301, *YYCURSOR); yych = *++YYCURSOR; @@ -4193,7 +4045,6 @@ yy317: } YYDEBUG(320, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1722 "Zend/zend_language_scanner.l" { if (CG(current_namespace)) { *zendlval = *CG(current_namespace); @@ -4203,7 +4054,6 @@ yy317: } return T_NS_C; } -#line 4207 "Zend/zend_language_scanner.c" yy321: YYDEBUG(321, *YYCURSOR); yych = *++YYCURSOR; @@ -4223,7 +4073,6 @@ yy322: } YYDEBUG(325, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1695 "Zend/zend_language_scanner.l" { char *filename = zend_get_compiled_filename(TSRMLS_C); const size_t filename_len = strlen(filename); @@ -4250,7 +4099,6 @@ yy322: zendlval->type = IS_STRING; return T_DIR; } -#line 4254 "Zend/zend_language_scanner.c" yy326: YYDEBUG(326, *YYCURSOR); yych = *++YYCURSOR; @@ -4275,13 +4123,11 @@ yy328: } YYDEBUG(331, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1677 "Zend/zend_language_scanner.l" { zendlval->value.lval = CG(zend_lineno); zendlval->type = IS_LONG; return T_LINE; } -#line 4285 "Zend/zend_language_scanner.c" yy332: YYDEBUG(332, *YYCURSOR); yych = *++YYCURSOR; @@ -4316,7 +4162,6 @@ yy336: } YYDEBUG(339, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1656 "Zend/zend_language_scanner.l" { const char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL; const char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL; @@ -4337,7 +4182,6 @@ yy336: zendlval->type = IS_STRING; return T_METHOD_C; } -#line 4341 "Zend/zend_language_scanner.c" yy340: YYDEBUG(340, *YYCURSOR); yych = *++YYCURSOR; @@ -4388,7 +4232,6 @@ yy347: } YYDEBUG(350, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1640 "Zend/zend_language_scanner.l" { const char *func_name = NULL; @@ -4404,7 +4247,6 @@ yy347: zendlval->type = IS_STRING; return T_FUNC_C; } -#line 4408 "Zend/zend_language_scanner.c" yy351: YYDEBUG(351, *YYCURSOR); yych = *++YYCURSOR; @@ -4424,7 +4266,6 @@ yy352: } YYDEBUG(355, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1683 "Zend/zend_language_scanner.l" { char *filename = zend_get_compiled_filename(TSRMLS_C); @@ -4436,7 +4277,6 @@ yy352: zendlval->type = IS_STRING; return T_FILE; } -#line 4440 "Zend/zend_language_scanner.c" yy356: YYDEBUG(356, *YYCURSOR); yych = *++YYCURSOR; @@ -4466,7 +4306,6 @@ yy359: } YYDEBUG(362, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1620 "Zend/zend_language_scanner.l" { const char *trait_name = NULL; @@ -4486,7 +4325,6 @@ yy359: return T_TRAIT_C; } -#line 4490 "Zend/zend_language_scanner.c" yy363: YYDEBUG(363, *YYCURSOR); yych = *++YYCURSOR; @@ -4516,7 +4354,6 @@ yy366: } YYDEBUG(369, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1593 "Zend/zend_language_scanner.l" { const char *class_name = NULL; @@ -4543,7 +4380,6 @@ yy366: } return T_CLASS_C; } -#line 4547 "Zend/zend_language_scanner.c" yy370: YYDEBUG(370, *YYCURSOR); yych = *++YYCURSOR; @@ -4605,11 +4441,9 @@ yy381: } YYDEBUG(382, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1302 "Zend/zend_language_scanner.l" { return T_HALT_COMPILER; } -#line 4613 "Zend/zend_language_scanner.c" yy383: YYDEBUG(383, *YYCURSOR); yych = *++YYCURSOR; @@ -4629,11 +4463,9 @@ yy385: } YYDEBUG(386, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1282 "Zend/zend_language_scanner.l" { return T_USE; } -#line 4637 "Zend/zend_language_scanner.c" yy387: YYDEBUG(387, *YYCURSOR); yych = *++YYCURSOR; @@ -4652,11 +4484,9 @@ yy389: } YYDEBUG(390, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1330 "Zend/zend_language_scanner.l" { return T_UNSET; } -#line 4660 "Zend/zend_language_scanner.c" yy391: YYDEBUG(391, *YYCURSOR); ++YYCURSOR; @@ -4828,11 +4658,9 @@ yy406: ++YYCURSOR; YYDEBUG(408, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1230 "Zend/zend_language_scanner.l" { return T_INT_CAST; } -#line 4836 "Zend/zend_language_scanner.c" yy409: YYDEBUG(409, *YYCURSOR); yych = *++YYCURSOR; @@ -4876,11 +4704,9 @@ yy414: ++YYCURSOR; YYDEBUG(417, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1234 "Zend/zend_language_scanner.l" { return T_DOUBLE_CAST; } -#line 4884 "Zend/zend_language_scanner.c" yy418: YYDEBUG(418, *YYCURSOR); yych = *++YYCURSOR; @@ -4950,11 +4776,9 @@ yy428: ++YYCURSOR; YYDEBUG(431, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1238 "Zend/zend_language_scanner.l" { return T_STRING_CAST; } -#line 4958 "Zend/zend_language_scanner.c" yy432: YYDEBUG(432, *YYCURSOR); yych = *++YYCURSOR; @@ -4987,11 +4811,9 @@ yy435: ++YYCURSOR; YYDEBUG(438, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1242 "Zend/zend_language_scanner.l" { return T_ARRAY_CAST; } -#line 4995 "Zend/zend_language_scanner.c" yy439: YYDEBUG(439, *YYCURSOR); yych = *++YYCURSOR; @@ -5029,11 +4851,9 @@ yy443: ++YYCURSOR; YYDEBUG(446, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1246 "Zend/zend_language_scanner.l" { return T_OBJECT_CAST; } -#line 5037 "Zend/zend_language_scanner.c" yy447: YYDEBUG(447, *YYCURSOR); yych = *++YYCURSOR; @@ -5074,11 +4894,9 @@ yy452: ++YYCURSOR; YYDEBUG(454, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1250 "Zend/zend_language_scanner.l" { return T_BOOL_CAST; } -#line 5082 "Zend/zend_language_scanner.c" yy455: YYDEBUG(455, *YYCURSOR); yych = *++YYCURSOR; @@ -5138,11 +4956,9 @@ yy463: ++YYCURSOR; YYDEBUG(466, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1254 "Zend/zend_language_scanner.l" { return T_UNSET_CAST; } -#line 5146 "Zend/zend_language_scanner.c" yy467: YYDEBUG(467, *YYCURSOR); yych = *++YYCURSOR; @@ -5156,11 +4972,9 @@ yy468: } YYDEBUG(469, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1226 "Zend/zend_language_scanner.l" { return T_VAR; } -#line 5164 "Zend/zend_language_scanner.c" yy470: YYDEBUG(470, *YYCURSOR); yych = *++YYCURSOR; @@ -5180,11 +4994,9 @@ yy472: } YYDEBUG(473, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1218 "Zend/zend_language_scanner.l" { return T_NEW; } -#line 5188 "Zend/zend_language_scanner.c" yy474: YYDEBUG(474, *YYCURSOR); yych = *++YYCURSOR; @@ -5223,21 +5035,17 @@ yy480: } YYDEBUG(481, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1278 "Zend/zend_language_scanner.l" { return T_NAMESPACE; } -#line 5231 "Zend/zend_language_scanner.c" yy482: YYDEBUG(482, *YYCURSOR); ++YYCURSOR; YYDEBUG(483, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1210 "Zend/zend_language_scanner.l" { return T_PAAMAYIM_NEKUDOTAYIM; } -#line 5241 "Zend/zend_language_scanner.c" yy484: YYDEBUG(484, *YYCURSOR); ++YYCURSOR; @@ -5259,32 +5067,26 @@ yy486: ++YYCURSOR; YYDEBUG(487, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1386 "Zend/zend_language_scanner.l" { return T_MINUS_EQUAL; } -#line 5267 "Zend/zend_language_scanner.c" yy488: YYDEBUG(488, *YYCURSOR); ++YYCURSOR; YYDEBUG(489, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1354 "Zend/zend_language_scanner.l" { return T_DEC; } -#line 5277 "Zend/zend_language_scanner.c" yy490: YYDEBUG(490, *YYCURSOR); ++YYCURSOR; YYDEBUG(491, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1180 "Zend/zend_language_scanner.l" { yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); return T_OBJECT_OPERATOR; } -#line 5288 "Zend/zend_language_scanner.c" yy492: YYDEBUG(492, *YYCURSOR); yych = *++YYCURSOR; @@ -5329,11 +5131,9 @@ yy497: } YYDEBUG(498, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1326 "Zend/zend_language_scanner.l" { return T_PUBLIC; } -#line 5337 "Zend/zend_language_scanner.c" yy499: YYDEBUG(499, *YYCURSOR); yych = *++YYCURSOR; @@ -5388,11 +5188,9 @@ yy506: } YYDEBUG(507, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1322 "Zend/zend_language_scanner.l" { return T_PROTECTED; } -#line 5396 "Zend/zend_language_scanner.c" yy508: YYDEBUG(508, *YYCURSOR); yych = *++YYCURSOR; @@ -5422,11 +5220,9 @@ yy512: } YYDEBUG(513, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1318 "Zend/zend_language_scanner.l" { return T_PRIVATE; } -#line 5430 "Zend/zend_language_scanner.c" yy514: YYDEBUG(514, *YYCURSOR); ++YYCURSOR; @@ -5435,11 +5231,9 @@ yy514: } YYDEBUG(515, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1156 "Zend/zend_language_scanner.l" { return T_PRINT; } -#line 5443 "Zend/zend_language_scanner.c" yy516: YYDEBUG(516, *YYCURSOR); yych = *++YYCURSOR; @@ -5464,11 +5258,9 @@ yy519: } YYDEBUG(520, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1148 "Zend/zend_language_scanner.l" { return T_GOTO; } -#line 5472 "Zend/zend_language_scanner.c" yy521: YYDEBUG(521, *YYCURSOR); yych = *++YYCURSOR; @@ -5492,11 +5284,9 @@ yy524: } YYDEBUG(525, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1290 "Zend/zend_language_scanner.l" { return T_GLOBAL; } -#line 5500 "Zend/zend_language_scanner.c" yy526: YYDEBUG(526, *YYCURSOR); yych = *++YYCURSOR; @@ -5533,11 +5323,9 @@ yy532: } YYDEBUG(533, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1140 "Zend/zend_language_scanner.l" { return T_BREAK; } -#line 5541 "Zend/zend_language_scanner.c" yy534: YYDEBUG(534, *YYCURSOR); yych = *++YYCURSOR; @@ -5577,11 +5365,9 @@ yy540: } YYDEBUG(541, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1124 "Zend/zend_language_scanner.l" { return T_SWITCH; } -#line 5585 "Zend/zend_language_scanner.c" yy542: YYDEBUG(542, *YYCURSOR); yych = *++YYCURSOR; @@ -5605,11 +5391,9 @@ yy545: } YYDEBUG(546, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1306 "Zend/zend_language_scanner.l" { return T_STATIC; } -#line 5613 "Zend/zend_language_scanner.c" yy547: YYDEBUG(547, *YYCURSOR); yych = *++YYCURSOR; @@ -5636,11 +5420,9 @@ yy550: } YYDEBUG(551, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1120 "Zend/zend_language_scanner.l" { return T_AS; } -#line 5644 "Zend/zend_language_scanner.c" yy552: YYDEBUG(552, *YYCURSOR); yych = *++YYCURSOR; @@ -5659,11 +5441,9 @@ yy554: } YYDEBUG(555, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1342 "Zend/zend_language_scanner.l" { return T_ARRAY; } -#line 5667 "Zend/zend_language_scanner.c" yy556: YYDEBUG(556, *YYCURSOR); ++YYCURSOR; @@ -5672,11 +5452,9 @@ yy556: } YYDEBUG(557, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1438 "Zend/zend_language_scanner.l" { return T_LOGICAL_AND; } -#line 5680 "Zend/zend_language_scanner.c" yy558: YYDEBUG(558, *YYCURSOR); yych = *++YYCURSOR; @@ -5710,11 +5488,9 @@ yy563: } YYDEBUG(564, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1310 "Zend/zend_language_scanner.l" { return T_ABSTRACT; } -#line 5718 "Zend/zend_language_scanner.c" yy565: YYDEBUG(565, *YYCURSOR); yych = *++YYCURSOR; @@ -5738,11 +5514,9 @@ yy568: } YYDEBUG(569, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1080 "Zend/zend_language_scanner.l" { return T_WHILE; } -#line 5746 "Zend/zend_language_scanner.c" yy570: YYDEBUG(570, *YYCURSOR); ++YYCURSOR; @@ -5751,11 +5525,9 @@ yy570: } YYDEBUG(571, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1064 "Zend/zend_language_scanner.l" { return T_IF; } -#line 5759 "Zend/zend_language_scanner.c" yy572: YYDEBUG(572, *YYCURSOR); yych = *++YYCURSOR; @@ -5807,11 +5579,9 @@ yy577: } YYDEBUG(578, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1294 "Zend/zend_language_scanner.l" { return T_ISSET; } -#line 5815 "Zend/zend_language_scanner.c" yy579: YYDEBUG(579, *YYCURSOR); yych = *++YYCURSOR; @@ -5865,11 +5635,9 @@ yy585: yy586: YYDEBUG(586, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1262 "Zend/zend_language_scanner.l" { return T_INCLUDE; } -#line 5873 "Zend/zend_language_scanner.c" yy587: YYDEBUG(587, *YYCURSOR); yych = *++YYCURSOR; @@ -5898,11 +5666,9 @@ yy591: } YYDEBUG(592, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1266 "Zend/zend_language_scanner.l" { return T_INCLUDE_ONCE; } -#line 5906 "Zend/zend_language_scanner.c" yy593: YYDEBUG(593, *YYCURSOR); yych = *++YYCURSOR; @@ -5936,11 +5702,9 @@ yy598: } YYDEBUG(599, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1164 "Zend/zend_language_scanner.l" { return T_INTERFACE; } -#line 5944 "Zend/zend_language_scanner.c" yy600: YYDEBUG(600, *YYCURSOR); yych = *++YYCURSOR; @@ -5990,11 +5754,9 @@ yy606: } YYDEBUG(607, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1286 "Zend/zend_language_scanner.l" { return T_INSTEADOF; } -#line 5998 "Zend/zend_language_scanner.c" yy608: YYDEBUG(608, *YYCURSOR); yych = *++YYCURSOR; @@ -6023,11 +5785,9 @@ yy612: } YYDEBUG(613, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1116 "Zend/zend_language_scanner.l" { return T_INSTANCEOF; } -#line 6031 "Zend/zend_language_scanner.c" yy614: YYDEBUG(614, *YYCURSOR); yych = *++YYCURSOR; @@ -6071,11 +5831,9 @@ yy621: } YYDEBUG(622, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1176 "Zend/zend_language_scanner.l" { return T_IMPLEMENTS; } -#line 6079 "Zend/zend_language_scanner.c" yy623: YYDEBUG(623, *YYCURSOR); yych = *++YYCURSOR; @@ -6103,11 +5861,9 @@ yy624: } YYDEBUG(626, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1048 "Zend/zend_language_scanner.l" { return T_TRY; } -#line 6111 "Zend/zend_language_scanner.c" yy627: YYDEBUG(627, *YYCURSOR); yych = *++YYCURSOR; @@ -6126,11 +5882,9 @@ yy629: } YYDEBUG(630, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1168 "Zend/zend_language_scanner.l" { return T_TRAIT; } -#line 6134 "Zend/zend_language_scanner.c" yy631: YYDEBUG(631, *YYCURSOR); yych = *++YYCURSOR; @@ -6149,11 +5903,9 @@ yy633: } YYDEBUG(634, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1060 "Zend/zend_language_scanner.l" { return T_THROW; } -#line 6157 "Zend/zend_language_scanner.c" yy635: YYDEBUG(635, *YYCURSOR); yych = *++YYCURSOR; @@ -6177,11 +5929,9 @@ yy638: } YYDEBUG(639, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1044 "Zend/zend_language_scanner.l" { return T_YIELD; } -#line 6185 "Zend/zend_language_scanner.c" yy640: YYDEBUG(640, *YYCURSOR); yych = *++YYCURSOR; @@ -6242,11 +5992,9 @@ yy646: yy647: YYDEBUG(647, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1270 "Zend/zend_language_scanner.l" { return T_REQUIRE; } -#line 6250 "Zend/zend_language_scanner.c" yy648: YYDEBUG(648, *YYCURSOR); yych = *++YYCURSOR; @@ -6275,11 +6023,9 @@ yy652: } YYDEBUG(653, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1274 "Zend/zend_language_scanner.l" { return T_REQUIRE_ONCE; } -#line 6283 "Zend/zend_language_scanner.c" yy654: YYDEBUG(654, *YYCURSOR); yych = *++YYCURSOR; @@ -6298,11 +6044,9 @@ yy656: } YYDEBUG(657, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1040 "Zend/zend_language_scanner.l" { return T_RETURN; } -#line 6306 "Zend/zend_language_scanner.c" yy658: YYDEBUG(658, *YYCURSOR); yych = *++YYCURSOR; @@ -6392,11 +6136,9 @@ yy667: } YYDEBUG(668, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1144 "Zend/zend_language_scanner.l" { return T_CONTINUE; } -#line 6400 "Zend/zend_language_scanner.c" yy669: YYDEBUG(669, *YYCURSOR); ++YYCURSOR; @@ -6405,11 +6147,9 @@ yy669: } YYDEBUG(670, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1036 "Zend/zend_language_scanner.l" { return T_CONST; } -#line 6413 "Zend/zend_language_scanner.c" yy671: YYDEBUG(671, *YYCURSOR); yych = *++YYCURSOR; @@ -6434,11 +6174,9 @@ yy674: } YYDEBUG(675, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1222 "Zend/zend_language_scanner.l" { return T_CLONE; } -#line 6442 "Zend/zend_language_scanner.c" yy676: YYDEBUG(676, *YYCURSOR); yych = *++YYCURSOR; @@ -6452,11 +6190,9 @@ yy677: } YYDEBUG(678, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1160 "Zend/zend_language_scanner.l" { return T_CLASS; } -#line 6460 "Zend/zend_language_scanner.c" yy679: YYDEBUG(679, *YYCURSOR); yych = *++YYCURSOR; @@ -6502,11 +6238,9 @@ yy686: } YYDEBUG(687, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1346 "Zend/zend_language_scanner.l" { return T_CALLABLE; } -#line 6510 "Zend/zend_language_scanner.c" yy688: YYDEBUG(688, *YYCURSOR); ++YYCURSOR; @@ -6515,11 +6249,9 @@ yy688: } YYDEBUG(689, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1132 "Zend/zend_language_scanner.l" { return T_CASE; } -#line 6523 "Zend/zend_language_scanner.c" yy690: YYDEBUG(690, *YYCURSOR); yych = *++YYCURSOR; @@ -6533,11 +6265,9 @@ yy691: } YYDEBUG(692, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1052 "Zend/zend_language_scanner.l" { return T_CATCH; } -#line 6541 "Zend/zend_language_scanner.c" yy693: YYDEBUG(693, *YYCURSOR); yych = *++YYCURSOR; @@ -6588,11 +6318,9 @@ yy701: } YYDEBUG(702, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1032 "Zend/zend_language_scanner.l" { return T_FUNCTION; } -#line 6596 "Zend/zend_language_scanner.c" yy703: YYDEBUG(703, *YYCURSOR); ++YYCURSOR; @@ -6616,11 +6344,9 @@ yy703: yy704: YYDEBUG(704, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1092 "Zend/zend_language_scanner.l" { return T_FOR; } -#line 6624 "Zend/zend_language_scanner.c" yy705: YYDEBUG(705, *YYCURSOR); yych = *++YYCURSOR; @@ -6644,11 +6370,9 @@ yy708: } YYDEBUG(709, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1100 "Zend/zend_language_scanner.l" { return T_FOREACH; } -#line 6652 "Zend/zend_language_scanner.c" yy710: YYDEBUG(710, *YYCURSOR); yych = *++YYCURSOR; @@ -6682,11 +6406,9 @@ yy712: yy713: YYDEBUG(713, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1314 "Zend/zend_language_scanner.l" { return T_FINAL; } -#line 6690 "Zend/zend_language_scanner.c" yy714: YYDEBUG(714, *YYCURSOR); yych = *++YYCURSOR; @@ -6700,11 +6422,9 @@ yy715: } YYDEBUG(716, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1056 "Zend/zend_language_scanner.l" { return T_FINALLY; } -#line 6708 "Zend/zend_language_scanner.c" yy717: YYDEBUG(717, *YYCURSOR); yych = *++YYCURSOR; @@ -6735,11 +6455,9 @@ yy719: } YYDEBUG(720, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1088 "Zend/zend_language_scanner.l" { return T_DO; } -#line 6743 "Zend/zend_language_scanner.c" yy721: YYDEBUG(721, *YYCURSOR); ++YYCURSOR; @@ -6748,11 +6466,9 @@ yy721: } YYDEBUG(722, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1028 "Zend/zend_language_scanner.l" { return T_EXIT; } -#line 6756 "Zend/zend_language_scanner.c" yy723: YYDEBUG(723, *YYCURSOR); yych = *++YYCURSOR; @@ -6787,11 +6503,9 @@ yy728: } YYDEBUG(729, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1136 "Zend/zend_language_scanner.l" { return T_DEFAULT; } -#line 6795 "Zend/zend_language_scanner.c" yy730: YYDEBUG(730, *YYCURSOR); yych = *++YYCURSOR; @@ -6815,11 +6529,9 @@ yy733: } YYDEBUG(734, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1108 "Zend/zend_language_scanner.l" { return T_DECLARE; } -#line 6823 "Zend/zend_language_scanner.c" yy735: YYDEBUG(735, *YYCURSOR); yych = *++YYCURSOR; @@ -6899,11 +6611,9 @@ yy746: } YYDEBUG(747, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1172 "Zend/zend_language_scanner.l" { return T_EXTENDS; } -#line 6907 "Zend/zend_language_scanner.c" yy748: YYDEBUG(748, *YYCURSOR); ++YYCURSOR; @@ -6912,11 +6622,9 @@ yy748: } YYDEBUG(749, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1024 "Zend/zend_language_scanner.l" { return T_EXIT; } -#line 6920 "Zend/zend_language_scanner.c" yy750: YYDEBUG(750, *YYCURSOR); yych = *++YYCURSOR; @@ -6930,11 +6638,9 @@ yy751: } YYDEBUG(752, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1258 "Zend/zend_language_scanner.l" { return T_EVAL; } -#line 6938 "Zend/zend_language_scanner.c" yy753: YYDEBUG(753, *YYCURSOR); yych = *++YYCURSOR; @@ -7004,11 +6710,9 @@ yy762: } YYDEBUG(763, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1084 "Zend/zend_language_scanner.l" { return T_ENDWHILE; } -#line 7012 "Zend/zend_language_scanner.c" yy764: YYDEBUG(764, *YYCURSOR); yych = *++YYCURSOR; @@ -7037,11 +6741,9 @@ yy768: } YYDEBUG(769, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1128 "Zend/zend_language_scanner.l" { return T_ENDSWITCH; } -#line 7045 "Zend/zend_language_scanner.c" yy770: YYDEBUG(770, *YYCURSOR); ++YYCURSOR; @@ -7050,11 +6752,9 @@ yy770: } YYDEBUG(771, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1072 "Zend/zend_language_scanner.l" { return T_ENDIF; } -#line 7058 "Zend/zend_language_scanner.c" yy772: YYDEBUG(772, *YYCURSOR); yych = *++YYCURSOR; @@ -7083,11 +6783,9 @@ yy773: yy774: YYDEBUG(774, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1096 "Zend/zend_language_scanner.l" { return T_ENDFOR; } -#line 7091 "Zend/zend_language_scanner.c" yy775: YYDEBUG(775, *YYCURSOR); yych = *++YYCURSOR; @@ -7111,11 +6809,9 @@ yy778: } YYDEBUG(779, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1104 "Zend/zend_language_scanner.l" { return T_ENDFOREACH; } -#line 7119 "Zend/zend_language_scanner.c" yy780: YYDEBUG(780, *YYCURSOR); yych = *++YYCURSOR; @@ -7149,11 +6845,9 @@ yy785: } YYDEBUG(786, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1112 "Zend/zend_language_scanner.l" { return T_ENDDECLARE; } -#line 7157 "Zend/zend_language_scanner.c" yy787: YYDEBUG(787, *YYCURSOR); yych = *++YYCURSOR; @@ -7172,11 +6866,9 @@ yy789: } YYDEBUG(790, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1298 "Zend/zend_language_scanner.l" { return T_EMPTY; } -#line 7180 "Zend/zend_language_scanner.c" yy791: YYDEBUG(791, *YYCURSOR); yych = *++YYCURSOR; @@ -7205,11 +6897,9 @@ yy792: yy793: YYDEBUG(793, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1076 "Zend/zend_language_scanner.l" { return T_ELSE; } -#line 7213 "Zend/zend_language_scanner.c" yy794: YYDEBUG(794, *YYCURSOR); yych = *++YYCURSOR; @@ -7223,11 +6913,9 @@ yy795: } YYDEBUG(796, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1068 "Zend/zend_language_scanner.l" { return T_ELSEIF; } -#line 7231 "Zend/zend_language_scanner.c" yy797: YYDEBUG(797, *YYCURSOR); yych = *++YYCURSOR; @@ -7241,11 +6929,9 @@ yy798: } YYDEBUG(799, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1152 "Zend/zend_language_scanner.l" { return T_ECHO; } -#line 7249 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_LOOKING_FOR_PROPERTY: @@ -7318,7 +7004,6 @@ yy802: yy803: YYDEBUG(803, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1185 "Zend/zend_language_scanner.l" { zendlval->value.str.val = yytext; /* no copying - intentional */ zendlval->value.str.len = yyleng; @@ -7326,7 +7011,6 @@ yy803: HANDLE_NEWLINES(yytext, yyleng); return T_WHITESPACE; } -#line 7330 "Zend/zend_language_scanner.c" yy804: YYDEBUG(804, *YYCURSOR); ++YYCURSOR; @@ -7334,13 +7018,11 @@ yy804: yy805: YYDEBUG(805, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1204 "Zend/zend_language_scanner.l" { yyless(0); yy_pop_state(TSRMLS_C); goto restart; } -#line 7344 "Zend/zend_language_scanner.c" yy806: YYDEBUG(806, *YYCURSOR); ++YYCURSOR; @@ -7349,14 +7031,12 @@ yy806: yy807: YYDEBUG(807, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1197 "Zend/zend_language_scanner.l" { yy_pop_state(TSRMLS_C); zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; return T_STRING; } -#line 7360 "Zend/zend_language_scanner.c" yy808: YYDEBUG(808, *YYCURSOR); yych = *++YYCURSOR; @@ -7377,11 +7057,9 @@ yy811: ++YYCURSOR; YYDEBUG(812, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1193 "Zend/zend_language_scanner.l" { return T_OBJECT_OPERATOR; } -#line 7385 "Zend/zend_language_scanner.c" yy813: YYDEBUG(813, *YYCURSOR); ++YYCURSOR; @@ -7466,14 +7144,12 @@ yy817: yy818: YYDEBUG(818, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1490 "Zend/zend_language_scanner.l" { yyless(0); yy_pop_state(TSRMLS_C); yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); goto restart; } -#line 7477 "Zend/zend_language_scanner.c" yy819: YYDEBUG(819, *YYCURSOR); yych = *++YYCURSOR; @@ -7498,7 +7174,6 @@ yy823: ++YYCURSOR; YYDEBUG(824, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1480 "Zend/zend_language_scanner.l" { yyless(yyleng - 1); zend_copy_value(zendlval, yytext, yyleng); @@ -7507,7 +7182,6 @@ yy823: yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); return T_STRING_VARNAME; } -#line 7511 "Zend/zend_language_scanner.c" } /* *********************************** */ yyc_ST_NOWDOC: @@ -7518,7 +7192,6 @@ yyc_ST_NOWDOC: ++YYCURSOR; YYDEBUG(828, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2374 "Zend/zend_language_scanner.l" { int newline = 0; @@ -7575,7 +7248,6 @@ nowdoc_scan_done: HANDLE_NEWLINES(yytext, yyleng - newline); return T_ENCAPSED_AND_WHITESPACE; } -#line 7579 "Zend/zend_language_scanner.c" /* *********************************** */ yyc_ST_VAR_OFFSET: { @@ -7682,10 +7354,9 @@ yy831: yy832: YYDEBUG(832, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1568 "Zend/zend_language_scanner.l" { /* Offset could be treated as a long */ if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { - zendlval->value.lval = strtol(yytext, NULL, 10); + zendlval->value.lval = ZEND_STRTOL(yytext, NULL, 10); zendlval->type = IS_LONG; } else { zendlval->value.str.val = (char *)estrndup(yytext, yyleng); @@ -7694,7 +7365,6 @@ yy832: } return T_NUM_STRING; } -#line 7698 "Zend/zend_language_scanner.c" yy833: YYDEBUG(833, *YYCURSOR); yych = *++YYCURSOR; @@ -7714,23 +7384,19 @@ yy834: yy835: YYDEBUG(835, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1900 "Zend/zend_language_scanner.l" { /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */ return yytext[0]; } -#line 7723 "Zend/zend_language_scanner.c" yy836: YYDEBUG(836, *YYCURSOR); ++YYCURSOR; YYDEBUG(837, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1895 "Zend/zend_language_scanner.l" { yy_pop_state(TSRMLS_C); return ']'; } -#line 7734 "Zend/zend_language_scanner.c" yy838: YYDEBUG(838, *YYCURSOR); yych = *++YYCURSOR; @@ -7740,14 +7406,12 @@ yy839: ++YYCURSOR; YYDEBUG(840, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1905 "Zend/zend_language_scanner.l" { /* Invalid rule to return a more explicit parse error with proper line number */ yyless(0); yy_pop_state(TSRMLS_C); return T_ENCAPSED_AND_WHITESPACE; } -#line 7751 "Zend/zend_language_scanner.c" yy841: YYDEBUG(841, *YYCURSOR); ++YYCURSOR; @@ -7756,19 +7420,16 @@ yy841: yy842: YYDEBUG(842, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1912 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, yytext, yyleng); zendlval->type = IS_STRING; return T_STRING; } -#line 7766 "Zend/zend_language_scanner.c" yy843: YYDEBUG(843, *YYCURSOR); ++YYCURSOR; YYDEBUG(844, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 2432 "Zend/zend_language_scanner.l" { if (YYCURSOR > YYLIMIT) { return 0; @@ -7777,7 +7438,6 @@ yy843: zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); goto restart; } -#line 7781 "Zend/zend_language_scanner.c" yy845: YYDEBUG(845, *YYCURSOR); ++YYCURSOR; @@ -7813,13 +7473,11 @@ yy847: yy849: YYDEBUG(849, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1889 "Zend/zend_language_scanner.l" { zend_copy_value(zendlval, (yytext+1), (yyleng-1)); zendlval->type = IS_STRING; return T_VARIABLE; } -#line 7823 "Zend/zend_language_scanner.c" yy850: YYDEBUG(850, *YYCURSOR); ++YYCURSOR; @@ -7859,14 +7517,12 @@ yy855: yy857: YYDEBUG(857, *YYCURSOR); yyleng = YYCURSOR - SCNG(yy_text); -#line 1580 "Zend/zend_language_scanner.l" { /* Offset must be treated as a string */ zendlval->value.str.val = (char *)estrndup(yytext, yyleng); zendlval->value.str.len = yyleng; zendlval->type = IS_STRING; return T_NUM_STRING; } -#line 7870 "Zend/zend_language_scanner.c" yy858: YYDEBUG(858, *YYCURSOR); ++YYCURSOR; @@ -7889,6 +7545,5 @@ yy860: goto yy857; } } -#line 2441 "Zend/zend_language_scanner.l" } diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index d2e7243..ff47c28 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1,2442 +1,2442 @@ -/* - +----------------------------------------------------------------------+ - | Zend Engine | - +----------------------------------------------------------------------+ - | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.00 of the Zend license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.zend.com/license/2_00.txt. | - | If you did not receive a copy of the Zend license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@zend.com so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - | Nuno Lopes <nlopess@php.net> | - | Scott MacVicar <scottmac@php.net> | - | Flex version authors: | - | Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#if 0 -# define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c) -#else -# define YYDEBUG(s, c) -#endif - -#include "zend_language_scanner_defs.h" - -#include <errno.h> -#include "zend.h" -#ifdef PHP_WIN32 -# include <Winuser.h> -#endif -#include "zend_alloc.h" -#include <zend_language_parser.h> -#include "zend_compile.h" -#include "zend_language_scanner.h" -#include "zend_highlight.h" -#include "zend_constants.h" -#include "zend_variables.h" -#include "zend_operators.h" -#include "zend_API.h" -#include "zend_strtod.h" -#include "zend_exceptions.h" -#include "tsrm_virtual_cwd.h" -#include "tsrm_config_common.h" - -#define YYCTYPE unsigned char -#define YYFILL(n) { if ((YYCURSOR + n) >= (YYLIMIT + ZEND_MMAP_AHEAD)) { return 0; } } -#define YYCURSOR SCNG(yy_cursor) -#define YYLIMIT SCNG(yy_limit) -#define YYMARKER SCNG(yy_marker) - -#define YYGETCONDITION() SCNG(yy_state) -#define YYSETCONDITION(s) SCNG(yy_state) = s - -#define STATE(name) yyc##name - -/* emulate flex constructs */ -#define BEGIN(state) YYSETCONDITION(STATE(state)) -#define YYSTATE YYGETCONDITION() -#define yytext ((char*)SCNG(yy_text)) -#define yyleng SCNG(yy_leng) -#define yyless(x) do { YYCURSOR = (unsigned char*)yytext + x; \ - yyleng = (unsigned int)x; } while(0) -#define yymore() goto yymore_restart - -/* perform sanity check. If this message is triggered you should - increase the ZEND_MMAP_AHEAD value in the zend_streams.h file */ -/*!max:re2c */ -#if ZEND_MMAP_AHEAD < YYMAXFILL -# error ZEND_MMAP_AHEAD should be greater than or equal to YYMAXFILL -#endif - -#ifdef HAVE_STDARG_H -# include <stdarg.h> -#endif - -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -/* Globals Macros */ -#define SCNG LANG_SCNG -#ifdef ZTS -ZEND_API ts_rsrc_id language_scanner_globals_id; -#else -ZEND_API zend_php_scanner_globals language_scanner_globals; -#endif - -#define HANDLE_NEWLINES(s, l) \ -do { \ - char *p = (s), *boundary = p+(l); \ - \ - while (p<boundary) { \ - if (*p == '\n' || (*p == '\r' && (*(p+1) != '\n'))) { \ - CG(zend_lineno)++; \ - } \ - p++; \ - } \ -} while (0) - -#define HANDLE_NEWLINE(c) \ -{ \ - if (c == '\n' || c == '\r') { \ - CG(zend_lineno)++; \ - } \ -} - -/* To save initial string length after scanning to first variable, CG(doc_comment_len) can be reused */ -#define SET_DOUBLE_QUOTES_SCANNED_LENGTH(len) CG(doc_comment_len) = (len) -#define GET_DOUBLE_QUOTES_SCANNED_LENGTH() CG(doc_comment_len) - -#define IS_LABEL_START(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || (c) == '_' || (c) >= 0x7F) - -#define ZEND_IS_OCT(c) ((c)>='0' && (c)<='7') -#define ZEND_IS_HEX(c) (((c)>='0' && (c)<='9') || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F')) - -BEGIN_EXTERN_C() - -static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) -{ - const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); - assert(internal_encoding && zend_multibyte_check_lexer_compatibility(internal_encoding)); - return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding) TSRMLS_CC); -} - -static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) -{ - return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding) TSRMLS_CC); -} - -static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) -{ - return zend_multibyte_encoding_converter(to, to_length, from, from_length, -LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8 TSRMLS_CC); -} - -static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) -{ - const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); - assert(internal_encoding && zend_multibyte_check_lexer_compatibility(internal_encoding)); - return zend_multibyte_encoding_converter(to, to_length, from, from_length, -internal_encoding, zend_multibyte_encoding_utf8 TSRMLS_CC); -} - - -static void _yy_push_state(int new_state TSRMLS_DC) -{ - zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION(), sizeof(int)); - YYSETCONDITION(new_state); -} - -#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) - -static void yy_pop_state(TSRMLS_D) -{ - int *stack_state; - zend_stack_top(&SCNG(state_stack), (void **) &stack_state); - YYSETCONDITION(*stack_state); - zend_stack_del_top(&SCNG(state_stack)); -} - -static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) -{ - YYCURSOR = (YYCTYPE*)str; - YYLIMIT = YYCURSOR + len; - if (!SCNG(yy_start)) { - SCNG(yy_start) = YYCURSOR; - } -} - -void startup_scanner(TSRMLS_D) -{ - CG(parse_error) = 0; - CG(doc_comment) = NULL; - CG(doc_comment_len) = 0; - zend_stack_init(&SCNG(state_stack)); - zend_ptr_stack_init(&SCNG(heredoc_label_stack)); -} - -static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) { - efree(heredoc_label->label); -} - -void shutdown_scanner(TSRMLS_D) -{ - CG(parse_error) = 0; - RESET_DOC_COMMENT(); - zend_stack_destroy(&SCNG(state_stack)); - zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); - zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); -} - -ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) -{ - lex_state->yy_leng = SCNG(yy_leng); - lex_state->yy_start = SCNG(yy_start); - lex_state->yy_text = SCNG(yy_text); - lex_state->yy_cursor = SCNG(yy_cursor); - lex_state->yy_marker = SCNG(yy_marker); - lex_state->yy_limit = SCNG(yy_limit); - - lex_state->state_stack = SCNG(state_stack); - zend_stack_init(&SCNG(state_stack)); - - lex_state->heredoc_label_stack = SCNG(heredoc_label_stack); - zend_ptr_stack_init(&SCNG(heredoc_label_stack)); - - lex_state->in = SCNG(yy_in); - lex_state->yy_state = YYSTATE; - lex_state->filename = zend_get_compiled_filename(TSRMLS_C); - lex_state->lineno = CG(zend_lineno); - - lex_state->script_org = SCNG(script_org); - lex_state->script_org_size = SCNG(script_org_size); - lex_state->script_filtered = SCNG(script_filtered); - lex_state->script_filtered_size = SCNG(script_filtered_size); - lex_state->input_filter = SCNG(input_filter); - lex_state->output_filter = SCNG(output_filter); - lex_state->script_encoding = SCNG(script_encoding); -} - -ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) -{ - SCNG(yy_leng) = lex_state->yy_leng; - SCNG(yy_start) = lex_state->yy_start; - SCNG(yy_text) = lex_state->yy_text; - SCNG(yy_cursor) = lex_state->yy_cursor; - SCNG(yy_marker) = lex_state->yy_marker; - SCNG(yy_limit) = lex_state->yy_limit; - - zend_stack_destroy(&SCNG(state_stack)); - SCNG(state_stack) = lex_state->state_stack; - - zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); - zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); - SCNG(heredoc_label_stack) = lex_state->heredoc_label_stack; - - SCNG(yy_in) = lex_state->in; - YYSETCONDITION(lex_state->yy_state); - CG(zend_lineno) = lex_state->lineno; - zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); - - if (SCNG(script_filtered)) { - efree(SCNG(script_filtered)); - SCNG(script_filtered) = NULL; - } - SCNG(script_org) = lex_state->script_org; - SCNG(script_org_size) = lex_state->script_org_size; - SCNG(script_filtered) = lex_state->script_filtered; - SCNG(script_filtered_size) = lex_state->script_filtered_size; - SCNG(input_filter) = lex_state->input_filter; - SCNG(output_filter) = lex_state->output_filter; - SCNG(script_encoding) = lex_state->script_encoding; - - RESET_DOC_COMMENT(); -} - -ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC) -{ - zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles); - /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */ - file_handle->opened_path = NULL; - if (file_handle->free_filename) { - file_handle->filename = NULL; - } -} - -#define BOM_UTF32_BE "\x00\x00\xfe\xff" -#define BOM_UTF32_LE "\xff\xfe\x00\x00" -#define BOM_UTF16_BE "\xfe\xff" -#define BOM_UTF16_LE "\xff\xfe" -#define BOM_UTF8 "\xef\xbb\xbf" - -static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size TSRMLS_DC) -{ - const unsigned char *p; - int wchar_size = 2; - int le = 0; - - /* utf-16 or utf-32? */ - p = script; - while ((p-script) < script_size) { - p = memchr(p, 0, script_size-(p-script)-2); - if (!p) { - break; - } - if (*(p+1) == '\0' && *(p+2) == '\0') { - wchar_size = 4; - break; - } - - /* searching for UTF-32 specific byte orders, so this will do */ - p += 4; - } - - /* BE or LE? */ - p = script; - while ((p-script) < script_size) { - if (*p == '\0' && *(p+wchar_size-1) != '\0') { - /* BE */ - le = 0; - break; - } else if (*p != '\0' && *(p+wchar_size-1) == '\0') { - /* LE* */ - le = 1; - break; - } - p += wchar_size; - } - - if (wchar_size == 2) { - return le ? zend_multibyte_encoding_utf16le : zend_multibyte_encoding_utf16be; - } else { - return le ? zend_multibyte_encoding_utf32le : zend_multibyte_encoding_utf32be; - } - - return NULL; -} - -static const zend_encoding* zend_multibyte_detect_unicode(TSRMLS_D) -{ - const zend_encoding *script_encoding = NULL; - int bom_size; - unsigned char *pos1, *pos2; - - if (LANG_SCNG(script_org_size) < sizeof(BOM_UTF32_LE)-1) { - return NULL; - } - - /* check out BOM */ - if (!memcmp(LANG_SCNG(script_org), BOM_UTF32_BE, sizeof(BOM_UTF32_BE)-1)) { - script_encoding = zend_multibyte_encoding_utf32be; - bom_size = sizeof(BOM_UTF32_BE)-1; - } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF32_LE, sizeof(BOM_UTF32_LE)-1)) { - script_encoding = zend_multibyte_encoding_utf32le; - bom_size = sizeof(BOM_UTF32_LE)-1; - } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF16_BE, sizeof(BOM_UTF16_BE)-1)) { - script_encoding = zend_multibyte_encoding_utf16be; - bom_size = sizeof(BOM_UTF16_BE)-1; - } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF16_LE, sizeof(BOM_UTF16_LE)-1)) { - script_encoding = zend_multibyte_encoding_utf16le; - bom_size = sizeof(BOM_UTF16_LE)-1; - } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF8, sizeof(BOM_UTF8)-1)) { - script_encoding = zend_multibyte_encoding_utf8; - bom_size = sizeof(BOM_UTF8)-1; - } - - if (script_encoding) { - /* remove BOM */ - LANG_SCNG(script_org) += bom_size; - LANG_SCNG(script_org_size) -= bom_size; - - return script_encoding; - } - - /* script contains NULL bytes -> auto-detection */ - if ((pos1 = memchr(LANG_SCNG(script_org), 0, LANG_SCNG(script_org_size)))) { - /* check if the NULL byte is after the __HALT_COMPILER(); */ - pos2 = LANG_SCNG(script_org); - - while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) { - pos2 = memchr(pos2, '_', pos1 - pos2); - if (!pos2) break; - pos2++; - if (strncasecmp((char*)pos2, "_HALT_COMPILER", sizeof("_HALT_COMPILER")-1) == 0) { - pos2 += sizeof("_HALT_COMPILER")-1; - while (*pos2 == ' ' || - *pos2 == '\t' || - *pos2 == '\r' || - *pos2 == '\n') { - pos2++; - } - if (*pos2 == '(') { - pos2++; - while (*pos2 == ' ' || - *pos2 == '\t' || - *pos2 == '\r' || - *pos2 == '\n') { - pos2++; - } - if (*pos2 == ')') { - pos2++; - while (*pos2 == ' ' || - *pos2 == '\t' || - *pos2 == '\r' || - *pos2 == '\n') { - pos2++; - } - if (*pos2 == ';') { - return NULL; - } - } - } - } - } - /* make best effort if BOM is missing */ - return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size) TSRMLS_CC); - } - - return NULL; -} - -static const zend_encoding* zend_multibyte_find_script_encoding(TSRMLS_D) -{ - const zend_encoding *script_encoding; - - if (CG(detect_unicode)) { - /* check out bom(byte order mark) and see if containing wchars */ - script_encoding = zend_multibyte_detect_unicode(TSRMLS_C); - if (script_encoding != NULL) { - /* bom or wchar detection is prior to 'script_encoding' option */ - return script_encoding; - } - } - - /* if no script_encoding specified, just leave alone */ - if (!CG(script_encoding_list) || !CG(script_encoding_list_size)) { - return NULL; - } - - /* if multiple encodings specified, detect automagically */ - if (CG(script_encoding_list_size) > 1) { - return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size) TSRMLS_CC); - } - - return CG(script_encoding_list)[0]; -} - -ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSRMLS_DC) -{ - const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); - const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(TSRMLS_C); - - if (!script_encoding) { - return FAILURE; - } - - /* judge input/output filter */ - LANG_SCNG(script_encoding) = script_encoding; - LANG_SCNG(input_filter) = NULL; - LANG_SCNG(output_filter) = NULL; - - if (!internal_encoding || LANG_SCNG(script_encoding) == internal_encoding) { - if (!zend_multibyte_check_lexer_compatibility(LANG_SCNG(script_encoding))) { - /* and if not, work around w/ script_encoding -> utf-8 -> script_encoding conversion */ - LANG_SCNG(input_filter) = encoding_filter_script_to_intermediate; - LANG_SCNG(output_filter) = encoding_filter_intermediate_to_script; - } else { - LANG_SCNG(input_filter) = NULL; - LANG_SCNG(output_filter) = NULL; - } - return SUCCESS; - } - - if (zend_multibyte_check_lexer_compatibility(internal_encoding)) { - LANG_SCNG(input_filter) = encoding_filter_script_to_internal; - LANG_SCNG(output_filter) = NULL; - } else if (zend_multibyte_check_lexer_compatibility(LANG_SCNG(script_encoding))) { - LANG_SCNG(input_filter) = NULL; - LANG_SCNG(output_filter) = encoding_filter_script_to_internal; - } else { - /* both script and internal encodings are incompatible w/ flex */ - LANG_SCNG(input_filter) = encoding_filter_script_to_intermediate; - LANG_SCNG(output_filter) = encoding_filter_intermediate_to_internal; - } - - return 0; -} - -ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC) -{ - const char *file_path = NULL; - char *buf; - size_t size, offset = 0; - - /* The shebang line was read, get the current position to obtain the buffer start */ - if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) { - if ((offset = ftell(file_handle->handle.fp)) == -1) { - offset = 0; - } - } - - if (zend_stream_fixup(file_handle, &buf, &size TSRMLS_CC) == FAILURE) { - return FAILURE; - } - - zend_llist_add_element(&CG(open_files), file_handle); - if (file_handle->handle.stream.handle >= (void*)file_handle && file_handle->handle.stream.handle <= (void*)(file_handle+1)) { - zend_file_handle *fh = (zend_file_handle*)zend_llist_get_last(&CG(open_files)); - size_t diff = (char*)file_handle->handle.stream.handle - (char*)file_handle; - fh->handle.stream.handle = (void*)(((char*)fh) + diff); - file_handle->handle.stream.handle = fh->handle.stream.handle; - } - - /* Reset the scanner for scanning the new file */ - SCNG(yy_in) = file_handle; - SCNG(yy_start) = NULL; - - if (size != -1) { - if (CG(multibyte)) { - SCNG(script_org) = (unsigned char*)buf; - SCNG(script_org_size) = size; - SCNG(script_filtered) = NULL; - - zend_multibyte_set_filter(NULL TSRMLS_CC); - - if (SCNG(input_filter)) { - if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { - zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " - "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); - } - buf = (char*)SCNG(script_filtered); - size = SCNG(script_filtered_size); - } - } - SCNG(yy_start) = (unsigned char *)buf - offset; - yy_scan_buffer(buf, size TSRMLS_CC); - } else { - zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed"); - } - - BEGIN(INITIAL); - - if (file_handle->opened_path) { - file_path = file_handle->opened_path; - } else { - file_path = file_handle->filename; - } - - zend_set_compiled_filename(file_path TSRMLS_CC); - - if (CG(start_lineno)) { - CG(zend_lineno) = CG(start_lineno); - CG(start_lineno) = 0; - } else { - CG(zend_lineno) = 1; - } - - RESET_DOC_COMMENT(); - CG(increment_lineno) = 0; - return SUCCESS; -} -END_EXTERN_C() - - -ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) -{ - zend_lex_state original_lex_state; - zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); - zend_op_array *original_active_op_array = CG(active_op_array); - zend_op_array *retval=NULL; - int compiler_result; - zend_bool compilation_successful=0; - znode retval_znode; - zend_bool original_in_compilation = CG(in_compilation); - - retval_znode.op_type = IS_CONST; - retval_znode.u.constant.type = IS_LONG; - retval_znode.u.constant.value.lval = 1; - Z_UNSET_ISREF(retval_znode.u.constant); - Z_SET_REFCOUNT(retval_znode.u.constant, 1); - - zend_save_lexical_state(&original_lex_state TSRMLS_CC); - - retval = op_array; /* success oriented */ - - if (open_file_for_scanning(file_handle TSRMLS_CC)==FAILURE) { - if (type==ZEND_REQUIRE) { - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); - zend_bailout(); - } else { - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); - } - compilation_successful=0; - } else { - init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); - CG(in_compilation) = 1; - CG(active_op_array) = op_array; - zend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context))); - zend_init_compiler_context(TSRMLS_C); - compiler_result = zendparse(TSRMLS_C); - zend_do_return(&retval_znode, 0 TSRMLS_CC); - CG(in_compilation) = original_in_compilation; - if (compiler_result != 0) { /* parser error */ - zend_bailout(); - } - compilation_successful=1; - } - - if (retval) { - CG(active_op_array) = original_active_op_array; - if (compilation_successful) { - pass_two(op_array TSRMLS_CC); - zend_release_labels(0 TSRMLS_CC); - } else { - efree(op_array); - retval = NULL; - } - } - zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - return retval; -} - - -zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC) -{ - zend_file_handle file_handle; - zval tmp; - zend_op_array *retval; - char *opened_path = NULL; - - if (filename->type != IS_STRING) { - tmp = *filename; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - filename = &tmp; - } - file_handle.filename = filename->value.str.val; - file_handle.free_filename = 0; - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.opened_path = NULL; - file_handle.handle.fp = NULL; - - retval = zend_compile_file(&file_handle, type TSRMLS_CC); - if (retval && file_handle.handle.stream.handle) { - int dummy = 1; - - if (!file_handle.opened_path) { - file_handle.opened_path = opened_path = estrndup(filename->value.str.val, filename->value.str.len); - } - - zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL); - - if (opened_path) { - efree(opened_path); - } - } - zend_destroy_file_handle(&file_handle TSRMLS_CC); - - if (filename==&tmp) { - zval_dtor(&tmp); - } - return retval; -} - -ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) -{ - char *buf; - size_t size; - - /* enforce two trailing NULLs for flex... */ - if (IS_INTERNED(str->value.str.val)) { - char *tmp = safe_emalloc(1, str->value.str.len, ZEND_MMAP_AHEAD); - memcpy(tmp, str->value.str.val, str->value.str.len + ZEND_MMAP_AHEAD); - str->value.str.val = tmp; - } else { - str->value.str.val = safe_erealloc(str->value.str.val, 1, str->value.str.len, ZEND_MMAP_AHEAD); - } - - memset(str->value.str.val + str->value.str.len, 0, ZEND_MMAP_AHEAD); - - SCNG(yy_in) = NULL; - SCNG(yy_start) = NULL; - - buf = str->value.str.val; - size = str->value.str.len; - - if (CG(multibyte)) { - SCNG(script_org) = (unsigned char*)buf; - SCNG(script_org_size) = size; - SCNG(script_filtered) = NULL; - - zend_multibyte_set_filter(zend_multibyte_get_internal_encoding(TSRMLS_C) TSRMLS_CC); - - if (SCNG(input_filter)) { - if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { - zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " - "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); - } - buf = (char*)SCNG(script_filtered); - size = SCNG(script_filtered_size); - } - } - - yy_scan_buffer(buf, size TSRMLS_CC); - - zend_set_compiled_filename(filename TSRMLS_CC); - CG(zend_lineno) = 1; - CG(increment_lineno) = 0; - RESET_DOC_COMMENT(); - return SUCCESS; -} - - -ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D) -{ - size_t offset = SCNG(yy_cursor) - SCNG(yy_start); - if (SCNG(input_filter)) { - size_t original_offset = offset, length = 0; - do { - unsigned char *p = NULL; - if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC)) { - return (size_t)-1; - } - efree(p); - if (length > original_offset) { - offset--; - } else if (length < original_offset) { - offset++; - } - } while (original_offset != length); - } - return offset; -} - - -zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC) -{ - zend_lex_state original_lex_state; - zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); - zend_op_array *original_active_op_array = CG(active_op_array); - zend_op_array *retval; - zval tmp; - int compiler_result; - zend_bool original_in_compilation = CG(in_compilation); - - if (source_string->value.str.len==0) { - efree(op_array); - return NULL; - } - - CG(in_compilation) = 1; - - tmp = *source_string; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - source_string = &tmp; - - zend_save_lexical_state(&original_lex_state TSRMLS_CC); - if (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC)==FAILURE) { - efree(op_array); - retval = NULL; - } else { - zend_bool orig_interactive = CG(interactive); - - CG(interactive) = 0; - init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); - CG(interactive) = orig_interactive; - CG(active_op_array) = op_array; - zend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context))); - zend_init_compiler_context(TSRMLS_C); - BEGIN(ST_IN_SCRIPTING); - compiler_result = zendparse(TSRMLS_C); - - if (SCNG(script_filtered)) { - efree(SCNG(script_filtered)); - SCNG(script_filtered) = NULL; - } - - if (compiler_result != 0) { - CG(active_op_array) = original_active_op_array; - CG(unclean_shutdown)=1; - destroy_op_array(op_array TSRMLS_CC); - efree(op_array); - retval = NULL; - } else { - zend_do_return(NULL, 0 TSRMLS_CC); - CG(active_op_array) = original_active_op_array; - pass_two(op_array TSRMLS_CC); - zend_release_labels(0 TSRMLS_CC); - retval = op_array; - } - } - zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - zval_dtor(&tmp); - CG(in_compilation) = original_in_compilation; - return retval; -} - - -BEGIN_EXTERN_C() -int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) -{ - zend_lex_state original_lex_state; - zend_file_handle file_handle; - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = filename; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - zend_save_lexical_state(&original_lex_state TSRMLS_CC); - if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) { - zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename TSRMLS_CC); - zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - return FAILURE; - } - zend_highlight(syntax_highlighter_ini TSRMLS_CC); - if (SCNG(script_filtered)) { - efree(SCNG(script_filtered)); - SCNG(script_filtered) = NULL; - } - zend_destroy_file_handle(&file_handle TSRMLS_CC); - zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - return SUCCESS; -} - -int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC) -{ - zend_lex_state original_lex_state; - zval tmp = *str; - - str = &tmp; - zval_copy_ctor(str); - zend_save_lexical_state(&original_lex_state TSRMLS_CC); - if (zend_prepare_string_for_scanning(str, str_name TSRMLS_CC)==FAILURE) { - zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - return FAILURE; - } - BEGIN(INITIAL); - zend_highlight(syntax_highlighter_ini TSRMLS_CC); - if (SCNG(script_filtered)) { - efree(SCNG(script_filtered)); - SCNG(script_filtered) = NULL; - } - zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - zval_dtor(str); - return SUCCESS; -} - -ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding TSRMLS_DC) -{ - size_t length; - unsigned char *new_yy_start; - - /* convert and set */ - if (!SCNG(input_filter)) { - if (SCNG(script_filtered)) { - efree(SCNG(script_filtered)); - SCNG(script_filtered) = NULL; - } - SCNG(script_filtered_size) = 0; - length = SCNG(script_org_size); - new_yy_start = SCNG(script_org); - } else { - if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { - zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " - "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); - } - SCNG(script_filtered) = new_yy_start; - SCNG(script_filtered_size) = length; - } - - SCNG(yy_cursor) = new_yy_start + (SCNG(yy_cursor) - SCNG(yy_start)); - SCNG(yy_marker) = new_yy_start + (SCNG(yy_marker) - SCNG(yy_start)); - SCNG(yy_text) = new_yy_start + (SCNG(yy_text) - SCNG(yy_start)); - SCNG(yy_limit) = new_yy_start + (SCNG(yy_limit) - SCNG(yy_start)); - - SCNG(yy_start) = new_yy_start; -} - - -# define zend_copy_value(zendlval, yytext, yyleng) \ - if (SCNG(output_filter)) { \ - size_t sz = 0; \ - SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); \ - zendlval->value.str.len = sz; \ - } else { \ - zendlval->value.str.val = (char *) estrndup(yytext, yyleng); \ - zendlval->value.str.len = yyleng; \ - } - -static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC) -{ - register char *s, *t; - char *end; - - ZVAL_STRINGL(zendlval, str, len, 1); - - /* convert escape sequences */ - s = t = zendlval->value.str.val; - end = s+zendlval->value.str.len; - while (s<end) { - if (*s=='\\') { - s++; - if (s >= end) { - *t++ = '\\'; - break; - } - - switch(*s) { - case 'n': - *t++ = '\n'; - zendlval->value.str.len--; - break; - case 'r': - *t++ = '\r'; - zendlval->value.str.len--; - break; - case 't': - *t++ = '\t'; - zendlval->value.str.len--; - break; - case 'f': - *t++ = '\f'; - zendlval->value.str.len--; - break; - case 'v': - *t++ = '\v'; - zendlval->value.str.len--; - break; - case 'e': -#ifdef PHP_WIN32 - *t++ = VK_ESCAPE; -#else - *t++ = '\e'; -#endif - zendlval->value.str.len--; - break; - case '"': - case '`': - if (*s != quote_type) { - *t++ = '\\'; - *t++ = *s; - break; - } - case '\\': - case '$': - *t++ = *s; - zendlval->value.str.len--; - break; - case 'x': - case 'X': - if (ZEND_IS_HEX(*(s+1))) { - char hex_buf[3] = { 0, 0, 0 }; - - zendlval->value.str.len--; /* for the 'x' */ - - hex_buf[0] = *(++s); - zendlval->value.str.len--; - if (ZEND_IS_HEX(*(s+1))) { - hex_buf[1] = *(++s); - zendlval->value.str.len--; - } - *t++ = (char) strtol(hex_buf, NULL, 16); - } else { - *t++ = '\\'; - *t++ = *s; - } - break; - default: - /* check for an octal */ - if (ZEND_IS_OCT(*s)) { - char octal_buf[4] = { 0, 0, 0, 0 }; - - octal_buf[0] = *s; - zendlval->value.str.len--; - if (ZEND_IS_OCT(*(s+1))) { - octal_buf[1] = *(++s); - zendlval->value.str.len--; - if (ZEND_IS_OCT(*(s+1))) { - octal_buf[2] = *(++s); - zendlval->value.str.len--; - } - } - *t++ = (char) strtol(octal_buf, NULL, 8); - } else { - *t++ = '\\'; - *t++ = *s; - } - break; - } - } else { - *t++ = *s; - } - - if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { - CG(zend_lineno)++; - } - s++; - } - *t = 0; - if (SCNG(output_filter)) { - size_t sz = 0; - s = zendlval->value.str.val; - SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)s, (size_t)zendlval->value.str.len TSRMLS_CC); - zendlval->value.str.len = sz; - efree(s); - } -} - - -int lex_scan(zval *zendlval TSRMLS_DC) -{ -restart: - SCNG(yy_text) = YYCURSOR; - -yymore_restart: - -/*!re2c -re2c:yyfill:check = 0; -LNUM [0-9]+ -DNUM ([0-9]*"."[0-9]+)|([0-9]+"."[0-9]*) -EXPONENT_DNUM (({LNUM}|{DNUM})[eE][+-]?{LNUM}) -HNUM "0x"[0-9a-fA-F]+ -BNUM "0b"[01]+ -LABEL [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* -WHITESPACE [ \n\r\t]+ -TABS_AND_SPACES [ \t]* -TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@] -ANY_CHAR [^] -NEWLINE ("\r"|"\n"|"\r\n") - -/* compute yyleng before each rule */ -<!*> := yyleng = YYCURSOR - SCNG(yy_text); - - -<ST_IN_SCRIPTING>"exit" { - return T_EXIT; -} - -<ST_IN_SCRIPTING>"die" { - return T_EXIT; -} - -<ST_IN_SCRIPTING>"function" { - return T_FUNCTION; -} - -<ST_IN_SCRIPTING>"const" { - return T_CONST; -} - -<ST_IN_SCRIPTING>"return" { - return T_RETURN; -} - -<ST_IN_SCRIPTING>"yield" { - return T_YIELD; -} - -<ST_IN_SCRIPTING>"try" { - return T_TRY; -} - -<ST_IN_SCRIPTING>"catch" { - return T_CATCH; -} - -<ST_IN_SCRIPTING>"finally" { - return T_FINALLY; -} - -<ST_IN_SCRIPTING>"throw" { - return T_THROW; -} - -<ST_IN_SCRIPTING>"if" { - return T_IF; -} - -<ST_IN_SCRIPTING>"elseif" { - return T_ELSEIF; -} - -<ST_IN_SCRIPTING>"endif" { - return T_ENDIF; -} - -<ST_IN_SCRIPTING>"else" { - return T_ELSE; -} - -<ST_IN_SCRIPTING>"while" { - return T_WHILE; -} - -<ST_IN_SCRIPTING>"endwhile" { - return T_ENDWHILE; -} - -<ST_IN_SCRIPTING>"do" { - return T_DO; -} - -<ST_IN_SCRIPTING>"for" { - return T_FOR; -} - -<ST_IN_SCRIPTING>"endfor" { - return T_ENDFOR; -} - -<ST_IN_SCRIPTING>"foreach" { - return T_FOREACH; -} - -<ST_IN_SCRIPTING>"endforeach" { - return T_ENDFOREACH; -} - -<ST_IN_SCRIPTING>"declare" { - return T_DECLARE; -} - -<ST_IN_SCRIPTING>"enddeclare" { - return T_ENDDECLARE; -} - -<ST_IN_SCRIPTING>"instanceof" { - return T_INSTANCEOF; -} - -<ST_IN_SCRIPTING>"as" { - return T_AS; -} - -<ST_IN_SCRIPTING>"switch" { - return T_SWITCH; -} - -<ST_IN_SCRIPTING>"endswitch" { - return T_ENDSWITCH; -} - -<ST_IN_SCRIPTING>"case" { - return T_CASE; -} - -<ST_IN_SCRIPTING>"default" { - return T_DEFAULT; -} - -<ST_IN_SCRIPTING>"break" { - return T_BREAK; -} - -<ST_IN_SCRIPTING>"continue" { - return T_CONTINUE; -} - -<ST_IN_SCRIPTING>"goto" { - return T_GOTO; -} - -<ST_IN_SCRIPTING>"echo" { - return T_ECHO; -} - -<ST_IN_SCRIPTING>"print" { - return T_PRINT; -} - -<ST_IN_SCRIPTING>"class" { - return T_CLASS; -} - -<ST_IN_SCRIPTING>"interface" { - return T_INTERFACE; -} - -<ST_IN_SCRIPTING>"trait" { - return T_TRAIT; -} - -<ST_IN_SCRIPTING>"extends" { - return T_EXTENDS; -} - -<ST_IN_SCRIPTING>"implements" { - return T_IMPLEMENTS; -} - -<ST_IN_SCRIPTING>"->" { - yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); - return T_OBJECT_OPERATOR; -} - -<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>{WHITESPACE}+ { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - HANDLE_NEWLINES(yytext, yyleng); - return T_WHITESPACE; -} - -<ST_LOOKING_FOR_PROPERTY>"->" { - return T_OBJECT_OPERATOR; -} - -<ST_LOOKING_FOR_PROPERTY>{LABEL} { - yy_pop_state(TSRMLS_C); - zend_copy_value(zendlval, yytext, yyleng); - zendlval->type = IS_STRING; - return T_STRING; -} - -<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} { - yyless(0); - yy_pop_state(TSRMLS_C); - goto restart; -} - -<ST_IN_SCRIPTING>"::" { - return T_PAAMAYIM_NEKUDOTAYIM; -} - -<ST_IN_SCRIPTING>"\\" { - return T_NS_SEPARATOR; -} - -<ST_IN_SCRIPTING>"new" { - return T_NEW; -} - -<ST_IN_SCRIPTING>"clone" { - return T_CLONE; -} - -<ST_IN_SCRIPTING>"var" { - return T_VAR; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("int"|"integer"){TABS_AND_SPACES}")" { - return T_INT_CAST; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("real"|"double"|"float"){TABS_AND_SPACES}")" { - return T_DOUBLE_CAST; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("string"|"binary"){TABS_AND_SPACES}")" { - return T_STRING_CAST; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"array"{TABS_AND_SPACES}")" { - return T_ARRAY_CAST; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"object"{TABS_AND_SPACES}")" { - return T_OBJECT_CAST; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" { - return T_BOOL_CAST; -} - -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("unset"){TABS_AND_SPACES}")" { - return T_UNSET_CAST; -} - -<ST_IN_SCRIPTING>"eval" { - return T_EVAL; -} - -<ST_IN_SCRIPTING>"include" { - return T_INCLUDE; -} - -<ST_IN_SCRIPTING>"include_once" { - return T_INCLUDE_ONCE; -} - -<ST_IN_SCRIPTING>"require" { - return T_REQUIRE; -} - -<ST_IN_SCRIPTING>"require_once" { - return T_REQUIRE_ONCE; -} - -<ST_IN_SCRIPTING>"namespace" { - return T_NAMESPACE; -} - -<ST_IN_SCRIPTING>"use" { - return T_USE; -} - -<ST_IN_SCRIPTING>"insteadof" { - return T_INSTEADOF; -} - -<ST_IN_SCRIPTING>"global" { - return T_GLOBAL; -} - -<ST_IN_SCRIPTING>"isset" { - return T_ISSET; -} - -<ST_IN_SCRIPTING>"empty" { - return T_EMPTY; -} - -<ST_IN_SCRIPTING>"__halt_compiler" { - return T_HALT_COMPILER; -} - -<ST_IN_SCRIPTING>"static" { - return T_STATIC; -} - -<ST_IN_SCRIPTING>"abstract" { - return T_ABSTRACT; -} - -<ST_IN_SCRIPTING>"final" { - return T_FINAL; -} - -<ST_IN_SCRIPTING>"private" { - return T_PRIVATE; -} - -<ST_IN_SCRIPTING>"protected" { - return T_PROTECTED; -} - -<ST_IN_SCRIPTING>"public" { - return T_PUBLIC; -} - -<ST_IN_SCRIPTING>"unset" { - return T_UNSET; -} - -<ST_IN_SCRIPTING>"=>" { - return T_DOUBLE_ARROW; -} - -<ST_IN_SCRIPTING>"list" { - return T_LIST; -} - -<ST_IN_SCRIPTING>"array" { - return T_ARRAY; -} - -<ST_IN_SCRIPTING>"callable" { - return T_CALLABLE; -} - -<ST_IN_SCRIPTING>"++" { - return T_INC; -} - -<ST_IN_SCRIPTING>"--" { - return T_DEC; -} - -<ST_IN_SCRIPTING>"===" { - return T_IS_IDENTICAL; -} - -<ST_IN_SCRIPTING>"!==" { - return T_IS_NOT_IDENTICAL; -} - -<ST_IN_SCRIPTING>"==" { - return T_IS_EQUAL; -} - -<ST_IN_SCRIPTING>"!="|"<>" { - return T_IS_NOT_EQUAL; -} - -<ST_IN_SCRIPTING>"<=" { - return T_IS_SMALLER_OR_EQUAL; -} - -<ST_IN_SCRIPTING>">=" { - return T_IS_GREATER_OR_EQUAL; -} - -<ST_IN_SCRIPTING>"+=" { - return T_PLUS_EQUAL; -} - -<ST_IN_SCRIPTING>"-=" { - return T_MINUS_EQUAL; -} - -<ST_IN_SCRIPTING>"*=" { - return T_MUL_EQUAL; -} - -<ST_IN_SCRIPTING>"/=" { - return T_DIV_EQUAL; -} - -<ST_IN_SCRIPTING>".=" { - return T_CONCAT_EQUAL; -} - -<ST_IN_SCRIPTING>"%=" { - return T_MOD_EQUAL; -} - -<ST_IN_SCRIPTING>"<<=" { - return T_SL_EQUAL; -} - -<ST_IN_SCRIPTING>">>=" { - return T_SR_EQUAL; -} - -<ST_IN_SCRIPTING>"&=" { - return T_AND_EQUAL; -} - -<ST_IN_SCRIPTING>"|=" { - return T_OR_EQUAL; -} - -<ST_IN_SCRIPTING>"^=" { - return T_XOR_EQUAL; -} - -<ST_IN_SCRIPTING>"||" { - return T_BOOLEAN_OR; -} - -<ST_IN_SCRIPTING>"&&" { - return T_BOOLEAN_AND; -} - -<ST_IN_SCRIPTING>"OR" { - return T_LOGICAL_OR; -} - -<ST_IN_SCRIPTING>"AND" { - return T_LOGICAL_AND; -} - -<ST_IN_SCRIPTING>"XOR" { - return T_LOGICAL_XOR; -} - -<ST_IN_SCRIPTING>"<<" { - return T_SL; -} - -<ST_IN_SCRIPTING>">>" { - return T_SR; -} - -<ST_IN_SCRIPTING>{TOKENS} { - return yytext[0]; -} - - -<ST_IN_SCRIPTING>"{" { - yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); - return '{'; -} - - -<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"${" { - yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); - return T_DOLLAR_OPEN_CURLY_BRACES; -} - - -<ST_IN_SCRIPTING>"}" { - RESET_DOC_COMMENT(); - if (!zend_stack_is_empty(&SCNG(state_stack))) { - yy_pop_state(TSRMLS_C); - } - return '}'; -} - - -<ST_LOOKING_FOR_VARNAME>{LABEL}[[}] { - yyless(yyleng - 1); - zend_copy_value(zendlval, yytext, yyleng); - zendlval->type = IS_STRING; - yy_pop_state(TSRMLS_C); - yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); - return T_STRING_VARNAME; -} - - -<ST_LOOKING_FOR_VARNAME>{ANY_CHAR} { - yyless(0); - yy_pop_state(TSRMLS_C); - yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); - goto restart; -} - -<ST_IN_SCRIPTING>{BNUM} { - char *bin = yytext + 2; /* Skip "0b" */ - int len = yyleng - 2; - - /* Skip any leading 0s */ - while (*bin == '0') { - ++bin; - --len; - } - - if (len < SIZEOF_LONG * 8) { - if (len == 0) { - zendlval->value.lval = 0; - } else { - zendlval->value.lval = strtol(bin, NULL, 2); - } - zendlval->type = IS_LONG; - return T_LNUMBER; - } else { - zendlval->value.dval = zend_bin_strtod(bin, NULL); - zendlval->type = IS_DOUBLE; - return T_DNUMBER; - } -} - -<ST_IN_SCRIPTING>{LNUM} { - if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ - zendlval->value.lval = strtol(yytext, NULL, 0); - } else { - errno = 0; - zendlval->value.lval = strtol(yytext, NULL, 0); - if (errno == ERANGE) { /* Overflow */ - if (yytext[0] == '0') { /* octal overflow */ - zendlval->value.dval = zend_oct_strtod(yytext, NULL); - } else { - zendlval->value.dval = zend_strtod(yytext, NULL); - } - zendlval->type = IS_DOUBLE; - return T_DNUMBER; - } - } - - zendlval->type = IS_LONG; - return T_LNUMBER; -} - -<ST_IN_SCRIPTING>{HNUM} { - char *hex = yytext + 2; /* Skip "0x" */ - int len = yyleng - 2; - - /* Skip any leading 0s */ - while (*hex == '0') { - hex++; - len--; - } - - if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) { - if (len == 0) { - zendlval->value.lval = 0; - } else { - zendlval->value.lval = strtol(hex, NULL, 16); - } - zendlval->type = IS_LONG; - return T_LNUMBER; - } else { - zendlval->value.dval = zend_hex_strtod(hex, NULL); - zendlval->type = IS_DOUBLE; - return T_DNUMBER; - } -} - -<ST_VAR_OFFSET>[0]|([1-9][0-9]*) { /* Offset could be treated as a long */ - if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { - zendlval->value.lval = strtol(yytext, NULL, 10); - zendlval->type = IS_LONG; - } else { - zendlval->value.str.val = (char *)estrndup(yytext, yyleng); - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - } - return T_NUM_STRING; -} - -<ST_VAR_OFFSET>{LNUM}|{HNUM}|{BNUM} { /* Offset must be treated as a string */ - zendlval->value.str.val = (char *)estrndup(yytext, yyleng); - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - return T_NUM_STRING; -} - -<ST_IN_SCRIPTING>{DNUM}|{EXPONENT_DNUM} { - zendlval->value.dval = zend_strtod(yytext, NULL); - zendlval->type = IS_DOUBLE; - return T_DNUMBER; -} - -<ST_IN_SCRIPTING>"__CLASS__" { - const char *class_name = NULL; - - if (CG(active_class_entry) - && (ZEND_ACC_TRAIT == - (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT))) { - /* We create a special __CLASS__ constant that is going to be resolved - at run-time */ - zendlval->value.str.len = sizeof("__CLASS__")-1; - zendlval->value.str.val = estrndup("__CLASS__", zendlval->value.str.len); - zendlval->type = IS_CONSTANT; - } else { - if (CG(active_class_entry)) { - class_name = CG(active_class_entry)->name; - } - - if (!class_name) { - class_name = ""; - } - - zendlval->value.str.len = strlen(class_name); - zendlval->value.str.val = estrndup(class_name, zendlval->value.str.len); - zendlval->type = IS_STRING; - } - return T_CLASS_C; -} - -<ST_IN_SCRIPTING>"__TRAIT__" { - const char *trait_name = NULL; - - if (CG(active_class_entry) - && (ZEND_ACC_TRAIT == - (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT))) { - trait_name = CG(active_class_entry)->name; - } - - if (!trait_name) { - trait_name = ""; - } - - zendlval->value.str.len = strlen(trait_name); - zendlval->value.str.val = estrndup(trait_name, zendlval->value.str.len); - zendlval->type = IS_STRING; - - return T_TRAIT_C; -} - -<ST_IN_SCRIPTING>"__FUNCTION__" { - const char *func_name = NULL; - - if (CG(active_op_array)) { - func_name = CG(active_op_array)->function_name; - } - - if (!func_name) { - func_name = ""; - } - zendlval->value.str.len = strlen(func_name); - zendlval->value.str.val = estrndup(func_name, zendlval->value.str.len); - zendlval->type = IS_STRING; - return T_FUNC_C; -} - -<ST_IN_SCRIPTING>"__METHOD__" { - const char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL; - const char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL; - size_t len = 0; - - if (class_name) { - len += strlen(class_name) + 2; - } - if (func_name) { - len += strlen(func_name); - } - - zendlval->value.str.len = zend_spprintf(&zendlval->value.str.val, 0, "%s%s%s", - class_name ? class_name : "", - class_name && func_name ? "::" : "", - func_name ? func_name : "" - ); - zendlval->type = IS_STRING; - return T_METHOD_C; -} - -<ST_IN_SCRIPTING>"__LINE__" { - zendlval->value.lval = CG(zend_lineno); - zendlval->type = IS_LONG; - return T_LINE; -} - -<ST_IN_SCRIPTING>"__FILE__" { - char *filename = zend_get_compiled_filename(TSRMLS_C); - - if (!filename) { - filename = ""; - } - zendlval->value.str.len = strlen(filename); - zendlval->value.str.val = estrndup(filename, zendlval->value.str.len); - zendlval->type = IS_STRING; - return T_FILE; -} - -<ST_IN_SCRIPTING>"__DIR__" { - char *filename = zend_get_compiled_filename(TSRMLS_C); - const size_t filename_len = strlen(filename); - char *dirname; - - if (!filename) { - filename = ""; - } - - dirname = estrndup(filename, filename_len); - zend_dirname(dirname, filename_len); - - if (strcmp(dirname, ".") == 0) { - dirname = erealloc(dirname, MAXPATHLEN); -#if HAVE_GETCWD - VCWD_GETCWD(dirname, MAXPATHLEN); -#elif HAVE_GETWD - VCWD_GETWD(dirname); -#endif - } - - zendlval->value.str.len = strlen(dirname); - zendlval->value.str.val = dirname; - zendlval->type = IS_STRING; - return T_DIR; -} - -<ST_IN_SCRIPTING>"__NAMESPACE__" { - if (CG(current_namespace)) { - *zendlval = *CG(current_namespace); - zval_copy_ctor(zendlval); - } else { - ZVAL_EMPTY_STRING(zendlval); - } - return T_NS_C; -} - -<INITIAL>"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"'php'"){WHITESPACE}*">" { - YYCTYPE *bracket = (YYCTYPE*)zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1)); - - if (bracket != SCNG(yy_text)) { - /* Handle previously scanned HTML, as possible <script> tags found are assumed to not be PHP's */ - YYCURSOR = bracket; - goto inline_html; - } - - HANDLE_NEWLINES(yytext, yyleng); - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - BEGIN(ST_IN_SCRIPTING); - return T_OPEN_TAG; -} - - -<INITIAL>"<%=" { - if (CG(asp_tags)) { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - BEGIN(ST_IN_SCRIPTING); - return T_OPEN_TAG_WITH_ECHO; - } else { - goto inline_char_handler; - } -} - - -<INITIAL>"<?=" { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - BEGIN(ST_IN_SCRIPTING); - return T_OPEN_TAG_WITH_ECHO; -} - - -<INITIAL>"<%" { - if (CG(asp_tags)) { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - BEGIN(ST_IN_SCRIPTING); - return T_OPEN_TAG; - } else { - goto inline_char_handler; - } -} - - -<INITIAL>"<?php"([ \t]|{NEWLINE}) { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - HANDLE_NEWLINE(yytext[yyleng-1]); - BEGIN(ST_IN_SCRIPTING); - return T_OPEN_TAG; -} - - -<INITIAL>"<?" { - if (CG(short_tags)) { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - BEGIN(ST_IN_SCRIPTING); - return T_OPEN_TAG; - } else { - goto inline_char_handler; - } -} - -<INITIAL>{ANY_CHAR} { - if (YYCURSOR > YYLIMIT) { - return 0; - } - -inline_char_handler: - - while (1) { - YYCTYPE *ptr = memchr(YYCURSOR, '<', YYLIMIT - YYCURSOR); - - YYCURSOR = ptr ? ptr + 1 : YYLIMIT; - - if (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR) { - case '?': - if (CG(short_tags) || !strncasecmp((char*)YYCURSOR + 1, "php", 3) || (*(YYCURSOR + 1) == '=')) { /* Assume [ \t\n\r] follows "php" */ - break; - } - continue; - case '%': - if (CG(asp_tags)) { - break; - } - continue; - case 's': - case 'S': - /* Probably NOT an opening PHP <script> tag, so don't end the HTML chunk yet - * If it is, the PHP <script> tag rule checks for any HTML scanned before it */ - YYCURSOR--; - yymore(); - default: - continue; - } - - YYCURSOR--; - } - - break; - } - -inline_html: - yyleng = YYCURSOR - SCNG(yy_text); - - if (SCNG(output_filter)) { - int readsize; - size_t sz = 0; - readsize = SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); - zendlval->value.str.len = sz; - if (readsize < yyleng) { - yyless(readsize); - } - } else { - zendlval->value.str.val = (char *) estrndup(yytext, yyleng); - zendlval->value.str.len = yyleng; - } - zendlval->type = IS_STRING; - HANDLE_NEWLINES(yytext, yyleng); - return T_INLINE_HTML; -} - - -/* Make sure a label character follows "->", otherwise there is no property - * and "->" will be taken literally - */ -<ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"->"[a-zA-Z_\x7f-\xff] { - yyless(yyleng - 3); - yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); - zend_copy_value(zendlval, (yytext+1), (yyleng-1)); - zendlval->type = IS_STRING; - return T_VARIABLE; -} - -/* A [ always designates a variable offset, regardless of what follows - */ -<ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"[" { - yyless(yyleng - 1); - yy_push_state(ST_VAR_OFFSET TSRMLS_CC); - zend_copy_value(zendlval, (yytext+1), (yyleng-1)); - zendlval->type = IS_STRING; - return T_VARIABLE; -} - -<ST_IN_SCRIPTING,ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE,ST_VAR_OFFSET>"$"{LABEL} { - zend_copy_value(zendlval, (yytext+1), (yyleng-1)); - zendlval->type = IS_STRING; - return T_VARIABLE; -} - -<ST_VAR_OFFSET>"]" { - yy_pop_state(TSRMLS_C); - return ']'; -} - -<ST_VAR_OFFSET>{TOKENS}|[{}"`] { - /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */ - return yytext[0]; -} - -<ST_VAR_OFFSET>[ \n\r\t\\'#] { - /* Invalid rule to return a more explicit parse error with proper line number */ - yyless(0); - yy_pop_state(TSRMLS_C); - return T_ENCAPSED_AND_WHITESPACE; -} - -<ST_IN_SCRIPTING,ST_VAR_OFFSET>{LABEL} { - zend_copy_value(zendlval, yytext, yyleng); - zendlval->type = IS_STRING; - return T_STRING; -} - - -<ST_IN_SCRIPTING>"#"|"//" { - while (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR++) { - case '\r': - if (*YYCURSOR == '\n') { - YYCURSOR++; - } - /* fall through */ - case '\n': - CG(zend_lineno)++; - break; - case '%': - if (!CG(asp_tags)) { - continue; - } - /* fall through */ - case '?': - if (*YYCURSOR == '>') { - YYCURSOR--; - break; - } - /* fall through */ - default: - continue; - } - - break; - } - - yyleng = YYCURSOR - SCNG(yy_text); - - return T_COMMENT; -} - -<ST_IN_SCRIPTING>"/*"|"/**"{WHITESPACE} { - int doc_com; - - if (yyleng > 2) { - doc_com = 1; - RESET_DOC_COMMENT(); - } else { - doc_com = 0; - } - - while (YYCURSOR < YYLIMIT) { - if (*YYCURSOR++ == '*' && *YYCURSOR == '/') { - break; - } - } - - if (YYCURSOR < YYLIMIT) { - YYCURSOR++; - } else { - zend_error(E_COMPILE_WARNING, "Unterminated comment starting line %d", CG(zend_lineno)); - } - - yyleng = YYCURSOR - SCNG(yy_text); - HANDLE_NEWLINES(yytext, yyleng); - - if (doc_com) { - CG(doc_comment) = estrndup(yytext, yyleng); - CG(doc_comment_len) = yyleng; - return T_DOC_COMMENT; - } - - return T_COMMENT; -} - -<ST_IN_SCRIPTING>("?>"|"</script"{WHITESPACE}*">"){NEWLINE}? { - zendlval->value.str.val = yytext; /* no copying - intentional */ - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - BEGIN(INITIAL); - return T_CLOSE_TAG; /* implicit ';' at php-end tag */ -} - - -<ST_IN_SCRIPTING>"%>"{NEWLINE}? { - if (CG(asp_tags)) { - BEGIN(INITIAL); - zendlval->value.str.len = yyleng; - zendlval->type = IS_STRING; - zendlval->value.str.val = yytext; /* no copying - intentional */ - return T_CLOSE_TAG; /* implicit ';' at php-end tag */ - } else { - yyless(1); - return yytext[0]; - } -} - - -<ST_IN_SCRIPTING>b?['] { - register char *s, *t; - char *end; - int bprefix = (yytext[0] != '\'') ? 1 : 0; - - while (1) { - if (YYCURSOR < YYLIMIT) { - if (*YYCURSOR == '\'') { - YYCURSOR++; - yyleng = YYCURSOR - SCNG(yy_text); - - break; - } else if (*YYCURSOR++ == '\\' && YYCURSOR < YYLIMIT) { - YYCURSOR++; - } - } else { - yyleng = YYLIMIT - SCNG(yy_text); - - /* Unclosed single quotes; treat similar to double quotes, but without a separate token - * for ' (unrecognized by parser), instead of old flex fallback to "Unexpected character..." - * rule, which continued in ST_IN_SCRIPTING state after the quote */ - return T_ENCAPSED_AND_WHITESPACE; - } - } - - zendlval->value.str.val = estrndup(yytext+bprefix+1, yyleng-bprefix-2); - zendlval->value.str.len = yyleng-bprefix-2; - zendlval->type = IS_STRING; - - /* convert escape sequences */ - s = t = zendlval->value.str.val; - end = s+zendlval->value.str.len; - while (s<end) { - if (*s=='\\') { - s++; - - switch(*s) { - case '\\': - case '\'': - *t++ = *s; - zendlval->value.str.len--; - break; - default: - *t++ = '\\'; - *t++ = *s; - break; - } - } else { - *t++ = *s; - } - - if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { - CG(zend_lineno)++; - } - s++; - } - *t = 0; - - if (SCNG(output_filter)) { - size_t sz = 0; - s = zendlval->value.str.val; - SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)s, (size_t)zendlval->value.str.len TSRMLS_CC); - zendlval->value.str.len = sz; - efree(s); - } - return T_CONSTANT_ENCAPSED_STRING; -} - - -<ST_IN_SCRIPTING>b?["] { - int bprefix = (yytext[0] != '"') ? 1 : 0; - - while (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR++) { - case '"': - yyleng = YYCURSOR - SCNG(yy_text); - zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC); - return T_CONSTANT_ENCAPSED_STRING; - case '$': - if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { - break; - } - continue; - case '{': - if (*YYCURSOR == '$') { - break; - } - continue; - case '\\': - if (YYCURSOR < YYLIMIT) { - YYCURSOR++; - } - /* fall through */ - default: - continue; - } - - YYCURSOR--; - break; - } - - /* Remember how much was scanned to save rescanning */ - SET_DOUBLE_QUOTES_SCANNED_LENGTH(YYCURSOR - SCNG(yy_text) - yyleng); - - YYCURSOR = SCNG(yy_text) + yyleng; - - BEGIN(ST_DOUBLE_QUOTES); - return '"'; -} - - -<ST_IN_SCRIPTING>b?"<<<"{TABS_AND_SPACES}({LABEL}|([']{LABEL}['])|(["]{LABEL}["])){NEWLINE} { - char *s; - int bprefix = (yytext[0] != '<') ? 1 : 0; - zend_heredoc_label *heredoc_label = emalloc(sizeof(zend_heredoc_label)); - - CG(zend_lineno)++; - heredoc_label->length = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); - s = yytext+bprefix+3; - while ((*s == ' ') || (*s == '\t')) { - s++; - heredoc_label->length--; - } - - if (*s == '\'') { - s++; - heredoc_label->length -= 2; - - BEGIN(ST_NOWDOC); - } else { - if (*s == '"') { - s++; - heredoc_label->length -= 2; - } - - BEGIN(ST_HEREDOC); - } - - heredoc_label->label = estrndup(s, heredoc_label->length); - - /* Check for ending label on the next line */ - if (heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, heredoc_label->length)) { - YYCTYPE *end = YYCURSOR + heredoc_label->length; - - if (*end == ';') { - end++; - } - - if (*end == '\n' || *end == '\r') { - BEGIN(ST_END_HEREDOC); - } - } - - zend_ptr_stack_push(&SCNG(heredoc_label_stack), (void *) heredoc_label); - - return T_START_HEREDOC; -} - - -<ST_IN_SCRIPTING>[`] { - BEGIN(ST_BACKQUOTE); - return '`'; -} - - -<ST_END_HEREDOC>{ANY_CHAR} { - zend_heredoc_label *heredoc_label = zend_ptr_stack_pop(&SCNG(heredoc_label_stack)); - - YYCURSOR += heredoc_label->length - 1; - yyleng = heredoc_label->length; - - heredoc_label_dtor(heredoc_label); - efree(heredoc_label); - - BEGIN(ST_IN_SCRIPTING); - return T_END_HEREDOC; -} - - -<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" { - zendlval->value.lval = (long) '{'; - yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); - yyless(1); - return T_CURLY_OPEN; -} - - -<ST_DOUBLE_QUOTES>["] { - BEGIN(ST_IN_SCRIPTING); - return '"'; -} - -<ST_BACKQUOTE>[`] { - BEGIN(ST_IN_SCRIPTING); - return '`'; -} - - -<ST_DOUBLE_QUOTES>{ANY_CHAR} { - if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) { - YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1; - SET_DOUBLE_QUOTES_SCANNED_LENGTH(0); - - goto double_quotes_scan_done; - } - - if (YYCURSOR > YYLIMIT) { - return 0; - } - if (yytext[0] == '\\' && YYCURSOR < YYLIMIT) { - YYCURSOR++; - } - - while (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR++) { - case '"': - break; - case '$': - if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { - break; - } - continue; - case '{': - if (*YYCURSOR == '$') { - break; - } - continue; - case '\\': - if (YYCURSOR < YYLIMIT) { - YYCURSOR++; - } - /* fall through */ - default: - continue; - } - - YYCURSOR--; - break; - } - -double_quotes_scan_done: - yyleng = YYCURSOR - SCNG(yy_text); - - zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); - return T_ENCAPSED_AND_WHITESPACE; -} - - -<ST_BACKQUOTE>{ANY_CHAR} { - if (YYCURSOR > YYLIMIT) { - return 0; - } - if (yytext[0] == '\\' && YYCURSOR < YYLIMIT) { - YYCURSOR++; - } - - while (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR++) { - case '`': - break; - case '$': - if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { - break; - } - continue; - case '{': - if (*YYCURSOR == '$') { - break; - } - continue; - case '\\': - if (YYCURSOR < YYLIMIT) { - YYCURSOR++; - } - /* fall through */ - default: - continue; - } - - YYCURSOR--; - break; - } - - yyleng = YYCURSOR - SCNG(yy_text); - - zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); - return T_ENCAPSED_AND_WHITESPACE; -} - - -<ST_HEREDOC>{ANY_CHAR} { - int newline = 0; - - zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); - - if (YYCURSOR > YYLIMIT) { - return 0; - } - - YYCURSOR--; - - while (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR++) { - case '\r': - if (*YYCURSOR == '\n') { - YYCURSOR++; - } - /* fall through */ - case '\n': - /* Check for ending label on the next line */ - if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { - YYCTYPE *end = YYCURSOR + heredoc_label->length; - - if (*end == ';') { - end++; - } - - if (*end == '\n' || *end == '\r') { - /* newline before label will be subtracted from returned text, but - * yyleng/yytext will include it, for zend_highlight/strip, tokenizer, etc. */ - if (YYCURSOR[-2] == '\r' && YYCURSOR[-1] == '\n') { - newline = 2; /* Windows newline */ - } else { - newline = 1; - } - - CG(increment_lineno) = 1; /* For newline before label */ - BEGIN(ST_END_HEREDOC); - - goto heredoc_scan_done; - } - } - continue; - case '$': - if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { - break; - } - continue; - case '{': - if (*YYCURSOR == '$') { - break; - } - continue; - case '\\': - if (YYCURSOR < YYLIMIT && *YYCURSOR != '\n' && *YYCURSOR != '\r') { - YYCURSOR++; - } - /* fall through */ - default: - continue; - } - - YYCURSOR--; - break; - } - -heredoc_scan_done: - yyleng = YYCURSOR - SCNG(yy_text); - - zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); - return T_ENCAPSED_AND_WHITESPACE; -} - - -<ST_NOWDOC>{ANY_CHAR} { - int newline = 0; - - zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); - - if (YYCURSOR > YYLIMIT) { - return 0; - } - - YYCURSOR--; - - while (YYCURSOR < YYLIMIT) { - switch (*YYCURSOR++) { - case '\r': - if (*YYCURSOR == '\n') { - YYCURSOR++; - } - /* fall through */ - case '\n': - /* Check for ending label on the next line */ - if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { - YYCTYPE *end = YYCURSOR + heredoc_label->length; - - if (*end == ';') { - end++; - } - - if (*end == '\n' || *end == '\r') { - /* newline before label will be subtracted from returned text, but - * yyleng/yytext will include it, for zend_highlight/strip, tokenizer, etc. */ - if (YYCURSOR[-2] == '\r' && YYCURSOR[-1] == '\n') { - newline = 2; /* Windows newline */ - } else { - newline = 1; - } - - CG(increment_lineno) = 1; /* For newline before label */ - BEGIN(ST_END_HEREDOC); - - goto nowdoc_scan_done; - } - } - /* fall through */ - default: - continue; - } - } - -nowdoc_scan_done: - yyleng = YYCURSOR - SCNG(yy_text); - - zend_copy_value(zendlval, yytext, yyleng - newline); - zendlval->type = IS_STRING; - HANDLE_NEWLINES(yytext, yyleng - newline); - return T_ENCAPSED_AND_WHITESPACE; -} - - -<ST_IN_SCRIPTING,ST_VAR_OFFSET>{ANY_CHAR} { - if (YYCURSOR > YYLIMIT) { - return 0; - } - - zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); - goto restart; -} - -*/ -} +/* + +----------------------------------------------------------------------+ + | Zend Engine | + +----------------------------------------------------------------------+ + | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.00 of the Zend license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.zend.com/license/2_00.txt. | + | If you did not receive a copy of the Zend license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@zend.com so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Marcus Boerger <helly@php.net> | + | Nuno Lopes <nlopess@php.net> | + | Scott MacVicar <scottmac@php.net> | + | Flex version authors: | + | Andi Gutmans <andi@zend.com> | + | Zeev Suraski <zeev@zend.com> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#if 0 +# define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c) +#else +# define YYDEBUG(s, c) +#endif + +#include "zend_language_scanner_defs.h" + +#include <errno.h> +#include "zend.h" +#ifdef PHP_WIN32 +# include <Winuser.h> +#endif +#include "zend_alloc.h" +#include <zend_language_parser.h> +#include "zend_compile.h" +#include "zend_language_scanner.h" +#include "zend_highlight.h" +#include "zend_constants.h" +#include "zend_variables.h" +#include "zend_operators.h" +#include "zend_API.h" +#include "zend_strtod.h" +#include "zend_exceptions.h" +#include "tsrm_virtual_cwd.h" +#include "tsrm_config_common.h" + +#define YYCTYPE unsigned char +#define YYFILL(n) { if ((YYCURSOR + n) >= (YYLIMIT + ZEND_MMAP_AHEAD)) { return 0; } } +#define YYCURSOR SCNG(yy_cursor) +#define YYLIMIT SCNG(yy_limit) +#define YYMARKER SCNG(yy_marker) + +#define YYGETCONDITION() SCNG(yy_state) +#define YYSETCONDITION(s) SCNG(yy_state) = s + +#define STATE(name) yyc##name + +/* emulate flex constructs */ +#define BEGIN(state) YYSETCONDITION(STATE(state)) +#define YYSTATE YYGETCONDITION() +#define yytext ((char*)SCNG(yy_text)) +#define yyleng SCNG(yy_leng) +#define yyless(x) do { YYCURSOR = (unsigned char*)yytext + x; \ + yyleng = (unsigned int)x; } while(0) +#define yymore() goto yymore_restart + +/* perform sanity check. If this message is triggered you should + increase the ZEND_MMAP_AHEAD value in the zend_streams.h file */ +/*!max:re2c */ +#if ZEND_MMAP_AHEAD < YYMAXFILL +# error ZEND_MMAP_AHEAD should be greater than or equal to YYMAXFILL +#endif + +#ifdef HAVE_STDARG_H +# include <stdarg.h> +#endif + +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +/* Globals Macros */ +#define SCNG LANG_SCNG +#ifdef ZTS +ZEND_API ts_rsrc_id language_scanner_globals_id; +#else +ZEND_API zend_php_scanner_globals language_scanner_globals; +#endif + +#define HANDLE_NEWLINES(s, l) \ +do { \ + char *p = (s), *boundary = p+(l); \ + \ + while (p<boundary) { \ + if (*p == '\n' || (*p == '\r' && (*(p+1) != '\n'))) { \ + CG(zend_lineno)++; \ + } \ + p++; \ + } \ +} while (0) + +#define HANDLE_NEWLINE(c) \ +{ \ + if (c == '\n' || c == '\r') { \ + CG(zend_lineno)++; \ + } \ +} + +/* To save initial string length after scanning to first variable, CG(doc_comment_len) can be reused */ +#define SET_DOUBLE_QUOTES_SCANNED_LENGTH(len) CG(doc_comment_len) = (len) +#define GET_DOUBLE_QUOTES_SCANNED_LENGTH() CG(doc_comment_len) + +#define IS_LABEL_START(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || (c) == '_' || (c) >= 0x7F) + +#define ZEND_IS_OCT(c) ((c)>='0' && (c)<='7') +#define ZEND_IS_HEX(c) (((c)>='0' && (c)<='9') || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F')) + +BEGIN_EXTERN_C() + +static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) +{ + const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); + assert(internal_encoding && zend_multibyte_check_lexer_compatibility(internal_encoding)); + return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding) TSRMLS_CC); +} + +static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) +{ + return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding) TSRMLS_CC); +} + +static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) +{ + return zend_multibyte_encoding_converter(to, to_length, from, from_length, +LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8 TSRMLS_CC); +} + +static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) +{ + const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); + assert(internal_encoding && zend_multibyte_check_lexer_compatibility(internal_encoding)); + return zend_multibyte_encoding_converter(to, to_length, from, from_length, +internal_encoding, zend_multibyte_encoding_utf8 TSRMLS_CC); +} + + +static void _yy_push_state(int new_state TSRMLS_DC) +{ + zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION(), sizeof(int)); + YYSETCONDITION(new_state); +} + +#define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) + +static void yy_pop_state(TSRMLS_D) +{ + int *stack_state; + zend_stack_top(&SCNG(state_stack), (void **) &stack_state); + YYSETCONDITION(*stack_state); + zend_stack_del_top(&SCNG(state_stack)); +} + +static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) +{ + YYCURSOR = (YYCTYPE*)str; + YYLIMIT = YYCURSOR + len; + if (!SCNG(yy_start)) { + SCNG(yy_start) = YYCURSOR; + } +} + +void startup_scanner(TSRMLS_D) +{ + CG(parse_error) = 0; + CG(doc_comment) = NULL; + CG(doc_comment_len) = 0; + zend_stack_init(&SCNG(state_stack)); + zend_ptr_stack_init(&SCNG(heredoc_label_stack)); +} + +static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) { + efree(heredoc_label->label); +} + +void shutdown_scanner(TSRMLS_D) +{ + CG(parse_error) = 0; + RESET_DOC_COMMENT(); + zend_stack_destroy(&SCNG(state_stack)); + zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); + zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); +} + +ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC) +{ + lex_state->yy_leng = SCNG(yy_leng); + lex_state->yy_start = SCNG(yy_start); + lex_state->yy_text = SCNG(yy_text); + lex_state->yy_cursor = SCNG(yy_cursor); + lex_state->yy_marker = SCNG(yy_marker); + lex_state->yy_limit = SCNG(yy_limit); + + lex_state->state_stack = SCNG(state_stack); + zend_stack_init(&SCNG(state_stack)); + + lex_state->heredoc_label_stack = SCNG(heredoc_label_stack); + zend_ptr_stack_init(&SCNG(heredoc_label_stack)); + + lex_state->in = SCNG(yy_in); + lex_state->yy_state = YYSTATE; + lex_state->filename = zend_get_compiled_filename(TSRMLS_C); + lex_state->lineno = CG(zend_lineno); + + lex_state->script_org = SCNG(script_org); + lex_state->script_org_size = SCNG(script_org_size); + lex_state->script_filtered = SCNG(script_filtered); + lex_state->script_filtered_size = SCNG(script_filtered_size); + lex_state->input_filter = SCNG(input_filter); + lex_state->output_filter = SCNG(output_filter); + lex_state->script_encoding = SCNG(script_encoding); +} + +ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC) +{ + SCNG(yy_leng) = lex_state->yy_leng; + SCNG(yy_start) = lex_state->yy_start; + SCNG(yy_text) = lex_state->yy_text; + SCNG(yy_cursor) = lex_state->yy_cursor; + SCNG(yy_marker) = lex_state->yy_marker; + SCNG(yy_limit) = lex_state->yy_limit; + + zend_stack_destroy(&SCNG(state_stack)); + SCNG(state_stack) = lex_state->state_stack; + + zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1); + zend_ptr_stack_destroy(&SCNG(heredoc_label_stack)); + SCNG(heredoc_label_stack) = lex_state->heredoc_label_stack; + + SCNG(yy_in) = lex_state->in; + YYSETCONDITION(lex_state->yy_state); + CG(zend_lineno) = lex_state->lineno; + zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); + + if (SCNG(script_filtered)) { + efree(SCNG(script_filtered)); + SCNG(script_filtered) = NULL; + } + SCNG(script_org) = lex_state->script_org; + SCNG(script_org_size) = lex_state->script_org_size; + SCNG(script_filtered) = lex_state->script_filtered; + SCNG(script_filtered_size) = lex_state->script_filtered_size; + SCNG(input_filter) = lex_state->input_filter; + SCNG(output_filter) = lex_state->output_filter; + SCNG(script_encoding) = lex_state->script_encoding; + + RESET_DOC_COMMENT(); +} + +ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC) +{ + zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles); + /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */ + file_handle->opened_path = NULL; + if (file_handle->free_filename) { + file_handle->filename = NULL; + } +} + +#define BOM_UTF32_BE "\x00\x00\xfe\xff" +#define BOM_UTF32_LE "\xff\xfe\x00\x00" +#define BOM_UTF16_BE "\xfe\xff" +#define BOM_UTF16_LE "\xff\xfe" +#define BOM_UTF8 "\xef\xbb\xbf" + +static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size TSRMLS_DC) +{ + const unsigned char *p; + int wchar_size = 2; + int le = 0; + + /* utf-16 or utf-32? */ + p = script; + while ((p-script) < script_size) { + p = memchr(p, 0, script_size-(p-script)-2); + if (!p) { + break; + } + if (*(p+1) == '\0' && *(p+2) == '\0') { + wchar_size = 4; + break; + } + + /* searching for UTF-32 specific byte orders, so this will do */ + p += 4; + } + + /* BE or LE? */ + p = script; + while ((p-script) < script_size) { + if (*p == '\0' && *(p+wchar_size-1) != '\0') { + /* BE */ + le = 0; + break; + } else if (*p != '\0' && *(p+wchar_size-1) == '\0') { + /* LE* */ + le = 1; + break; + } + p += wchar_size; + } + + if (wchar_size == 2) { + return le ? zend_multibyte_encoding_utf16le : zend_multibyte_encoding_utf16be; + } else { + return le ? zend_multibyte_encoding_utf32le : zend_multibyte_encoding_utf32be; + } + + return NULL; +} + +static const zend_encoding* zend_multibyte_detect_unicode(TSRMLS_D) +{ + const zend_encoding *script_encoding = NULL; + int bom_size; + unsigned char *pos1, *pos2; + + if (LANG_SCNG(script_org_size) < sizeof(BOM_UTF32_LE)-1) { + return NULL; + } + + /* check out BOM */ + if (!memcmp(LANG_SCNG(script_org), BOM_UTF32_BE, sizeof(BOM_UTF32_BE)-1)) { + script_encoding = zend_multibyte_encoding_utf32be; + bom_size = sizeof(BOM_UTF32_BE)-1; + } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF32_LE, sizeof(BOM_UTF32_LE)-1)) { + script_encoding = zend_multibyte_encoding_utf32le; + bom_size = sizeof(BOM_UTF32_LE)-1; + } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF16_BE, sizeof(BOM_UTF16_BE)-1)) { + script_encoding = zend_multibyte_encoding_utf16be; + bom_size = sizeof(BOM_UTF16_BE)-1; + } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF16_LE, sizeof(BOM_UTF16_LE)-1)) { + script_encoding = zend_multibyte_encoding_utf16le; + bom_size = sizeof(BOM_UTF16_LE)-1; + } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF8, sizeof(BOM_UTF8)-1)) { + script_encoding = zend_multibyte_encoding_utf8; + bom_size = sizeof(BOM_UTF8)-1; + } + + if (script_encoding) { + /* remove BOM */ + LANG_SCNG(script_org) += bom_size; + LANG_SCNG(script_org_size) -= bom_size; + + return script_encoding; + } + + /* script contains NULL bytes -> auto-detection */ + if ((pos1 = memchr(LANG_SCNG(script_org), 0, LANG_SCNG(script_org_size)))) { + /* check if the NULL byte is after the __HALT_COMPILER(); */ + pos2 = LANG_SCNG(script_org); + + while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) { + pos2 = memchr(pos2, '_', pos1 - pos2); + if (!pos2) break; + pos2++; + if (strncasecmp((char*)pos2, "_HALT_COMPILER", sizeof("_HALT_COMPILER")-1) == 0) { + pos2 += sizeof("_HALT_COMPILER")-1; + while (*pos2 == ' ' || + *pos2 == '\t' || + *pos2 == '\r' || + *pos2 == '\n') { + pos2++; + } + if (*pos2 == '(') { + pos2++; + while (*pos2 == ' ' || + *pos2 == '\t' || + *pos2 == '\r' || + *pos2 == '\n') { + pos2++; + } + if (*pos2 == ')') { + pos2++; + while (*pos2 == ' ' || + *pos2 == '\t' || + *pos2 == '\r' || + *pos2 == '\n') { + pos2++; + } + if (*pos2 == ';') { + return NULL; + } + } + } + } + } + /* make best effort if BOM is missing */ + return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size) TSRMLS_CC); + } + + return NULL; +} + +static const zend_encoding* zend_multibyte_find_script_encoding(TSRMLS_D) +{ + const zend_encoding *script_encoding; + + if (CG(detect_unicode)) { + /* check out bom(byte order mark) and see if containing wchars */ + script_encoding = zend_multibyte_detect_unicode(TSRMLS_C); + if (script_encoding != NULL) { + /* bom or wchar detection is prior to 'script_encoding' option */ + return script_encoding; + } + } + + /* if no script_encoding specified, just leave alone */ + if (!CG(script_encoding_list) || !CG(script_encoding_list_size)) { + return NULL; + } + + /* if multiple encodings specified, detect automagically */ + if (CG(script_encoding_list_size) > 1) { + return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size) TSRMLS_CC); + } + + return CG(script_encoding_list)[0]; +} + +ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding TSRMLS_DC) +{ + const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); + const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(TSRMLS_C); + + if (!script_encoding) { + return FAILURE; + } + + /* judge input/output filter */ + LANG_SCNG(script_encoding) = script_encoding; + LANG_SCNG(input_filter) = NULL; + LANG_SCNG(output_filter) = NULL; + + if (!internal_encoding || LANG_SCNG(script_encoding) == internal_encoding) { + if (!zend_multibyte_check_lexer_compatibility(LANG_SCNG(script_encoding))) { + /* and if not, work around w/ script_encoding -> utf-8 -> script_encoding conversion */ + LANG_SCNG(input_filter) = encoding_filter_script_to_intermediate; + LANG_SCNG(output_filter) = encoding_filter_intermediate_to_script; + } else { + LANG_SCNG(input_filter) = NULL; + LANG_SCNG(output_filter) = NULL; + } + return SUCCESS; + } + + if (zend_multibyte_check_lexer_compatibility(internal_encoding)) { + LANG_SCNG(input_filter) = encoding_filter_script_to_internal; + LANG_SCNG(output_filter) = NULL; + } else if (zend_multibyte_check_lexer_compatibility(LANG_SCNG(script_encoding))) { + LANG_SCNG(input_filter) = NULL; + LANG_SCNG(output_filter) = encoding_filter_script_to_internal; + } else { + /* both script and internal encodings are incompatible w/ flex */ + LANG_SCNG(input_filter) = encoding_filter_script_to_intermediate; + LANG_SCNG(output_filter) = encoding_filter_intermediate_to_internal; + } + + return 0; +} + +ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC) +{ + const char *file_path = NULL; + char *buf; + size_t size, offset = 0; + + /* The shebang line was read, get the current position to obtain the buffer start */ + if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) { + if ((offset = ftell(file_handle->handle.fp)) == -1) { + offset = 0; + } + } + + if (zend_stream_fixup(file_handle, &buf, &size TSRMLS_CC) == FAILURE) { + return FAILURE; + } + + zend_llist_add_element(&CG(open_files), file_handle); + if (file_handle->handle.stream.handle >= (void*)file_handle && file_handle->handle.stream.handle <= (void*)(file_handle+1)) { + zend_file_handle *fh = (zend_file_handle*)zend_llist_get_last(&CG(open_files)); + size_t diff = (char*)file_handle->handle.stream.handle - (char*)file_handle; + fh->handle.stream.handle = (void*)(((char*)fh) + diff); + file_handle->handle.stream.handle = fh->handle.stream.handle; + } + + /* Reset the scanner for scanning the new file */ + SCNG(yy_in) = file_handle; + SCNG(yy_start) = NULL; + + if (size != -1) { + if (CG(multibyte)) { + SCNG(script_org) = (unsigned char*)buf; + SCNG(script_org_size) = size; + SCNG(script_filtered) = NULL; + + zend_multibyte_set_filter(NULL TSRMLS_CC); + + if (SCNG(input_filter)) { + if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { + zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " + "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); + } + buf = (char*)SCNG(script_filtered); + size = SCNG(script_filtered_size); + } + } + SCNG(yy_start) = (unsigned char *)buf - offset; + yy_scan_buffer(buf, size TSRMLS_CC); + } else { + zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed"); + } + + BEGIN(INITIAL); + + if (file_handle->opened_path) { + file_path = file_handle->opened_path; + } else { + file_path = file_handle->filename; + } + + zend_set_compiled_filename(file_path TSRMLS_CC); + + if (CG(start_lineno)) { + CG(zend_lineno) = CG(start_lineno); + CG(start_lineno) = 0; + } else { + CG(zend_lineno) = 1; + } + + RESET_DOC_COMMENT(); + CG(increment_lineno) = 0; + return SUCCESS; +} +END_EXTERN_C() + + +ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) +{ + zend_lex_state original_lex_state; + zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); + zend_op_array *original_active_op_array = CG(active_op_array); + zend_op_array *retval=NULL; + int compiler_result; + zend_bool compilation_successful=0; + znode retval_znode; + zend_bool original_in_compilation = CG(in_compilation); + + retval_znode.op_type = IS_CONST; + retval_znode.u.constant.type = IS_LONG; + retval_znode.u.constant.value.lval = 1; + Z_UNSET_ISREF(retval_znode.u.constant); + Z_SET_REFCOUNT(retval_znode.u.constant, 1); + + zend_save_lexical_state(&original_lex_state TSRMLS_CC); + + retval = op_array; /* success oriented */ + + if (open_file_for_scanning(file_handle TSRMLS_CC)==FAILURE) { + if (type==ZEND_REQUIRE) { + zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); + zend_bailout(); + } else { + zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); + } + compilation_successful=0; + } else { + init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); + CG(in_compilation) = 1; + CG(active_op_array) = op_array; + zend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context))); + zend_init_compiler_context(TSRMLS_C); + compiler_result = zendparse(TSRMLS_C); + zend_do_return(&retval_znode, 0 TSRMLS_CC); + CG(in_compilation) = original_in_compilation; + if (compiler_result != 0) { /* parser error */ + zend_bailout(); + } + compilation_successful=1; + } + + if (retval) { + CG(active_op_array) = original_active_op_array; + if (compilation_successful) { + pass_two(op_array TSRMLS_CC); + zend_release_labels(0 TSRMLS_CC); + } else { + efree(op_array); + retval = NULL; + } + } + zend_restore_lexical_state(&original_lex_state TSRMLS_CC); + return retval; +} + + +zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC) +{ + zend_file_handle file_handle; + zval tmp; + zend_op_array *retval; + char *opened_path = NULL; + + if (filename->type != IS_STRING) { + tmp = *filename; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + filename = &tmp; + } + file_handle.filename = filename->value.str.val; + file_handle.free_filename = 0; + file_handle.type = ZEND_HANDLE_FILENAME; + file_handle.opened_path = NULL; + file_handle.handle.fp = NULL; + + retval = zend_compile_file(&file_handle, type TSRMLS_CC); + if (retval && file_handle.handle.stream.handle) { + int dummy = 1; + + if (!file_handle.opened_path) { + file_handle.opened_path = opened_path = estrndup(filename->value.str.val, filename->value.str.len); + } + + zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL); + + if (opened_path) { + efree(opened_path); + } + } + zend_destroy_file_handle(&file_handle TSRMLS_CC); + + if (filename==&tmp) { + zval_dtor(&tmp); + } + return retval; +} + +ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) +{ + char *buf; + size_t size; + + /* enforce two trailing NULLs for flex... */ + if (IS_INTERNED(str->value.str.val)) { + char *tmp = safe_emalloc(1, str->value.str.len, ZEND_MMAP_AHEAD); + memcpy(tmp, str->value.str.val, str->value.str.len + ZEND_MMAP_AHEAD); + str->value.str.val = tmp; + } else { + str->value.str.val = safe_erealloc(str->value.str.val, 1, str->value.str.len, ZEND_MMAP_AHEAD); + } + + memset(str->value.str.val + str->value.str.len, 0, ZEND_MMAP_AHEAD); + + SCNG(yy_in) = NULL; + SCNG(yy_start) = NULL; + + buf = str->value.str.val; + size = str->value.str.len; + + if (CG(multibyte)) { + SCNG(script_org) = (unsigned char*)buf; + SCNG(script_org_size) = size; + SCNG(script_filtered) = NULL; + + zend_multibyte_set_filter(zend_multibyte_get_internal_encoding(TSRMLS_C) TSRMLS_CC); + + if (SCNG(input_filter)) { + if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { + zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " + "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); + } + buf = (char*)SCNG(script_filtered); + size = SCNG(script_filtered_size); + } + } + + yy_scan_buffer(buf, size TSRMLS_CC); + + zend_set_compiled_filename(filename TSRMLS_CC); + CG(zend_lineno) = 1; + CG(increment_lineno) = 0; + RESET_DOC_COMMENT(); + return SUCCESS; +} + + +ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D) +{ + size_t offset = SCNG(yy_cursor) - SCNG(yy_start); + if (SCNG(input_filter)) { + size_t original_offset = offset, length = 0; + do { + unsigned char *p = NULL; + if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC)) { + return (size_t)-1; + } + efree(p); + if (length > original_offset) { + offset--; + } else if (length < original_offset) { + offset++; + } + } while (original_offset != length); + } + return offset; +} + + +zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC) +{ + zend_lex_state original_lex_state; + zend_op_array *op_array = (zend_op_array *) emalloc(sizeof(zend_op_array)); + zend_op_array *original_active_op_array = CG(active_op_array); + zend_op_array *retval; + zval tmp; + int compiler_result; + zend_bool original_in_compilation = CG(in_compilation); + + if (source_string->value.str.len==0) { + efree(op_array); + return NULL; + } + + CG(in_compilation) = 1; + + tmp = *source_string; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + source_string = &tmp; + + zend_save_lexical_state(&original_lex_state TSRMLS_CC); + if (zend_prepare_string_for_scanning(source_string, filename TSRMLS_CC)==FAILURE) { + efree(op_array); + retval = NULL; + } else { + zend_bool orig_interactive = CG(interactive); + + CG(interactive) = 0; + init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); + CG(interactive) = orig_interactive; + CG(active_op_array) = op_array; + zend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context))); + zend_init_compiler_context(TSRMLS_C); + BEGIN(ST_IN_SCRIPTING); + compiler_result = zendparse(TSRMLS_C); + + if (SCNG(script_filtered)) { + efree(SCNG(script_filtered)); + SCNG(script_filtered) = NULL; + } + + if (compiler_result != 0) { + CG(active_op_array) = original_active_op_array; + CG(unclean_shutdown)=1; + destroy_op_array(op_array TSRMLS_CC); + efree(op_array); + retval = NULL; + } else { + zend_do_return(NULL, 0 TSRMLS_CC); + CG(active_op_array) = original_active_op_array; + pass_two(op_array TSRMLS_CC); + zend_release_labels(0 TSRMLS_CC); + retval = op_array; + } + } + zend_restore_lexical_state(&original_lex_state TSRMLS_CC); + zval_dtor(&tmp); + CG(in_compilation) = original_in_compilation; + return retval; +} + + +BEGIN_EXTERN_C() +int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) +{ + zend_lex_state original_lex_state; + zend_file_handle file_handle; + + file_handle.type = ZEND_HANDLE_FILENAME; + file_handle.filename = filename; + file_handle.free_filename = 0; + file_handle.opened_path = NULL; + zend_save_lexical_state(&original_lex_state TSRMLS_CC); + if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) { + zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename TSRMLS_CC); + zend_restore_lexical_state(&original_lex_state TSRMLS_CC); + return FAILURE; + } + zend_highlight(syntax_highlighter_ini TSRMLS_CC); + if (SCNG(script_filtered)) { + efree(SCNG(script_filtered)); + SCNG(script_filtered) = NULL; + } + zend_destroy_file_handle(&file_handle TSRMLS_CC); + zend_restore_lexical_state(&original_lex_state TSRMLS_CC); + return SUCCESS; +} + +int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC) +{ + zend_lex_state original_lex_state; + zval tmp = *str; + + str = &tmp; + zval_copy_ctor(str); + zend_save_lexical_state(&original_lex_state TSRMLS_CC); + if (zend_prepare_string_for_scanning(str, str_name TSRMLS_CC)==FAILURE) { + zend_restore_lexical_state(&original_lex_state TSRMLS_CC); + return FAILURE; + } + BEGIN(INITIAL); + zend_highlight(syntax_highlighter_ini TSRMLS_CC); + if (SCNG(script_filtered)) { + efree(SCNG(script_filtered)); + SCNG(script_filtered) = NULL; + } + zend_restore_lexical_state(&original_lex_state TSRMLS_CC); + zval_dtor(str); + return SUCCESS; +} + +ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding TSRMLS_DC) +{ + size_t length; + unsigned char *new_yy_start; + + /* convert and set */ + if (!SCNG(input_filter)) { + if (SCNG(script_filtered)) { + efree(SCNG(script_filtered)); + SCNG(script_filtered) = NULL; + } + SCNG(script_filtered_size) = 0; + length = SCNG(script_org_size); + new_yy_start = SCNG(script_org); + } else { + if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size) TSRMLS_CC)) { + zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected " + "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding))); + } + SCNG(script_filtered) = new_yy_start; + SCNG(script_filtered_size) = length; + } + + SCNG(yy_cursor) = new_yy_start + (SCNG(yy_cursor) - SCNG(yy_start)); + SCNG(yy_marker) = new_yy_start + (SCNG(yy_marker) - SCNG(yy_start)); + SCNG(yy_text) = new_yy_start + (SCNG(yy_text) - SCNG(yy_start)); + SCNG(yy_limit) = new_yy_start + (SCNG(yy_limit) - SCNG(yy_start)); + + SCNG(yy_start) = new_yy_start; +} + + +# define zend_copy_value(zendlval, yytext, yyleng) \ + if (SCNG(output_filter)) { \ + size_t sz = 0; \ + SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); \ + zendlval->value.str.len = sz; \ + } else { \ + zendlval->value.str.val = (char *) estrndup(yytext, yyleng); \ + zendlval->value.str.len = yyleng; \ + } + +static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC) +{ + register char *s, *t; + char *end; + + ZVAL_STRINGL(zendlval, str, len, 1); + + /* convert escape sequences */ + s = t = zendlval->value.str.val; + end = s+zendlval->value.str.len; + while (s<end) { + if (*s=='\\') { + s++; + if (s >= end) { + *t++ = '\\'; + break; + } + + switch(*s) { + case 'n': + *t++ = '\n'; + zendlval->value.str.len--; + break; + case 'r': + *t++ = '\r'; + zendlval->value.str.len--; + break; + case 't': + *t++ = '\t'; + zendlval->value.str.len--; + break; + case 'f': + *t++ = '\f'; + zendlval->value.str.len--; + break; + case 'v': + *t++ = '\v'; + zendlval->value.str.len--; + break; + case 'e': +#ifdef PHP_WIN32 + *t++ = VK_ESCAPE; +#else + *t++ = '\e'; +#endif + zendlval->value.str.len--; + break; + case '"': + case '`': + if (*s != quote_type) { + *t++ = '\\'; + *t++ = *s; + break; + } + case '\\': + case '$': + *t++ = *s; + zendlval->value.str.len--; + break; + case 'x': + case 'X': + if (ZEND_IS_HEX(*(s+1))) { + char hex_buf[3] = { 0, 0, 0 }; + + zendlval->value.str.len--; /* for the 'x' */ + + hex_buf[0] = *(++s); + zendlval->value.str.len--; + if (ZEND_IS_HEX(*(s+1))) { + hex_buf[1] = *(++s); + zendlval->value.str.len--; + } + *t++ = (char) ZEND_STRTOL(hex_buf, NULL, 16); + } else { + *t++ = '\\'; + *t++ = *s; + } + break; + default: + /* check for an octal */ + if (ZEND_IS_OCT(*s)) { + char octal_buf[4] = { 0, 0, 0, 0 }; + + octal_buf[0] = *s; + zendlval->value.str.len--; + if (ZEND_IS_OCT(*(s+1))) { + octal_buf[1] = *(++s); + zendlval->value.str.len--; + if (ZEND_IS_OCT(*(s+1))) { + octal_buf[2] = *(++s); + zendlval->value.str.len--; + } + } + *t++ = (char) ZEND_STRTOL(octal_buf, NULL, 8); + } else { + *t++ = '\\'; + *t++ = *s; + } + break; + } + } else { + *t++ = *s; + } + + if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { + CG(zend_lineno)++; + } + s++; + } + *t = 0; + if (SCNG(output_filter)) { + size_t sz = 0; + s = zendlval->value.str.val; + SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)s, (size_t)zendlval->value.str.len TSRMLS_CC); + zendlval->value.str.len = sz; + efree(s); + } +} + + +int lex_scan(zval *zendlval TSRMLS_DC) +{ +restart: + SCNG(yy_text) = YYCURSOR; + +yymore_restart: + +/*!re2c +re2c:yyfill:check = 0; +LNUM [0-9]+ +DNUM ([0-9]*"."[0-9]+)|([0-9]+"."[0-9]*) +EXPONENT_DNUM (({LNUM}|{DNUM})[eE][+-]?{LNUM}) +HNUM "0x"[0-9a-fA-F]+ +BNUM "0b"[01]+ +LABEL [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* +WHITESPACE [ \n\r\t]+ +TABS_AND_SPACES [ \t]* +TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@] +ANY_CHAR [^] +NEWLINE ("\r"|"\n"|"\r\n") + +/* compute yyleng before each rule */ +<!*> := yyleng = YYCURSOR - SCNG(yy_text); + + +<ST_IN_SCRIPTING>"exit" { + return T_EXIT; +} + +<ST_IN_SCRIPTING>"die" { + return T_EXIT; +} + +<ST_IN_SCRIPTING>"function" { + return T_FUNCTION; +} + +<ST_IN_SCRIPTING>"const" { + return T_CONST; +} + +<ST_IN_SCRIPTING>"return" { + return T_RETURN; +} + +<ST_IN_SCRIPTING>"yield" { + return T_YIELD; +} + +<ST_IN_SCRIPTING>"try" { + return T_TRY; +} + +<ST_IN_SCRIPTING>"catch" { + return T_CATCH; +} + +<ST_IN_SCRIPTING>"finally" { + return T_FINALLY; +} + +<ST_IN_SCRIPTING>"throw" { + return T_THROW; +} + +<ST_IN_SCRIPTING>"if" { + return T_IF; +} + +<ST_IN_SCRIPTING>"elseif" { + return T_ELSEIF; +} + +<ST_IN_SCRIPTING>"endif" { + return T_ENDIF; +} + +<ST_IN_SCRIPTING>"else" { + return T_ELSE; +} + +<ST_IN_SCRIPTING>"while" { + return T_WHILE; +} + +<ST_IN_SCRIPTING>"endwhile" { + return T_ENDWHILE; +} + +<ST_IN_SCRIPTING>"do" { + return T_DO; +} + +<ST_IN_SCRIPTING>"for" { + return T_FOR; +} + +<ST_IN_SCRIPTING>"endfor" { + return T_ENDFOR; +} + +<ST_IN_SCRIPTING>"foreach" { + return T_FOREACH; +} + +<ST_IN_SCRIPTING>"endforeach" { + return T_ENDFOREACH; +} + +<ST_IN_SCRIPTING>"declare" { + return T_DECLARE; +} + +<ST_IN_SCRIPTING>"enddeclare" { + return T_ENDDECLARE; +} + +<ST_IN_SCRIPTING>"instanceof" { + return T_INSTANCEOF; +} + +<ST_IN_SCRIPTING>"as" { + return T_AS; +} + +<ST_IN_SCRIPTING>"switch" { + return T_SWITCH; +} + +<ST_IN_SCRIPTING>"endswitch" { + return T_ENDSWITCH; +} + +<ST_IN_SCRIPTING>"case" { + return T_CASE; +} + +<ST_IN_SCRIPTING>"default" { + return T_DEFAULT; +} + +<ST_IN_SCRIPTING>"break" { + return T_BREAK; +} + +<ST_IN_SCRIPTING>"continue" { + return T_CONTINUE; +} + +<ST_IN_SCRIPTING>"goto" { + return T_GOTO; +} + +<ST_IN_SCRIPTING>"echo" { + return T_ECHO; +} + +<ST_IN_SCRIPTING>"print" { + return T_PRINT; +} + +<ST_IN_SCRIPTING>"class" { + return T_CLASS; +} + +<ST_IN_SCRIPTING>"interface" { + return T_INTERFACE; +} + +<ST_IN_SCRIPTING>"trait" { + return T_TRAIT; +} + +<ST_IN_SCRIPTING>"extends" { + return T_EXTENDS; +} + +<ST_IN_SCRIPTING>"implements" { + return T_IMPLEMENTS; +} + +<ST_IN_SCRIPTING>"->" { + yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); + return T_OBJECT_OPERATOR; +} + +<ST_IN_SCRIPTING,ST_LOOKING_FOR_PROPERTY>{WHITESPACE}+ { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + HANDLE_NEWLINES(yytext, yyleng); + return T_WHITESPACE; +} + +<ST_LOOKING_FOR_PROPERTY>"->" { + return T_OBJECT_OPERATOR; +} + +<ST_LOOKING_FOR_PROPERTY>{LABEL} { + yy_pop_state(TSRMLS_C); + zend_copy_value(zendlval, yytext, yyleng); + zendlval->type = IS_STRING; + return T_STRING; +} + +<ST_LOOKING_FOR_PROPERTY>{ANY_CHAR} { + yyless(0); + yy_pop_state(TSRMLS_C); + goto restart; +} + +<ST_IN_SCRIPTING>"::" { + return T_PAAMAYIM_NEKUDOTAYIM; +} + +<ST_IN_SCRIPTING>"\\" { + return T_NS_SEPARATOR; +} + +<ST_IN_SCRIPTING>"new" { + return T_NEW; +} + +<ST_IN_SCRIPTING>"clone" { + return T_CLONE; +} + +<ST_IN_SCRIPTING>"var" { + return T_VAR; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("int"|"integer"){TABS_AND_SPACES}")" { + return T_INT_CAST; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("real"|"double"|"float"){TABS_AND_SPACES}")" { + return T_DOUBLE_CAST; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("string"|"binary"){TABS_AND_SPACES}")" { + return T_STRING_CAST; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"array"{TABS_AND_SPACES}")" { + return T_ARRAY_CAST; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"object"{TABS_AND_SPACES}")" { + return T_OBJECT_CAST; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" { + return T_BOOL_CAST; +} + +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("unset"){TABS_AND_SPACES}")" { + return T_UNSET_CAST; +} + +<ST_IN_SCRIPTING>"eval" { + return T_EVAL; +} + +<ST_IN_SCRIPTING>"include" { + return T_INCLUDE; +} + +<ST_IN_SCRIPTING>"include_once" { + return T_INCLUDE_ONCE; +} + +<ST_IN_SCRIPTING>"require" { + return T_REQUIRE; +} + +<ST_IN_SCRIPTING>"require_once" { + return T_REQUIRE_ONCE; +} + +<ST_IN_SCRIPTING>"namespace" { + return T_NAMESPACE; +} + +<ST_IN_SCRIPTING>"use" { + return T_USE; +} + +<ST_IN_SCRIPTING>"insteadof" { + return T_INSTEADOF; +} + +<ST_IN_SCRIPTING>"global" { + return T_GLOBAL; +} + +<ST_IN_SCRIPTING>"isset" { + return T_ISSET; +} + +<ST_IN_SCRIPTING>"empty" { + return T_EMPTY; +} + +<ST_IN_SCRIPTING>"__halt_compiler" { + return T_HALT_COMPILER; +} + +<ST_IN_SCRIPTING>"static" { + return T_STATIC; +} + +<ST_IN_SCRIPTING>"abstract" { + return T_ABSTRACT; +} + +<ST_IN_SCRIPTING>"final" { + return T_FINAL; +} + +<ST_IN_SCRIPTING>"private" { + return T_PRIVATE; +} + +<ST_IN_SCRIPTING>"protected" { + return T_PROTECTED; +} + +<ST_IN_SCRIPTING>"public" { + return T_PUBLIC; +} + +<ST_IN_SCRIPTING>"unset" { + return T_UNSET; +} + +<ST_IN_SCRIPTING>"=>" { + return T_DOUBLE_ARROW; +} + +<ST_IN_SCRIPTING>"list" { + return T_LIST; +} + +<ST_IN_SCRIPTING>"array" { + return T_ARRAY; +} + +<ST_IN_SCRIPTING>"callable" { + return T_CALLABLE; +} + +<ST_IN_SCRIPTING>"++" { + return T_INC; +} + +<ST_IN_SCRIPTING>"--" { + return T_DEC; +} + +<ST_IN_SCRIPTING>"===" { + return T_IS_IDENTICAL; +} + +<ST_IN_SCRIPTING>"!==" { + return T_IS_NOT_IDENTICAL; +} + +<ST_IN_SCRIPTING>"==" { + return T_IS_EQUAL; +} + +<ST_IN_SCRIPTING>"!="|"<>" { + return T_IS_NOT_EQUAL; +} + +<ST_IN_SCRIPTING>"<=" { + return T_IS_SMALLER_OR_EQUAL; +} + +<ST_IN_SCRIPTING>">=" { + return T_IS_GREATER_OR_EQUAL; +} + +<ST_IN_SCRIPTING>"+=" { + return T_PLUS_EQUAL; +} + +<ST_IN_SCRIPTING>"-=" { + return T_MINUS_EQUAL; +} + +<ST_IN_SCRIPTING>"*=" { + return T_MUL_EQUAL; +} + +<ST_IN_SCRIPTING>"/=" { + return T_DIV_EQUAL; +} + +<ST_IN_SCRIPTING>".=" { + return T_CONCAT_EQUAL; +} + +<ST_IN_SCRIPTING>"%=" { + return T_MOD_EQUAL; +} + +<ST_IN_SCRIPTING>"<<=" { + return T_SL_EQUAL; +} + +<ST_IN_SCRIPTING>">>=" { + return T_SR_EQUAL; +} + +<ST_IN_SCRIPTING>"&=" { + return T_AND_EQUAL; +} + +<ST_IN_SCRIPTING>"|=" { + return T_OR_EQUAL; +} + +<ST_IN_SCRIPTING>"^=" { + return T_XOR_EQUAL; +} + +<ST_IN_SCRIPTING>"||" { + return T_BOOLEAN_OR; +} + +<ST_IN_SCRIPTING>"&&" { + return T_BOOLEAN_AND; +} + +<ST_IN_SCRIPTING>"OR" { + return T_LOGICAL_OR; +} + +<ST_IN_SCRIPTING>"AND" { + return T_LOGICAL_AND; +} + +<ST_IN_SCRIPTING>"XOR" { + return T_LOGICAL_XOR; +} + +<ST_IN_SCRIPTING>"<<" { + return T_SL; +} + +<ST_IN_SCRIPTING>">>" { + return T_SR; +} + +<ST_IN_SCRIPTING>{TOKENS} { + return yytext[0]; +} + + +<ST_IN_SCRIPTING>"{" { + yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); + return '{'; +} + + +<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"${" { + yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC); + return T_DOLLAR_OPEN_CURLY_BRACES; +} + + +<ST_IN_SCRIPTING>"}" { + RESET_DOC_COMMENT(); + if (!zend_stack_is_empty(&SCNG(state_stack))) { + yy_pop_state(TSRMLS_C); + } + return '}'; +} + + +<ST_LOOKING_FOR_VARNAME>{LABEL}[[}] { + yyless(yyleng - 1); + zend_copy_value(zendlval, yytext, yyleng); + zendlval->type = IS_STRING; + yy_pop_state(TSRMLS_C); + yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); + return T_STRING_VARNAME; +} + + +<ST_LOOKING_FOR_VARNAME>{ANY_CHAR} { + yyless(0); + yy_pop_state(TSRMLS_C); + yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); + goto restart; +} + +<ST_IN_SCRIPTING>{BNUM} { + char *bin = yytext + 2; /* Skip "0b" */ + int len = yyleng - 2; + + /* Skip any leading 0s */ + while (*bin == '0') { + ++bin; + --len; + } + + if (len < SIZEOF_LONG * 8) { + if (len == 0) { + zendlval->value.lval = 0; + } else { + zendlval->value.lval = ZEND_STRTOL(bin, NULL, 2); + } + zendlval->type = IS_LONG; + return T_LNUMBER; + } else { + zendlval->value.dval = zend_bin_strtod(bin, NULL); + zendlval->type = IS_DOUBLE; + return T_DNUMBER; + } +} + +<ST_IN_SCRIPTING>{LNUM} { + if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */ + zendlval->value.lval = ZEND_STRTOL(yytext, NULL, 0); + } else { + errno = 0; + zendlval->value.lval = ZEND_STRTOL(yytext, NULL, 0); + if (errno == ERANGE) { /* Overflow */ + if (yytext[0] == '0') { /* octal overflow */ + zendlval->value.dval = zend_oct_strtod(yytext, NULL); + } else { + zendlval->value.dval = zend_strtod(yytext, NULL); + } + zendlval->type = IS_DOUBLE; + return T_DNUMBER; + } + } + + zendlval->type = IS_LONG; + return T_LNUMBER; +} + +<ST_IN_SCRIPTING>{HNUM} { + char *hex = yytext + 2; /* Skip "0x" */ + int len = yyleng - 2; + + /* Skip any leading 0s */ + while (*hex == '0') { + hex++; + len--; + } + + if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) { + if (len == 0) { + zendlval->value.lval = 0; + } else { + zendlval->value.lval = ZEND_STRTOL(hex, NULL, 16); + } + zendlval->type = IS_LONG; + return T_LNUMBER; + } else { + zendlval->value.dval = zend_hex_strtod(hex, NULL); + zendlval->type = IS_DOUBLE; + return T_DNUMBER; + } +} + +<ST_VAR_OFFSET>[0]|([1-9][0-9]*) { /* Offset could be treated as a long */ + if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) { + zendlval->value.lval = ZEND_STRTOL(yytext, NULL, 10); + zendlval->type = IS_LONG; + } else { + zendlval->value.str.val = (char *)estrndup(yytext, yyleng); + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + } + return T_NUM_STRING; +} + +<ST_VAR_OFFSET>{LNUM}|{HNUM}|{BNUM} { /* Offset must be treated as a string */ + zendlval->value.str.val = (char *)estrndup(yytext, yyleng); + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + return T_NUM_STRING; +} + +<ST_IN_SCRIPTING>{DNUM}|{EXPONENT_DNUM} { + zendlval->value.dval = zend_strtod(yytext, NULL); + zendlval->type = IS_DOUBLE; + return T_DNUMBER; +} + +<ST_IN_SCRIPTING>"__CLASS__" { + const char *class_name = NULL; + + if (CG(active_class_entry) + && (ZEND_ACC_TRAIT == + (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT))) { + /* We create a special __CLASS__ constant that is going to be resolved + at run-time */ + zendlval->value.str.len = sizeof("__CLASS__")-1; + zendlval->value.str.val = estrndup("__CLASS__", zendlval->value.str.len); + zendlval->type = IS_CONSTANT; + } else { + if (CG(active_class_entry)) { + class_name = CG(active_class_entry)->name; + } + + if (!class_name) { + class_name = ""; + } + + zendlval->value.str.len = strlen(class_name); + zendlval->value.str.val = estrndup(class_name, zendlval->value.str.len); + zendlval->type = IS_STRING; + } + return T_CLASS_C; +} + +<ST_IN_SCRIPTING>"__TRAIT__" { + const char *trait_name = NULL; + + if (CG(active_class_entry) + && (ZEND_ACC_TRAIT == + (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT))) { + trait_name = CG(active_class_entry)->name; + } + + if (!trait_name) { + trait_name = ""; + } + + zendlval->value.str.len = strlen(trait_name); + zendlval->value.str.val = estrndup(trait_name, zendlval->value.str.len); + zendlval->type = IS_STRING; + + return T_TRAIT_C; +} + +<ST_IN_SCRIPTING>"__FUNCTION__" { + const char *func_name = NULL; + + if (CG(active_op_array)) { + func_name = CG(active_op_array)->function_name; + } + + if (!func_name) { + func_name = ""; + } + zendlval->value.str.len = strlen(func_name); + zendlval->value.str.val = estrndup(func_name, zendlval->value.str.len); + zendlval->type = IS_STRING; + return T_FUNC_C; +} + +<ST_IN_SCRIPTING>"__METHOD__" { + const char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL; + const char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL; + size_t len = 0; + + if (class_name) { + len += strlen(class_name) + 2; + } + if (func_name) { + len += strlen(func_name); + } + + zendlval->value.str.len = zend_spprintf(&zendlval->value.str.val, 0, "%s%s%s", + class_name ? class_name : "", + class_name && func_name ? "::" : "", + func_name ? func_name : "" + ); + zendlval->type = IS_STRING; + return T_METHOD_C; +} + +<ST_IN_SCRIPTING>"__LINE__" { + zendlval->value.lval = CG(zend_lineno); + zendlval->type = IS_LONG; + return T_LINE; +} + +<ST_IN_SCRIPTING>"__FILE__" { + char *filename = zend_get_compiled_filename(TSRMLS_C); + + if (!filename) { + filename = ""; + } + zendlval->value.str.len = strlen(filename); + zendlval->value.str.val = estrndup(filename, zendlval->value.str.len); + zendlval->type = IS_STRING; + return T_FILE; +} + +<ST_IN_SCRIPTING>"__DIR__" { + char *filename = zend_get_compiled_filename(TSRMLS_C); + const size_t filename_len = strlen(filename); + char *dirname; + + if (!filename) { + filename = ""; + } + + dirname = estrndup(filename, filename_len); + zend_dirname(dirname, filename_len); + + if (strcmp(dirname, ".") == 0) { + dirname = erealloc(dirname, MAXPATHLEN); +#if HAVE_GETCWD + VCWD_GETCWD(dirname, MAXPATHLEN); +#elif HAVE_GETWD + VCWD_GETWD(dirname); +#endif + } + + zendlval->value.str.len = strlen(dirname); + zendlval->value.str.val = dirname; + zendlval->type = IS_STRING; + return T_DIR; +} + +<ST_IN_SCRIPTING>"__NAMESPACE__" { + if (CG(current_namespace)) { + *zendlval = *CG(current_namespace); + zval_copy_ctor(zendlval); + } else { + ZVAL_EMPTY_STRING(zendlval); + } + return T_NS_C; +} + +<INITIAL>"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"'php'"){WHITESPACE}*">" { + YYCTYPE *bracket = (YYCTYPE*)zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1)); + + if (bracket != SCNG(yy_text)) { + /* Handle previously scanned HTML, as possible <script> tags found are assumed to not be PHP's */ + YYCURSOR = bracket; + goto inline_html; + } + + HANDLE_NEWLINES(yytext, yyleng); + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG; +} + + +<INITIAL>"<%=" { + if (CG(asp_tags)) { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG_WITH_ECHO; + } else { + goto inline_char_handler; + } +} + + +<INITIAL>"<?=" { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG_WITH_ECHO; +} + + +<INITIAL>"<%" { + if (CG(asp_tags)) { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG; + } else { + goto inline_char_handler; + } +} + + +<INITIAL>"<?php"([ \t]|{NEWLINE}) { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + HANDLE_NEWLINE(yytext[yyleng-1]); + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG; +} + + +<INITIAL>"<?" { + if (CG(short_tags)) { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(ST_IN_SCRIPTING); + return T_OPEN_TAG; + } else { + goto inline_char_handler; + } +} + +<INITIAL>{ANY_CHAR} { + if (YYCURSOR > YYLIMIT) { + return 0; + } + +inline_char_handler: + + while (1) { + YYCTYPE *ptr = memchr(YYCURSOR, '<', YYLIMIT - YYCURSOR); + + YYCURSOR = ptr ? ptr + 1 : YYLIMIT; + + if (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR) { + case '?': + if (CG(short_tags) || !strncasecmp((char*)YYCURSOR + 1, "php", 3) || (*(YYCURSOR + 1) == '=')) { /* Assume [ \t\n\r] follows "php" */ + break; + } + continue; + case '%': + if (CG(asp_tags)) { + break; + } + continue; + case 's': + case 'S': + /* Probably NOT an opening PHP <script> tag, so don't end the HTML chunk yet + * If it is, the PHP <script> tag rule checks for any HTML scanned before it */ + YYCURSOR--; + yymore(); + default: + continue; + } + + YYCURSOR--; + } + + break; + } + +inline_html: + yyleng = YYCURSOR - SCNG(yy_text); + + if (SCNG(output_filter)) { + int readsize; + size_t sz = 0; + readsize = SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC); + zendlval->value.str.len = sz; + if (readsize < yyleng) { + yyless(readsize); + } + } else { + zendlval->value.str.val = (char *) estrndup(yytext, yyleng); + zendlval->value.str.len = yyleng; + } + zendlval->type = IS_STRING; + HANDLE_NEWLINES(yytext, yyleng); + return T_INLINE_HTML; +} + + +/* Make sure a label character follows "->", otherwise there is no property + * and "->" will be taken literally + */ +<ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"->"[a-zA-Z_\x7f-\xff] { + yyless(yyleng - 3); + yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC); + zend_copy_value(zendlval, (yytext+1), (yyleng-1)); + zendlval->type = IS_STRING; + return T_VARIABLE; +} + +/* A [ always designates a variable offset, regardless of what follows + */ +<ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE>"$"{LABEL}"[" { + yyless(yyleng - 1); + yy_push_state(ST_VAR_OFFSET TSRMLS_CC); + zend_copy_value(zendlval, (yytext+1), (yyleng-1)); + zendlval->type = IS_STRING; + return T_VARIABLE; +} + +<ST_IN_SCRIPTING,ST_DOUBLE_QUOTES,ST_HEREDOC,ST_BACKQUOTE,ST_VAR_OFFSET>"$"{LABEL} { + zend_copy_value(zendlval, (yytext+1), (yyleng-1)); + zendlval->type = IS_STRING; + return T_VARIABLE; +} + +<ST_VAR_OFFSET>"]" { + yy_pop_state(TSRMLS_C); + return ']'; +} + +<ST_VAR_OFFSET>{TOKENS}|[{}"`] { + /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */ + return yytext[0]; +} + +<ST_VAR_OFFSET>[ \n\r\t\\'#] { + /* Invalid rule to return a more explicit parse error with proper line number */ + yyless(0); + yy_pop_state(TSRMLS_C); + return T_ENCAPSED_AND_WHITESPACE; +} + +<ST_IN_SCRIPTING,ST_VAR_OFFSET>{LABEL} { + zend_copy_value(zendlval, yytext, yyleng); + zendlval->type = IS_STRING; + return T_STRING; +} + + +<ST_IN_SCRIPTING>"#"|"//" { + while (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR++) { + case '\r': + if (*YYCURSOR == '\n') { + YYCURSOR++; + } + /* fall through */ + case '\n': + CG(zend_lineno)++; + break; + case '%': + if (!CG(asp_tags)) { + continue; + } + /* fall through */ + case '?': + if (*YYCURSOR == '>') { + YYCURSOR--; + break; + } + /* fall through */ + default: + continue; + } + + break; + } + + yyleng = YYCURSOR - SCNG(yy_text); + + return T_COMMENT; +} + +<ST_IN_SCRIPTING>"/*"|"/**"{WHITESPACE} { + int doc_com; + + if (yyleng > 2) { + doc_com = 1; + RESET_DOC_COMMENT(); + } else { + doc_com = 0; + } + + while (YYCURSOR < YYLIMIT) { + if (*YYCURSOR++ == '*' && *YYCURSOR == '/') { + break; + } + } + + if (YYCURSOR < YYLIMIT) { + YYCURSOR++; + } else { + zend_error(E_COMPILE_WARNING, "Unterminated comment starting line %d", CG(zend_lineno)); + } + + yyleng = YYCURSOR - SCNG(yy_text); + HANDLE_NEWLINES(yytext, yyleng); + + if (doc_com) { + CG(doc_comment) = estrndup(yytext, yyleng); + CG(doc_comment_len) = yyleng; + return T_DOC_COMMENT; + } + + return T_COMMENT; +} + +<ST_IN_SCRIPTING>("?>"|"</script"{WHITESPACE}*">"){NEWLINE}? { + zendlval->value.str.val = yytext; /* no copying - intentional */ + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + BEGIN(INITIAL); + return T_CLOSE_TAG; /* implicit ';' at php-end tag */ +} + + +<ST_IN_SCRIPTING>"%>"{NEWLINE}? { + if (CG(asp_tags)) { + BEGIN(INITIAL); + zendlval->value.str.len = yyleng; + zendlval->type = IS_STRING; + zendlval->value.str.val = yytext; /* no copying - intentional */ + return T_CLOSE_TAG; /* implicit ';' at php-end tag */ + } else { + yyless(1); + return yytext[0]; + } +} + + +<ST_IN_SCRIPTING>b?['] { + register char *s, *t; + char *end; + int bprefix = (yytext[0] != '\'') ? 1 : 0; + + while (1) { + if (YYCURSOR < YYLIMIT) { + if (*YYCURSOR == '\'') { + YYCURSOR++; + yyleng = YYCURSOR - SCNG(yy_text); + + break; + } else if (*YYCURSOR++ == '\\' && YYCURSOR < YYLIMIT) { + YYCURSOR++; + } + } else { + yyleng = YYLIMIT - SCNG(yy_text); + + /* Unclosed single quotes; treat similar to double quotes, but without a separate token + * for ' (unrecognized by parser), instead of old flex fallback to "Unexpected character..." + * rule, which continued in ST_IN_SCRIPTING state after the quote */ + return T_ENCAPSED_AND_WHITESPACE; + } + } + + zendlval->value.str.val = estrndup(yytext+bprefix+1, yyleng-bprefix-2); + zendlval->value.str.len = yyleng-bprefix-2; + zendlval->type = IS_STRING; + + /* convert escape sequences */ + s = t = zendlval->value.str.val; + end = s+zendlval->value.str.len; + while (s<end) { + if (*s=='\\') { + s++; + + switch(*s) { + case '\\': + case '\'': + *t++ = *s; + zendlval->value.str.len--; + break; + default: + *t++ = '\\'; + *t++ = *s; + break; + } + } else { + *t++ = *s; + } + + if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) { + CG(zend_lineno)++; + } + s++; + } + *t = 0; + + if (SCNG(output_filter)) { + size_t sz = 0; + s = zendlval->value.str.val; + SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)s, (size_t)zendlval->value.str.len TSRMLS_CC); + zendlval->value.str.len = sz; + efree(s); + } + return T_CONSTANT_ENCAPSED_STRING; +} + + +<ST_IN_SCRIPTING>b?["] { + int bprefix = (yytext[0] != '"') ? 1 : 0; + + while (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR++) { + case '"': + yyleng = YYCURSOR - SCNG(yy_text); + zend_scan_escape_string(zendlval, yytext+bprefix+1, yyleng-bprefix-2, '"' TSRMLS_CC); + return T_CONSTANT_ENCAPSED_STRING; + case '$': + if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { + break; + } + continue; + case '{': + if (*YYCURSOR == '$') { + break; + } + continue; + case '\\': + if (YYCURSOR < YYLIMIT) { + YYCURSOR++; + } + /* fall through */ + default: + continue; + } + + YYCURSOR--; + break; + } + + /* Remember how much was scanned to save rescanning */ + SET_DOUBLE_QUOTES_SCANNED_LENGTH(YYCURSOR - SCNG(yy_text) - yyleng); + + YYCURSOR = SCNG(yy_text) + yyleng; + + BEGIN(ST_DOUBLE_QUOTES); + return '"'; +} + + +<ST_IN_SCRIPTING>b?"<<<"{TABS_AND_SPACES}({LABEL}|([']{LABEL}['])|(["]{LABEL}["])){NEWLINE} { + char *s; + int bprefix = (yytext[0] != '<') ? 1 : 0; + zend_heredoc_label *heredoc_label = emalloc(sizeof(zend_heredoc_label)); + + CG(zend_lineno)++; + heredoc_label->length = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0); + s = yytext+bprefix+3; + while ((*s == ' ') || (*s == '\t')) { + s++; + heredoc_label->length--; + } + + if (*s == '\'') { + s++; + heredoc_label->length -= 2; + + BEGIN(ST_NOWDOC); + } else { + if (*s == '"') { + s++; + heredoc_label->length -= 2; + } + + BEGIN(ST_HEREDOC); + } + + heredoc_label->label = estrndup(s, heredoc_label->length); + + /* Check for ending label on the next line */ + if (heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; + + if (*end == ';') { + end++; + } + + if (*end == '\n' || *end == '\r') { + BEGIN(ST_END_HEREDOC); + } + } + + zend_ptr_stack_push(&SCNG(heredoc_label_stack), (void *) heredoc_label); + + return T_START_HEREDOC; +} + + +<ST_IN_SCRIPTING>[`] { + BEGIN(ST_BACKQUOTE); + return '`'; +} + + +<ST_END_HEREDOC>{ANY_CHAR} { + zend_heredoc_label *heredoc_label = zend_ptr_stack_pop(&SCNG(heredoc_label_stack)); + + YYCURSOR += heredoc_label->length - 1; + yyleng = heredoc_label->length; + + heredoc_label_dtor(heredoc_label); + efree(heredoc_label); + + BEGIN(ST_IN_SCRIPTING); + return T_END_HEREDOC; +} + + +<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"{$" { + zendlval->value.lval = (long) '{'; + yy_push_state(ST_IN_SCRIPTING TSRMLS_CC); + yyless(1); + return T_CURLY_OPEN; +} + + +<ST_DOUBLE_QUOTES>["] { + BEGIN(ST_IN_SCRIPTING); + return '"'; +} + +<ST_BACKQUOTE>[`] { + BEGIN(ST_IN_SCRIPTING); + return '`'; +} + + +<ST_DOUBLE_QUOTES>{ANY_CHAR} { + if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) { + YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1; + SET_DOUBLE_QUOTES_SCANNED_LENGTH(0); + + goto double_quotes_scan_done; + } + + if (YYCURSOR > YYLIMIT) { + return 0; + } + if (yytext[0] == '\\' && YYCURSOR < YYLIMIT) { + YYCURSOR++; + } + + while (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR++) { + case '"': + break; + case '$': + if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { + break; + } + continue; + case '{': + if (*YYCURSOR == '$') { + break; + } + continue; + case '\\': + if (YYCURSOR < YYLIMIT) { + YYCURSOR++; + } + /* fall through */ + default: + continue; + } + + YYCURSOR--; + break; + } + +double_quotes_scan_done: + yyleng = YYCURSOR - SCNG(yy_text); + + zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC); + return T_ENCAPSED_AND_WHITESPACE; +} + + +<ST_BACKQUOTE>{ANY_CHAR} { + if (YYCURSOR > YYLIMIT) { + return 0; + } + if (yytext[0] == '\\' && YYCURSOR < YYLIMIT) { + YYCURSOR++; + } + + while (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR++) { + case '`': + break; + case '$': + if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { + break; + } + continue; + case '{': + if (*YYCURSOR == '$') { + break; + } + continue; + case '\\': + if (YYCURSOR < YYLIMIT) { + YYCURSOR++; + } + /* fall through */ + default: + continue; + } + + YYCURSOR--; + break; + } + + yyleng = YYCURSOR - SCNG(yy_text); + + zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC); + return T_ENCAPSED_AND_WHITESPACE; +} + + +<ST_HEREDOC>{ANY_CHAR} { + int newline = 0; + + zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); + + if (YYCURSOR > YYLIMIT) { + return 0; + } + + YYCURSOR--; + + while (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR++) { + case '\r': + if (*YYCURSOR == '\n') { + YYCURSOR++; + } + /* fall through */ + case '\n': + /* Check for ending label on the next line */ + if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; + + if (*end == ';') { + end++; + } + + if (*end == '\n' || *end == '\r') { + /* newline before label will be subtracted from returned text, but + * yyleng/yytext will include it, for zend_highlight/strip, tokenizer, etc. */ + if (YYCURSOR[-2] == '\r' && YYCURSOR[-1] == '\n') { + newline = 2; /* Windows newline */ + } else { + newline = 1; + } + + CG(increment_lineno) = 1; /* For newline before label */ + BEGIN(ST_END_HEREDOC); + + goto heredoc_scan_done; + } + } + continue; + case '$': + if (IS_LABEL_START(*YYCURSOR) || *YYCURSOR == '{') { + break; + } + continue; + case '{': + if (*YYCURSOR == '$') { + break; + } + continue; + case '\\': + if (YYCURSOR < YYLIMIT && *YYCURSOR != '\n' && *YYCURSOR != '\r') { + YYCURSOR++; + } + /* fall through */ + default: + continue; + } + + YYCURSOR--; + break; + } + +heredoc_scan_done: + yyleng = YYCURSOR - SCNG(yy_text); + + zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC); + return T_ENCAPSED_AND_WHITESPACE; +} + + +<ST_NOWDOC>{ANY_CHAR} { + int newline = 0; + + zend_heredoc_label *heredoc_label = zend_ptr_stack_top(&SCNG(heredoc_label_stack)); + + if (YYCURSOR > YYLIMIT) { + return 0; + } + + YYCURSOR--; + + while (YYCURSOR < YYLIMIT) { + switch (*YYCURSOR++) { + case '\r': + if (*YYCURSOR == '\n') { + YYCURSOR++; + } + /* fall through */ + case '\n': + /* Check for ending label on the next line */ + if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) { + YYCTYPE *end = YYCURSOR + heredoc_label->length; + + if (*end == ';') { + end++; + } + + if (*end == '\n' || *end == '\r') { + /* newline before label will be subtracted from returned text, but + * yyleng/yytext will include it, for zend_highlight/strip, tokenizer, etc. */ + if (YYCURSOR[-2] == '\r' && YYCURSOR[-1] == '\n') { + newline = 2; /* Windows newline */ + } else { + newline = 1; + } + + CG(increment_lineno) = 1; /* For newline before label */ + BEGIN(ST_END_HEREDOC); + + goto nowdoc_scan_done; + } + } + /* fall through */ + default: + continue; + } + } + +nowdoc_scan_done: + yyleng = YYCURSOR - SCNG(yy_text); + + zend_copy_value(zendlval, yytext, yyleng - newline); + zendlval->type = IS_STRING; + HANDLE_NEWLINES(yytext, yyleng - newline); + return T_ENCAPSED_AND_WHITESPACE; +} + + +<ST_IN_SCRIPTING,ST_VAR_OFFSET>{ANY_CHAR} { + if (YYCURSOR > YYLIMIT) { + return 0; + } + + zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE); + goto restart; +} + +*/ +} diff --git a/Zend/zend_language_scanner_defs.h b/Zend/zend_language_scanner_defs.h index 5926e3c..677ebcd 100644 --- a/Zend/zend_language_scanner_defs.h +++ b/Zend/zend_language_scanner_defs.h @@ -1,15 +1,14 @@ -/* Generated by re2c 0.13.5 */ -#line 3 "Zend/zend_language_scanner_defs.h" - -enum YYCONDTYPE { - yycST_IN_SCRIPTING, - yycST_LOOKING_FOR_PROPERTY, - yycST_BACKQUOTE, - yycST_DOUBLE_QUOTES, - yycST_HEREDOC, - yycST_LOOKING_FOR_VARNAME, - yycST_VAR_OFFSET, - yycINITIAL, - yycST_END_HEREDOC, - yycST_NOWDOC, -}; +/* Generated by re2c 0.13.5 */ + +enum YYCONDTYPE { + yycST_IN_SCRIPTING, + yycST_LOOKING_FOR_PROPERTY, + yycST_BACKQUOTE, + yycST_DOUBLE_QUOTES, + yycST_HEREDOC, + yycST_LOOKING_FOR_VARNAME, + yycST_VAR_OFFSET, + yycINITIAL, + yycST_END_HEREDOC, + yycST_NOWDOC, +};
« previous php.cvs (#73641) next »