Skip to content
Newer
Older
100644 2383 lines (1963 sloc) 55 KB
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
97a9470 @laruence bump year which is missed in rev 49493a2
laruence authored Jan 2, 2016
5 | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
6 +----------------------------------------------------------------------+
d863d52 @sebastianbergmann Update headers.
sebastianbergmann authored Dec 11, 2001
7 | This source file is subject to version 2.00 of the Zend license, |
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff updating license information in the headers.
James Cox authored Jun 10, 2003
9 | available through the world-wide-web at the following url: |
d863d52 @sebastianbergmann Update headers.
sebastianbergmann authored Dec 11, 2001
10 | http://www.zend.com/license/2_00.txt. |
b5b1117 @zsuraski License update
zsuraski authored Jul 16, 1999
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
14 +----------------------------------------------------------------------+
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
15 | Authors: Marcus Boerger <helly@php.net> |
16 | Nuno Lopes <nlopess@php.net> |
17 | Scott MacVicar <scottmac@php.net> |
18 | Flex version authors: |
19 | Andi Gutmans <andi@zend.com> |
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
20 | Zeev Suraski <zeev@zend.com> |
21 +----------------------------------------------------------------------+
22 */
23
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored Feb 1, 2003
24 /* $Id$ */
25
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
26 #if 0
27 # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
28 #else
29 # define YYDEBUG(s, c)
30 #endif
31
32 #include "zend_language_scanner_defs.h"
79961dc @felipensp - Fixed Windows build
felipensp authored Apr 30, 2012
33
34 #include <errno.h>
35 #include "zend.h"
ce2cd89 @KalleZ Replace references to PHP_WIN32 and TSRM_WIN32 with ZEND_WIN32 in Zen…
KalleZ authored Jul 4, 2015
36 #ifdef ZEND_WIN32
3120387 @felipensp - Changed last commit to use VK_ESCAPE on Windows
felipensp authored Apr 30, 2012
37 # include <Winuser.h>
38 #endif
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
39 #include "zend_alloc.h"
4cf9d27 - Fixed bug #28930 (PHP sources pick wrong header files generated by …
foobar authored Dec 30, 2004
40 #include <zend_language_parser.h>
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
41 #include "zend_compile.h"
7b0d92d @zsuraski Unify the names of these last 3 files...
zsuraski authored Oct 29, 2000
42 #include "zend_language_scanner.h"
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
43 #include "zend_highlight.h"
44 #include "zend_constants.h"
45 #include "zend_variables.h"
46 #include "zend_operators.h"
86d46f7 - Speed up by making null/false/true reserved word which allows to drop
Marcus Boerger authored Jul 16, 2004
47 #include "zend_API.h"
e612284 - Fixed bug #30630: Added a BSD based strtod function that is
Derick Rethans authored Nov 3, 2004
48 #include "zend_strtod.h"
50ea267 - Avoid sprintf, even when checked copy'n'paste or changes lead to er…
Marcus Boerger authored Feb 24, 2007
49 #include "zend_exceptions.h"
e30b2aa @weltling initial move on renaming files and fixing includes
weltling authored Oct 17, 2013
50 #include "zend_virtual_cwd.h"
fd597dc @smalyshev [DOC] Add compile-time __DIR__ constant which implements dirname(__FI…
smalyshev authored Feb 12, 2008
51 #include "tsrm_config_common.h"
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
52
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
53 #define YYCTYPE unsigned char
dd031ee MFH: Fix scanner handling of NULL values in heredoc, nowdoc, strings,…
Brian Shire authored Mar 16, 2009
54 #define YYFILL(n) { if ((YYCURSOR + n) >= (YYLIMIT + ZEND_MMAP_AHEAD)) { return 0; } }
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
55 #define YYCURSOR SCNG(yy_cursor)
56 #define YYLIMIT SCNG(yy_limit)
57 #define YYMARKER SCNG(yy_marker)
58
59 #define YYGETCONDITION() SCNG(yy_state)
60 #define YYSETCONDITION(s) SCNG(yy_state) = s
61
62 #define STATE(name) yyc##name
63
64 /* emulate flex constructs */
65 #define BEGIN(state) YYSETCONDITION(STATE(state))
66 #define YYSTATE YYGETCONDITION()
67 #define yytext ((char*)SCNG(yy_text))
68 #define yyleng SCNG(yy_leng)
cfc1756 @nunoplopes fix the yyless() definition to match flex one and revert part of last…
nunoplopes authored Apr 9, 2008
69 #define yyless(x) do { YYCURSOR = (unsigned char*)yytext + x; \
70 yyleng = (unsigned int)x; } while(0)
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
71 #define yymore() goto yymore_restart
72
bfcdbbc @nunoplopes add sanity checks for ZEND_MMAP_AHEAD and reduce the value from 32 to…
nunoplopes authored Apr 4, 2008
73 /* perform sanity check. If this message is triggered you should
74 increase the ZEND_MMAP_AHEAD value in the zend_streams.h file */
75 /*!max:re2c */
76 #if ZEND_MMAP_AHEAD < YYMAXFILL
77 # error ZEND_MMAP_AHEAD should be greater than or equal to YYMAXFILL
78 #endif
79
009025e * header file cleanup
Stig S. Bakken authored Sep 6, 1999
80 #ifdef HAVE_STDARG_H
81 # include <stdarg.h>
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
82 #endif
83
009025e * header file cleanup
Stig S. Bakken authored Sep 6, 1999
84 #ifdef HAVE_UNISTD_H
85 # include <unistd.h>
473d1d7 @zsuraski * Fix a bug that occured in case of parse errors. We need to restore …
zsuraski authored May 11, 1999
86 #endif
87
609d58a @zsuraski Merge from branch - move to standard C scanners in thread safe mode
zsuraski authored Aug 6, 2001
88 /* Globals Macros */
89 #define SCNG LANG_SCNG
90 #ifdef ZTS
91 ZEND_API ts_rsrc_id language_scanner_globals_id;
92 #else
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
93 ZEND_API zend_php_scanner_globals language_scanner_globals;
609d58a @zsuraski Merge from branch - move to standard C scanners in thread safe mode
zsuraski authored Aug 6, 2001
94 #endif
95
4f6c95d @zsuraski Whitespace
zsuraski authored Aug 11, 2001
96 #define HANDLE_NEWLINES(s, l) \
a514e8f @andigutmans - Fix line numbers when some lines end with \r
andigutmans authored May 8, 2001
97 do { \
4f6c95d @zsuraski Whitespace
zsuraski authored Aug 11, 2001
98 char *p = (s), *boundary = p+(l); \
a514e8f @andigutmans - Fix line numbers when some lines end with \r
andigutmans authored May 8, 2001
99 \
100 while (p<boundary) { \
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
101 if (*p == '\n' || (*p == '\r' && (*(p+1) != '\n'))) { \
a514e8f @andigutmans - Fix line numbers when some lines end with \r
andigutmans authored May 8, 2001
102 CG(zend_lineno)++; \
103 } \
104 p++; \
105 } \
acd56b0 @andigutmans - More whitespace fixes while I'm at it.
andigutmans authored Apr 27, 2001
106 } while (0)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
107
108 #define HANDLE_NEWLINE(c) \
109 { \
a514e8f @andigutmans - Fix line numbers when some lines end with \r
andigutmans authored May 8, 2001
110 if (c == '\n' || c == '\r') { \
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
111 CG(zend_lineno)++; \
112 } \
113 }
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
114
f4cfaf3 @dstogov Use better data structures (incomplete)
dstogov authored Feb 10, 2014
115 /* To save initial string length after scanning to first variable */
116 #define SET_DOUBLE_QUOTES_SCANNED_LENGTH(len) SCNG(scanned_string_len) = (len)
117 #define GET_DOUBLE_QUOTES_SCANNED_LENGTH() SCNG(scanned_string_len)
09034cf MFH: Implemented manual scanning for strings/comments, plus misc. fixes
Matt Wilmas authored May 5, 2009
118
119 #define IS_LABEL_START(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || (c) == '_' || (c) >= 0x7F)
120
d63f813 @andigutmans - Clean up the scanner a tiny bit while messing with it.
andigutmans authored Dec 17, 2000
121 #define ZEND_IS_OCT(c) ((c)>='0' && (c)<='7')
67296f0 @zsuraski Add \012 and \xff missing support to constant quoted string
zsuraski authored May 14, 1999
122 #define ZEND_IS_HEX(c) (((c)>='0' && (c)<='9') || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F'))
123
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
124 BEGIN_EXTERN_C()
c5d8c38 @zsuraski Ok, I tested it now. It works very nicely!
zsuraski authored May 6, 1999
125
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
126 static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
127 {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
128 const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
f017843 @nikic Remove self-contradictory zend multibyte assertion
nikic authored Sep 11, 2014
129 ZEND_ASSERT(internal_encoding);
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
130 return zend_multibyte_encoding_converter(to, to_length, from, from_length, internal_encoding, LANG_SCNG(script_encoding));
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
131 }
132
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
133 static size_t encoding_filter_script_to_intermediate(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
134 {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
135 return zend_multibyte_encoding_converter(to, to_length, from, from_length, zend_multibyte_encoding_utf8, LANG_SCNG(script_encoding));
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
136 }
137
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
138 static size_t encoding_filter_intermediate_to_script(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
139 {
140 return zend_multibyte_encoding_converter(to, to_length, from, from_length,
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
141 LANG_SCNG(script_encoding), zend_multibyte_encoding_utf8);
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
142 }
143
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
144 static size_t encoding_filter_intermediate_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length)
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
145 {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
146 const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
f017843 @nikic Remove self-contradictory zend multibyte assertion
nikic authored Sep 11, 2014
147 ZEND_ASSERT(internal_encoding);
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
148 return zend_multibyte_encoding_converter(to, to_length, from, from_length,
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
149 internal_encoding, zend_multibyte_encoding_utf8);
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
150 }
151
152
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
153 static void _yy_push_state(int new_state)
c5d8c38 @zsuraski Ok, I tested it now. It works very nicely!
zsuraski authored May 6, 1999
154 {
5a03efe @nikic Don't allocate zend_stack elements individually
nikic authored Apr 30, 2014
155 zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION());
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
156 YYSETCONDITION(new_state);
157 }
158
159 #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm)
160
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
161 static void yy_pop_state(void)
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
162 {
e0247de @nikic zend_stack_top() now returns pointer directly
nikic authored Apr 30, 2014
163 int *stack_state = zend_stack_top(&SCNG(state_stack));
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
164 YYSETCONDITION(*stack_state);
165 zend_stack_del_top(&SCNG(state_stack));
166 }
167
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
168 static void yy_scan_buffer(char *str, unsigned int len)
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
169 {
170 YYCURSOR = (YYCTYPE*)str;
171 YYLIMIT = YYCURSOR + len;
f6f0f65 @felipensp - Fixed bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP >= 5.3)
felipensp authored Jun 30, 2010
172 if (!SCNG(yy_start)) {
173 SCNG(yy_start) = YYCURSOR;
174 }
c5d8c38 @zsuraski Ok, I tested it now. It works very nicely!
zsuraski authored May 6, 1999
175 }
176
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
177 void startup_scanner(void)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
178 {
72f7be3 @felipensp - Improved parse error messages
felipensp authored Jun 23, 2011
179 CG(parse_error) = 0;
f3ebf7d Fixed bug (Crash on Windows and ZTS) that was introduced with fix for…
Dmitry Stogov authored Jun 9, 2005
180 CG(doc_comment) = NULL;
5a03efe @nikic Don't allocate zend_stack elements individually
nikic authored Apr 30, 2014
181 zend_stack_init(&SCNG(state_stack), sizeof(int));
4cf90e0 @nikic Fix lexing of nested heredoc strings in token_get_all()
nikic authored Mar 30, 2012
182 zend_ptr_stack_init(&SCNG(heredoc_label_stack));
183 }
184
185 static void heredoc_label_dtor(zend_heredoc_label *heredoc_label) {
186 efree(heredoc_label->label);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
187 }
188
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
189 void shutdown_scanner(void)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
190 {
72f7be3 @felipensp - Improved parse error messages
felipensp authored Jun 23, 2011
191 CG(parse_error) = 0;
bdd3b60 Implement a different way to catch documentation comments.
Andrei Zmievski authored Apr 2, 2003
192 RESET_DOC_COMMENT();
4cf90e0 @nikic Fix lexing of nested heredoc strings in token_get_all()
nikic authored Mar 30, 2012
193 zend_stack_destroy(&SCNG(state_stack));
194 zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1);
195 zend_ptr_stack_destroy(&SCNG(heredoc_label_stack));
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
196 SCNG(on_event) = NULL;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
197 }
198
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
199 ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
200 {
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
201 lex_state->yy_leng = SCNG(yy_leng);
202 lex_state->yy_start = SCNG(yy_start);
203 lex_state->yy_text = SCNG(yy_text);
204 lex_state->yy_cursor = SCNG(yy_cursor);
205 lex_state->yy_marker = SCNG(yy_marker);
206 lex_state->yy_limit = SCNG(yy_limit);
207
208 lex_state->state_stack = SCNG(state_stack);
5a03efe @nikic Don't allocate zend_stack elements individually
nikic authored Apr 30, 2014
209 zend_stack_init(&SCNG(state_stack), sizeof(int));
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
210
4cf90e0 @nikic Fix lexing of nested heredoc strings in token_get_all()
nikic authored Mar 30, 2012
211 lex_state->heredoc_label_stack = SCNG(heredoc_label_stack);
212 zend_ptr_stack_init(&SCNG(heredoc_label_stack));
213
483fc4c @zsuraski MFZE1
zsuraski authored Sep 19, 2001
214 lex_state->in = SCNG(yy_in);
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
215 lex_state->yy_state = YYSTATE;
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
216 lex_state->filename = zend_get_compiled_filename();
7957b20 @zsuraski Fix filenames and line numbers in ZTS mode
zsuraski authored Jun 17, 2000
217 lex_state->lineno = CG(zend_lineno);
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
218
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
219 lex_state->script_org = SCNG(script_org);
220 lex_state->script_org_size = SCNG(script_org_size);
221 lex_state->script_filtered = SCNG(script_filtered);
222 lex_state->script_filtered_size = SCNG(script_filtered_size);
223 lex_state->input_filter = SCNG(input_filter);
224 lex_state->output_filter = SCNG(output_filter);
225 lex_state->script_encoding = SCNG(script_encoding);
b494aa0 @dstogov Fixed compiler reenterability
dstogov authored Jan 22, 2015
226
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
227 lex_state->on_event = SCNG(on_event);
228
b494aa0 @dstogov Fixed compiler reenterability
dstogov authored Jan 22, 2015
229 lex_state->ast = CG(ast);
230 lex_state->ast_arena = CG(ast_arena);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
231 }
232
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
233 ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
234 {
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
235 SCNG(yy_leng) = lex_state->yy_leng;
236 SCNG(yy_start) = lex_state->yy_start;
237 SCNG(yy_text) = lex_state->yy_text;
238 SCNG(yy_cursor) = lex_state->yy_cursor;
239 SCNG(yy_marker) = lex_state->yy_marker;
240 SCNG(yy_limit) = lex_state->yy_limit;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
241
bcd9099 Fixed bug #47038 (Memory leak in include)
Dmitry Stogov authored Mar 25, 2009
242 zend_stack_destroy(&SCNG(state_stack));
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
243 SCNG(state_stack) = lex_state->state_stack;
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
244
4cf90e0 @nikic Fix lexing of nested heredoc strings in token_get_all()
nikic authored Mar 30, 2012
245 zend_ptr_stack_clean(&SCNG(heredoc_label_stack), (void (*)(void *)) &heredoc_label_dtor, 1);
246 zend_ptr_stack_destroy(&SCNG(heredoc_label_stack));
247 SCNG(heredoc_label_stack) = lex_state->heredoc_label_stack;
248
483fc4c @zsuraski MFZE1
zsuraski authored Sep 19, 2001
249 SCNG(yy_in) = lex_state->in;
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
250 YYSETCONDITION(lex_state->yy_state);
7957b20 @zsuraski Fix filenames and line numbers in ZTS mode
zsuraski authored Jun 17, 2000
251 CG(zend_lineno) = lex_state->lineno;
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
252 zend_restore_compiled_filename(lex_state->filename);
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
253
254 if (SCNG(script_filtered)) {
255 efree(SCNG(script_filtered));
256 SCNG(script_filtered) = NULL;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
257 }
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
258 SCNG(script_org) = lex_state->script_org;
259 SCNG(script_org_size) = lex_state->script_org_size;
260 SCNG(script_filtered) = lex_state->script_filtered;
261 SCNG(script_filtered_size) = lex_state->script_filtered_size;
262 SCNG(input_filter) = lex_state->input_filter;
263 SCNG(output_filter) = lex_state->output_filter;
264 SCNG(script_encoding) = lex_state->script_encoding;
7a2157c Fixed Bug #53629 (memory leak inside highlight_string()).
Ilia Alshanetsky authored Jan 3, 2011
265
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
266 SCNG(on_event) = lex_state->on_event;
267
b494aa0 @dstogov Fixed compiler reenterability
dstogov authored Jan 22, 2015
268 CG(ast) = lex_state->ast;
269 CG(ast_arena) = lex_state->ast_arena;
270
2208447 @smalyshev Fix bug #64936 - clean doc comment state at the beginning and end of …
smalyshev authored Jun 16, 2013
271 RESET_DOC_COMMENT();
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
272 }
273
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
274 ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
58153df @zsuraski - Improve the file handle closing code
zsuraski authored Nov 26, 1999
275 {
276 zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
090215c @tony2001 nullify opened_path and filename (when required)
tony2001 authored Nov 23, 2006
277 /* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
278 file_handle->opened_path = NULL;
279 if (file_handle->free_filename) {
280 file_handle->filename = NULL;
281 }
74a9ed7 @zsuraski Weed out all BoundsChecker-found bugs (including a serious file descr…
zsuraski authored May 10, 1999
282 }
283
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
284 ZEND_API void zend_lex_tstring(zval *zv)
285 {
286 if (SCNG(on_event)) SCNG(on_event)(ON_FEEDBACK, T_STRING, 0);
287
288 ZVAL_STRINGL(zv, (char*)SCNG(yy_text), SCNG(yy_leng));
289 }
290
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
291 #define BOM_UTF32_BE "\x00\x00\xfe\xff"
292 #define BOM_UTF32_LE "\xff\xfe\x00\x00"
293 #define BOM_UTF16_BE "\xfe\xff"
294 #define BOM_UTF16_LE "\xff\xfe"
295 #define BOM_UTF8 "\xef\xbb\xbf"
296
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
297 static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size)
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
298 {
299 const unsigned char *p;
300 int wchar_size = 2;
301 int le = 0;
302
303 /* utf-16 or utf-32? */
304 p = script;
d9d16d2 @weltling fix datatype mismatch warnings
weltling authored Oct 28, 2014
305 assert(p >= script);
306 while ((size_t)(p-script) < script_size) {
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
307 p = memchr(p, 0, script_size-(p-script)-2);
308 if (!p) {
309 break;
310 }
311 if (*(p+1) == '\0' && *(p+2) == '\0') {
312 wchar_size = 4;
313 break;
314 }
315
316 /* searching for UTF-32 specific byte orders, so this will do */
317 p += 4;
318 }
319
320 /* BE or LE? */
321 p = script;
d9d16d2 @weltling fix datatype mismatch warnings
weltling authored Oct 28, 2014
322 assert(p >= script);
323 while ((size_t)(p-script) < script_size) {
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
324 if (*p == '\0' && *(p+wchar_size-1) != '\0') {
325 /* BE */
326 le = 0;
327 break;
328 } else if (*p != '\0' && *(p+wchar_size-1) == '\0') {
329 /* LE* */
330 le = 1;
331 break;
332 }
333 p += wchar_size;
334 }
335
336 if (wchar_size == 2) {
337 return le ? zend_multibyte_encoding_utf16le : zend_multibyte_encoding_utf16be;
338 } else {
339 return le ? zend_multibyte_encoding_utf32le : zend_multibyte_encoding_utf32be;
340 }
341
342 return NULL;
343 }
344
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
345 static const zend_encoding* zend_multibyte_detect_unicode(void)
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
346 {
347 const zend_encoding *script_encoding = NULL;
348 int bom_size;
349 unsigned char *pos1, *pos2;
350
351 if (LANG_SCNG(script_org_size) < sizeof(BOM_UTF32_LE)-1) {
352 return NULL;
353 }
354
355 /* check out BOM */
356 if (!memcmp(LANG_SCNG(script_org), BOM_UTF32_BE, sizeof(BOM_UTF32_BE)-1)) {
357 script_encoding = zend_multibyte_encoding_utf32be;
358 bom_size = sizeof(BOM_UTF32_BE)-1;
359 } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF32_LE, sizeof(BOM_UTF32_LE)-1)) {
360 script_encoding = zend_multibyte_encoding_utf32le;
361 bom_size = sizeof(BOM_UTF32_LE)-1;
362 } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF16_BE, sizeof(BOM_UTF16_BE)-1)) {
363 script_encoding = zend_multibyte_encoding_utf16be;
364 bom_size = sizeof(BOM_UTF16_BE)-1;
365 } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF16_LE, sizeof(BOM_UTF16_LE)-1)) {
366 script_encoding = zend_multibyte_encoding_utf16le;
367 bom_size = sizeof(BOM_UTF16_LE)-1;
368 } else if (!memcmp(LANG_SCNG(script_org), BOM_UTF8, sizeof(BOM_UTF8)-1)) {
369 script_encoding = zend_multibyte_encoding_utf8;
370 bom_size = sizeof(BOM_UTF8)-1;
371 }
372
373 if (script_encoding) {
374 /* remove BOM */
bbc879b Fixed multibyte related issues
Dmitry Stogov authored Mar 14, 2011
375 LANG_SCNG(script_org) += bom_size;
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
376 LANG_SCNG(script_org_size) -= bom_size;
377
378 return script_encoding;
379 }
380
381 /* script contains NULL bytes -> auto-detection */
382 if ((pos1 = memchr(LANG_SCNG(script_org), 0, LANG_SCNG(script_org_size)))) {
383 /* check if the NULL byte is after the __HALT_COMPILER(); */
384 pos2 = LANG_SCNG(script_org);
385
386 while (pos1 - pos2 >= sizeof("__HALT_COMPILER();")-1) {
387 pos2 = memchr(pos2, '_', pos1 - pos2);
388 if (!pos2) break;
389 pos2++;
390 if (strncasecmp((char*)pos2, "_HALT_COMPILER", sizeof("_HALT_COMPILER")-1) == 0) {
391 pos2 += sizeof("_HALT_COMPILER")-1;
392 while (*pos2 == ' ' ||
393 *pos2 == '\t' ||
394 *pos2 == '\r' ||
395 *pos2 == '\n') {
396 pos2++;
397 }
398 if (*pos2 == '(') {
399 pos2++;
400 while (*pos2 == ' ' ||
401 *pos2 == '\t' ||
402 *pos2 == '\r' ||
403 *pos2 == '\n') {
404 pos2++;
405 }
406 if (*pos2 == ')') {
407 pos2++;
408 while (*pos2 == ' ' ||
409 *pos2 == '\t' ||
410 *pos2 == '\r' ||
411 *pos2 == '\n') {
412 pos2++;
413 }
414 if (*pos2 == ';') {
415 return NULL;
416 }
417 }
418 }
419 }
420 }
421 /* make best effort if BOM is missing */
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
422 return zend_multibyte_detect_utf_encoding(LANG_SCNG(script_org), LANG_SCNG(script_org_size));
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
423 }
424
425 return NULL;
426 }
427
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
428 static const zend_encoding* zend_multibyte_find_script_encoding(void)
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
429 {
430 const zend_encoding *script_encoding;
431
432 if (CG(detect_unicode)) {
433 /* check out bom(byte order mark) and see if containing wchars */
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
434 script_encoding = zend_multibyte_detect_unicode();
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
435 if (script_encoding != NULL) {
436 /* bom or wchar detection is prior to 'script_encoding' option */
437 return script_encoding;
438 }
439 }
440
441 /* if no script_encoding specified, just leave alone */
442 if (!CG(script_encoding_list) || !CG(script_encoding_list_size)) {
443 return NULL;
444 }
445
446 /* if multiple encodings specified, detect automagically */
447 if (CG(script_encoding_list_size) > 1) {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
448 return zend_multibyte_encoding_detector(LANG_SCNG(script_org), LANG_SCNG(script_org_size), CG(script_encoding_list), CG(script_encoding_list_size));
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
449 }
450
451 return CG(script_encoding_list)[0];
452 }
453
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
454 ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding)
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
455 {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
456 const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding();
457 const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding();
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
458
459 if (!script_encoding) {
460 return FAILURE;
461 }
462
463 /* judge input/output filter */
464 LANG_SCNG(script_encoding) = script_encoding;
465 LANG_SCNG(input_filter) = NULL;
466 LANG_SCNG(output_filter) = NULL;
467
468 if (!internal_encoding || LANG_SCNG(script_encoding) == internal_encoding) {
469 if (!zend_multibyte_check_lexer_compatibility(LANG_SCNG(script_encoding))) {
470 /* and if not, work around w/ script_encoding -> utf-8 -> script_encoding conversion */
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
471 LANG_SCNG(input_filter) = encoding_filter_script_to_intermediate;
472 LANG_SCNG(output_filter) = encoding_filter_intermediate_to_script;
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
473 } else {
474 LANG_SCNG(input_filter) = NULL;
475 LANG_SCNG(output_filter) = NULL;
476 }
477 return SUCCESS;
478 }
479
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
480 if (zend_multibyte_check_lexer_compatibility(internal_encoding)) {
481 LANG_SCNG(input_filter) = encoding_filter_script_to_internal;
482 LANG_SCNG(output_filter) = NULL;
483 } else if (zend_multibyte_check_lexer_compatibility(LANG_SCNG(script_encoding))) {
484 LANG_SCNG(input_filter) = NULL;
485 LANG_SCNG(output_filter) = encoding_filter_script_to_internal;
486 } else {
487 /* both script and internal encodings are incompatible w/ flex */
488 LANG_SCNG(input_filter) = encoding_filter_script_to_intermediate;
489 LANG_SCNG(output_filter) = encoding_filter_intermediate_to_internal;
490 }
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
491
492 return 0;
493 }
87ba08d @zsuraski Avoid leaking fd's in case of failures
zsuraski authored May 22, 1999
494
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
495 ZEND_API int open_file_for_scanning(zend_file_handle *file_handle)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
496 {
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored Sep 13, 2011
497 char *buf;
f6f0f65 @felipensp - Fixed bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP >= 5.3)
felipensp authored Jun 30, 2010
498 size_t size, offset = 0;
e7d173f @laruence Fixed Memory leak
laruence authored Feb 17, 2014
499 zend_string *compiled_filename;
516c2f5 @smalyshev removing scalar types in trunk
smalyshev authored May 15, 2011
500
f6f0f65 @felipensp - Fixed bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP >= 5.3)
felipensp authored Jun 30, 2010
501 /* The shebang line was read, get the current position to obtain the buffer start */
502 if (CG(start_lineno) == 2 && file_handle->type == ZEND_HANDLE_FP && file_handle->handle.fp) {
503 if ((offset = ftell(file_handle->handle.fp)) == -1) {
504 offset = 0;
505 }
506 }
290525f @andigutmans Always store full filename as compiled file name
andigutmans authored Jul 27, 2000
507
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
508 if (zend_stream_fixup(file_handle, &buf, &size) == FAILURE) {
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
509 return FAILURE;
510 }
714d083 @andigutmans - Fix by Jani Taskinen <sniper@iki.fi> for whole path also to work
andigutmans authored Mar 12, 2001
511
e52aac9 @wez Implement simple stream support in the ZE scanners.
wez authored Feb 18, 2003
512 zend_llist_add_element(&CG(open_files), file_handle);
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
513 if (file_handle->handle.stream.handle >= (void*)file_handle && file_handle->handle.stream.handle <= (void*)(file_handle+1)) {
514 zend_file_handle *fh = (zend_file_handle*)zend_llist_get_last(&CG(open_files));
515 size_t diff = (char*)file_handle->handle.stream.handle - (char*)file_handle;
516 fh->handle.stream.handle = (void*)(((char*)fh) + diff);
517 file_handle->handle.stream.handle = fh->handle.stream.handle;
518 }
519
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
520 /* Reset the scanner for scanning the new file */
e52aac9 @wez Implement simple stream support in the ZE scanners.
wez authored Feb 18, 2003
521 SCNG(yy_in) = file_handle;
f6f0f65 @felipensp - Fixed bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP >= 5.3)
felipensp authored Jun 30, 2010
522 SCNG(yy_start) = NULL;
ab9dcec @fujimoto - added script encoding support to Zend Engine 2.
fujimoto authored Aug 11, 2003
523
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
524 if (size != -1) {
ab93d8c Added multibyte suppport by default. Previosly php had to be compiled…
Dmitry Stogov authored Nov 24, 2010
525 if (CG(multibyte)) {
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored Sep 13, 2011
526 SCNG(script_org) = (unsigned char*)buf;
516c2f5 @smalyshev removing scalar types in trunk
smalyshev authored May 15, 2011
527 SCNG(script_org_size) = size;
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
528 SCNG(script_filtered) = NULL;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
529
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
530 zend_multibyte_set_filter(NULL);
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
531
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
532 if (SCNG(input_filter)) {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
533 if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size))) {
ab93d8c Added multibyte suppport by default. Previosly php had to be compiled…
Dmitry Stogov authored Nov 24, 2010
534 zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
bbf3d43 * Refactor zend_multibyte facility.
Moriyoshi Koizumi authored Dec 19, 2010
535 "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
ab93d8c Added multibyte suppport by default. Previosly php had to be compiled…
Dmitry Stogov authored Nov 24, 2010
536 }
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored Sep 13, 2011
537 buf = (char*)SCNG(script_filtered);
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
538 size = SCNG(script_filtered_size);
1d04f41 @pierrejoye - NULL deref fix, patch by Gustavo
pierrejoye authored Nov 17, 2010
539 }
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
540 }
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
541 SCNG(yy_start) = (unsigned char *)buf - offset;
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
542 yy_scan_buffer(buf, (unsigned int)size);
ab9dcec @fujimoto - added script encoding support to Zend Engine 2.
fujimoto authored Aug 11, 2003
543 } else {
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
544 zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
ab9dcec @fujimoto - added script encoding support to Zend Engine 2.
fujimoto authored Aug 11, 2003
545 }
546
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
547 BEGIN(INITIAL);
714d083 @andigutmans - Fix by Jani Taskinen <sniper@iki.fi> for whole path also to work
andigutmans authored Mar 12, 2001
548
0971ff9 @andigutmans - Whitespace changes to be standard like the rest of Zend
andigutmans authored Apr 27, 2001
549 if (file_handle->opened_path) {
2fa8d67 @dstogov Use zend_string* instead of char* for opened_patch handling. Avoid re…
dstogov authored Mar 4, 2015
550 compiled_filename = zend_string_copy(file_handle->opened_path);
714d083 @andigutmans - Fix by Jani Taskinen <sniper@iki.fi> for whole path also to work
andigutmans authored Mar 12, 2001
551 } else {
2fa8d67 @dstogov Use zend_string* instead of char* for opened_patch handling. Avoid re…
dstogov authored Mar 3, 2015
552 compiled_filename = zend_string_init(file_handle->filename, strlen(file_handle->filename), 0);
714d083 @andigutmans - Fix by Jani Taskinen <sniper@iki.fi> for whole path also to work
andigutmans authored Mar 12, 2001
553 }
554
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
555 zend_set_compiled_filename(compiled_filename);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
556 zend_string_release(compiled_filename);
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
557
cf05f34 @zsuraski MFZE1 - lineno fix
zsuraski authored Jan 5, 2003
558 if (CG(start_lineno)) {
559 CG(zend_lineno) = CG(start_lineno);
560 CG(start_lineno) = 0;
78bf1d9 MFZE1
Ilia Alshanetsky authored Nov 5, 2002
561 } else {
562 CG(zend_lineno) = 1;
563 }
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
564
2208447 @smalyshev Fix bug #64936 - clean doc comment state at the beginning and end of …
smalyshev authored Jun 16, 2013
565 RESET_DOC_COMMENT();
7ade3b3 @zsuraski Fix an off by one lineno issue, in case of an implicit ;
zsuraski authored Aug 6, 2001
566 CG(increment_lineno) = 0;
a458b4f @zsuraski Support eval() and highlight_string() in the C++ scanner
zsuraski authored Apr 23, 1999
567 return SUCCESS;
1aa2c5c @zsuraski Ok, call me crazy, because I probably am.
zsuraski authored Apr 23, 1999
568 }
569 END_EXTERN_C()
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
570
998204e @dstogov Separate common part of compile_file() and compile_string() into zend…
dstogov authored Nov 12, 2015
571 static zend_op_array *zend_compile(int type)
572 {
573 zend_op_array *op_array = NULL;
574 zend_bool original_in_compilation = CG(in_compilation);
575
576 CG(in_compilation) = 1;
577 CG(ast) = NULL;
578 CG(ast_arena) = zend_arena_create(1024 * 32);
579
580 if (!zendparse()) {
581 zend_file_context original_file_context;
582 zend_oparray_context original_oparray_context;
583 zend_op_array *original_active_op_array = CG(active_op_array);
584
585 op_array = emalloc(sizeof(zend_op_array));
586 init_op_array(op_array, type, INITIAL_OP_ARRAY_SIZE);
587 CG(active_op_array) = op_array;
588
589 if (zend_ast_process) {
590 zend_ast_process(CG(ast));
591 }
592
593 zend_file_context_begin(&original_file_context);
594 zend_oparray_context_begin(&original_oparray_context);
595 zend_compile_top_stmt(CG(ast));
596 zend_emit_final_return(type == ZEND_USER_FUNCTION);
597 op_array->line_start = 1;
598 op_array->line_end = CG(zend_lineno);
599 pass_two(op_array);
600 zend_oparray_context_end(&original_oparray_context);
601 zend_file_context_end(&original_file_context);
602
603 CG(active_op_array) = original_active_op_array;
604 }
605
606 zend_ast_destroy(CG(ast));
607 zend_arena_destroy(CG(ast_arena));
608
609 CG(in_compilation) = original_in_compilation;
610
611 return op_array;
612 }
39f9487 @andigutmans -Tiny patches
andigutmans authored Apr 14, 1999
613
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
614 ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
615 {
616 zend_lex_state original_lex_state;
f1a6c06 @nikic Support ParseException for require etc
nikic authored Mar 17, 2015
617 zend_op_array *op_array = NULL;
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
618 zend_save_lexical_state(&original_lex_state);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
619
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
620 if (open_file_for_scanning(file_handle)==FAILURE) {
7795aca @zsuraski Fix warning issue (compile errors inside require()'d files were incor…
zsuraski authored Aug 15, 2000
621 if (type==ZEND_REQUIRE) {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
622 zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
623 zend_bailout();
7795aca @zsuraski Fix warning issue (compile errors inside require()'d files were incor…
zsuraski authored Aug 15, 2000
624 } else {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
625 zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
7795aca @zsuraski Fix warning issue (compile errors inside require()'d files were incor…
zsuraski authored Aug 15, 2000
626 }
c06692e @zsuraski The patch we promised - redesigned the compilation/execution API:
zsuraski authored Aug 9, 2000
627 } else {
998204e @dstogov Separate common part of compile_file() and compile_string() into zend…
dstogov authored Nov 12, 2015
628 op_array = zend_compile(ZEND_USER_FUNCTION);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
629 }
b625661 @laruence Remove unnecessary branch/temp variable
laruence authored Sep 9, 2014
630
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
631 zend_restore_lexical_state(&original_lex_state);
b625661 @laruence Remove unnecessary branch/temp variable
laruence authored Sep 9, 2014
632 return op_array;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
633 }
634
635
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
636 zend_op_array *compile_filename(int type, zval *filename)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
637 {
638 zend_file_handle file_handle;
639 zval tmp;
640 zend_op_array *retval;
2fa8d67 @dstogov Use zend_string* instead of char* for opened_patch handling. Avoid re…
dstogov authored Mar 3, 2015
641 zend_string *opened_path = NULL;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
642
d8099d0 @dstogov Changed data layout to allow more efficient operations
dstogov authored Apr 2, 2014
643 if (Z_TYPE_P(filename) != IS_STRING) {
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
644 tmp = *filename;
645 zval_copy_ctor(&tmp);
646 convert_to_string(&tmp);
647 filename = &tmp;
648 }
d2950ac @nikic Make use of Z_*VAL and ZVAL_* in language scanner
nikic authored Sep 13, 2013
649 file_handle.filename = Z_STRVAL_P(filename);
9baad80 @zsuraski - Break the zend->PHP dependency introduced by the .php extension for…
zsuraski authored Dec 4, 1999
650 file_handle.free_filename = 0;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
651 file_handle.type = ZEND_HANDLE_FILENAME;
b92d70a php_fopen_wrapper_for_zend() does *NOT* insert the opened files into …
Thies C. Arntzen authored Dec 2, 1999
652 file_handle.opened_path = NULL;
ec58143 @rlerdorf Valgrind is unhappy that this is not initialized
rlerdorf authored Jul 18, 2005
653 file_handle.handle.fp = NULL;
67b4b3a @zsuraski - require() of a dynamic expression now has the standard require() se…
zsuraski authored Dec 23, 1999
654
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
655 retval = zend_compile_file(&file_handle, type);
e52aac9 @wez Implement simple stream support in the ZE scanners.
wez authored Feb 18, 2003
656 if (retval && file_handle.handle.stream.handle) {
d704357 MFZE1 (20214).
Ilia Alshanetsky authored Nov 2, 2002
657 if (!file_handle.opened_path) {
2fa8d67 @dstogov Use zend_string* instead of char* for opened_patch handling. Avoid re…
dstogov authored Mar 3, 2015
658 file_handle.opened_path = opened_path = zend_string_copy(Z_STR_P(filename));
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
659 }
660
2fa8d67 @dstogov Use zend_string* instead of char* for opened_patch handling. Avoid re…
dstogov authored Mar 3, 2015
661 zend_hash_add_empty_element(&EG(included_files), file_handle.opened_path);
729e470 @sebastianbergmann Fix build.
sebastianbergmann authored Feb 1, 2003
662
7936a86 MFZE1
Ilia Alshanetsky authored Nov 2, 2002
663 if (opened_path) {
2fa8d67 @dstogov Use zend_string* instead of char* for opened_patch handling. Avoid re…
dstogov authored Mar 3, 2015
664 zend_string_release(opened_path);
7936a86 MFZE1
Ilia Alshanetsky authored Nov 2, 2002
665 }
d84c5a2 @andigutmans - Updated included_files() also for plain include()/require().
andigutmans authored Oct 5, 2000
666 }
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
667 zend_destroy_file_handle(&file_handle);
67b4b3a @zsuraski - require() of a dynamic expression now has the standard require() se…
zsuraski authored Dec 23, 1999
668
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
669 if (filename==&tmp) {
670 zval_dtor(&tmp);
671 }
672 return retval;
673 }
674
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
675 ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
676 {
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
677 char *buf;
557994d @dstogov Use better data structures (incomplete)
dstogov authored Feb 19, 2014
678 size_t size, old_len;
257853c @laruence Fixed memory leak in ext/standard/tests/strings/005.php
laruence authored Feb 22, 2014
679 zend_string *new_compiled_filename;
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
680
96b1c21 @nikic Provide more macros for handling of interned strings
nikic authored Sep 13, 2013
681 /* enforce ZEND_MMAP_AHEAD trailing NULLs for flex... */
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
682 old_len = Z_STRLEN_P(str);
d146d15 @dstogov Optimize zend_string_realloc() add more specialized versions zend_str…
dstogov authored Mar 20, 2015
683 Z_STR_P(str) = zend_string_extend(Z_STR_P(str), old_len + ZEND_MMAP_AHEAD, 0);
76cc99f @dstogov Refactored ZVAL flags usage to simplify various checks (e.g. Z_REFCOU…
dstogov authored Apr 3, 2014
684 Z_TYPE_INFO_P(str) = IS_STRING_EX;
557994d @dstogov Use better data structures (incomplete)
dstogov authored Feb 18, 2014
685 memset(Z_STRVAL_P(str) + old_len, 0, ZEND_MMAP_AHEAD + 1);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
686
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
687 SCNG(yy_in) = NULL;
f6f0f65 @felipensp - Fixed bug #48930 (__COMPILER_HALT_OFFSET__ incorrect in PHP >= 5.3)
felipensp authored Jun 30, 2010
688 SCNG(yy_start) = NULL;
ab9dcec @fujimoto - added script encoding support to Zend Engine 2.
fujimoto authored Aug 11, 2003
689
d2950ac @nikic Make use of Z_*VAL and ZVAL_* in language scanner
nikic authored Sep 13, 2013
690 buf = Z_STRVAL_P(str);
557994d @dstogov Use better data structures (incomplete)
dstogov authored Feb 18, 2014
691 size = old_len;
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
692
ab93d8c Added multibyte suppport by default. Previosly php had to be compiled…
Dmitry Stogov authored Nov 24, 2010
693 if (CG(multibyte)) {
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored Sep 13, 2011
694 SCNG(script_org) = (unsigned char*)buf;
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
695 SCNG(script_org_size) = size;
696 SCNG(script_filtered) = NULL;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
697
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
698 zend_multibyte_set_filter(zend_multibyte_get_internal_encoding());
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
699
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
700 if (SCNG(input_filter)) {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
701 if ((size_t)-1 == SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size))) {
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
702 zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
703 "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
704 }
e43ff13 Fixed ZE specific compile warnings (Bug #55629)
Dmitry Stogov authored Sep 13, 2011
705 buf = (char*)SCNG(script_filtered);
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
706 size = SCNG(script_filtered_size);
ab93d8c Added multibyte suppport by default. Previosly php had to be compiled…
Dmitry Stogov authored Nov 24, 2010
707 }
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
708 }
709
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
710 yy_scan_buffer(buf, (unsigned int)size);
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
711
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
712 new_compiled_filename = zend_string_init(filename, strlen(filename), 0);
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
713 zend_set_compiled_filename(new_compiled_filename);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
714 zend_string_release(new_compiled_filename);
3cda6a7 @zsuraski Allow the symbol_table to be passed to call_user_function_ex()
zsuraski authored Jun 17, 2000
715 CG(zend_lineno) = 1;
b392fe4 @zsuraski MFZE1
zsuraski authored Aug 28, 2001
716 CG(increment_lineno) = 0;
2208447 @smalyshev Fix bug #64936 - clean doc comment state at the beginning and end of …
smalyshev authored Jun 16, 2013
717 RESET_DOC_COMMENT();
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
718 return SUCCESS;
719 }
720
721
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
722 ZEND_API size_t zend_get_scanned_file_offset(void)
d33500e @zsuraski Thought I committed it ages ago... Anyway, without further delays, th…
zsuraski authored Jun 4, 2005
723 {
f241995 @felipensp - MF5.3: Reverted fix for bug #48930 (due binary compatibility breakage)
felipensp authored Jun 30, 2010
724 size_t offset = SCNG(yy_cursor) - SCNG(yy_start);
b9eaa80 - SCNG(input_filter) can be null if the script encoding is idential to
Moriyoshi Koizumi authored Jul 28, 2008
725 if (SCNG(input_filter)) {
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
726 size_t original_offset = offset, length = 0;
727 do {
b9eaa80 - SCNG(input_filter) can be null if the script encoding is idential to
Moriyoshi Koizumi authored Jul 28, 2008
728 unsigned char *p = NULL;
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
729 if ((size_t)-1 == SCNG(input_filter)(&p, &length, SCNG(script_org), offset)) {
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
730 return (size_t)-1;
b9eaa80 - SCNG(input_filter) can be null if the script encoding is idential to
Moriyoshi Koizumi authored Jul 28, 2008
731 }
732 efree(p);
733 if (length > original_offset) {
734 offset--;
735 } else if (length < original_offset) {
736 offset++;
737 }
738 } while (original_offset != length);
739 }
1782511 - WS
Moriyoshi Koizumi authored Jul 28, 2008
740 return offset;
d33500e @zsuraski Thought I committed it ages ago... Anyway, without further delays, th…
zsuraski authored Jun 4, 2005
741 }
742
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
743 zend_op_array *compile_string(zval *source_string, char *filename)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
744 {
745 zend_lex_state original_lex_state;
b7876e7 @nikic eval() with parse error uses clean shutdown now
nikic authored Aug 26, 2014
746 zend_op_array *op_array = NULL;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
747 zval tmp;
748
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
749 if (Z_STRLEN_P(source_string)==0) {
473d1d7 @zsuraski * Fix a bug that occured in case of parse errors. We need to restore …
zsuraski authored May 11, 1999
750 return NULL;
751 }
b6197bc @zsuraski Maintain a state of whether we're compiling and/or executing
zsuraski authored Feb 4, 2000
752
557994d @dstogov Use better data structures (incomplete)
dstogov authored Feb 18, 2014
753 ZVAL_DUP(&tmp, source_string);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
754 convert_to_string(&tmp);
755 source_string = &tmp;
b7a7b1a @smalyshev trailing whitespace removal
smalyshev authored Jan 3, 2015
756
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
757 zend_save_lexical_state(&original_lex_state);
758 if (zend_prepare_string_for_scanning(source_string, filename) == SUCCESS) {
b7876e7 @nikic eval() with parse error uses clean shutdown now
nikic authored Aug 26, 2014
759 BEGIN(ST_IN_SCRIPTING);
998204e @dstogov Separate common part of compile_file() and compile_string() into zend…
dstogov authored Nov 12, 2015
760 op_array = zend_compile(ZEND_EVAL_CODE);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
761 }
b7876e7 @nikic eval() with parse error uses clean shutdown now
nikic authored Aug 26, 2014
762
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
763 zend_restore_lexical_state(&original_lex_state);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
764 zval_dtor(&tmp);
998204e @dstogov Separate common part of compile_file() and compile_string() into zend…
dstogov authored Nov 12, 2015
765
b7876e7 @nikic eval() with parse error uses clean shutdown now
nikic authored Aug 26, 2014
766 return op_array;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
767 }
768
769
1aa2c5c @zsuraski Ok, call me crazy, because I probably am.
zsuraski authored Apr 23, 1999
770 BEGIN_EXTERN_C()
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
771 int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
772 {
773 zend_lex_state original_lex_state;
774 zend_file_handle file_handle;
775
776 file_handle.type = ZEND_HANDLE_FILENAME;
777 file_handle.filename = filename;
9baad80 @zsuraski - Break the zend->PHP dependency introduced by the .php extension for…
zsuraski authored Dec 4, 1999
778 file_handle.free_filename = 0;
0d7e971 revert my last patch - WARNING: we leak fd's again.
Thies C. Arntzen authored Dec 3, 1999
779 file_handle.opened_path = NULL;
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
780 zend_save_lexical_state(&original_lex_state);
781 if (open_file_for_scanning(&file_handle)==FAILURE) {
782 zend_message_dispatcher(ZMSG_FAILED_HIGHLIGHT_FOPEN, filename);
783 zend_restore_lexical_state(&original_lex_state);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
784 return FAILURE;
785 }
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
786 zend_highlight(syntax_highlighter_ini);
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
787 if (SCNG(script_filtered)) {
788 efree(SCNG(script_filtered));
789 SCNG(script_filtered) = NULL;
790 }
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
791 zend_destroy_file_handle(&file_handle);
792 zend_restore_lexical_state(&original_lex_state);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
793 return SUCCESS;
794 }
795
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
796 int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
797 {
798 zend_lex_state original_lex_state;
799 zval tmp = *str;
800
801 str = &tmp;
802 zval_copy_ctor(str);
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
803 zend_save_lexical_state(&original_lex_state);
804 if (zend_prepare_string_for_scanning(str, str_name)==FAILURE) {
805 zend_restore_lexical_state(&original_lex_state);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
806 return FAILURE;
807 }
7c3bdf4 Fixed bug #34782 (token_get_all() gives wrong result)
Dmitry Stogov authored Oct 21, 2005
808 BEGIN(INITIAL);
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
809 zend_highlight(syntax_highlighter_ini);
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
810 if (SCNG(script_filtered)) {
811 efree(SCNG(script_filtered));
812 SCNG(script_filtered) = NULL;
813 }
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
814 zend_restore_lexical_state(&original_lex_state);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
815 zval_dtor(str);
816 return SUCCESS;
817 }
818
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
819 ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding)
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
820 {
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
821 size_t length;
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
822 unsigned char *new_yy_start;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
823
824 /* convert and set */
825 if (!SCNG(input_filter)) {
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
826 if (SCNG(script_filtered)) {
827 efree(SCNG(script_filtered));
828 SCNG(script_filtered) = NULL;
829 }
830 SCNG(script_filtered_size) = 0;
cdb9ee0 Fix zend.multibyte oddities. Hope this will address all the known pro…
Moriyoshi Koizumi authored Mar 6, 2011
831 length = SCNG(script_org_size);
832 new_yy_start = SCNG(script_org);
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
833 } else {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
834 if ((size_t)-1 == SCNG(input_filter)(&new_yy_start, &length, SCNG(script_org), SCNG(script_org_size))) {
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
835 zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
836 "encoding \"%s\" to a compatible encoding", zend_multibyte_get_encoding_name(LANG_SCNG(script_encoding)));
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
837 }
a9599c9 @dstogov Fixed memory leak
dstogov authored Apr 10, 2014
838 if (SCNG(script_filtered)) {
839 efree(SCNG(script_filtered));
840 }
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
841 SCNG(script_filtered) = new_yy_start;
842 SCNG(script_filtered_size) = length;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
843 }
844
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
845 SCNG(yy_cursor) = new_yy_start + (SCNG(yy_cursor) - SCNG(yy_start));
846 SCNG(yy_marker) = new_yy_start + (SCNG(yy_marker) - SCNG(yy_start));
847 SCNG(yy_text) = new_yy_start + (SCNG(yy_text) - SCNG(yy_start));
e2d4d70 @nikic Fix yy_limit computation after encoding switch
nikic authored Sep 11, 2014
848 SCNG(yy_limit) = new_yy_start + length;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
849
a304a0f - Avoid allocating extra buffers. This makes parsing with zend.multib…
Moriyoshi Koizumi authored Dec 20, 2010
850 SCNG(yy_start) = new_yy_start;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
851 }
852
853
f9b26bc @dstogov Cleanup (2-nd round)
dstogov authored Apr 15, 2014
854 // TODO: avoid reallocation ???
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
855 # define zend_copy_value(zendlval, yytext, yyleng) \
856 if (SCNG(output_filter)) { \
4f42ed3 - Revived zend multibyte
Moriyoshi Koizumi authored Jul 24, 2008
857 size_t sz = 0; \
8eb8d12 @dstogov Fixed suppor for multibyte encoding
dstogov authored Apr 10, 2014
858 char *s = NULL; \
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
859 SCNG(output_filter)((unsigned char **)&s, &sz, (unsigned char *)yytext, (size_t)yyleng); \
8eb8d12 @dstogov Fixed suppor for multibyte encoding
dstogov authored Apr 10, 2014
860 ZVAL_STRINGL(zendlval, s, sz); \
861 efree(s); \
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
862 } else { \
f4cfaf3 @dstogov Use better data structures (incomplete)
dstogov authored Feb 10, 2014
863 ZVAL_STRINGL(zendlval, yytext, yyleng); \
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
864 }
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
865
a8bf1c5 @nikic Throw ParseException from lexer
nikic authored Mar 21, 2015
866 static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type)
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
867 {
868 register char *s, *t;
869 char *end;
870
f4cfaf3 @dstogov Use better data structures (incomplete)
dstogov authored Feb 10, 2014
871 ZVAL_STRINGL(zendlval, str, len);
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
872
873 /* convert escape sequences */
d2950ac @nikic Make use of Z_*VAL and ZVAL_* in language scanner
nikic authored Sep 13, 2013
874 s = t = Z_STRVAL_P(zendlval);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
875 end = s+Z_STRLEN_P(zendlval);
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
876 while (s<end) {
877 if (*s=='\\') {
878 s++;
c83d916 MFH: Restore end check for "escape" strings
Matt Wilmas authored May 10, 2008
879 if (s >= end) {
880 *t++ = '\\';
881 break;
882 }
c4e406d MFH: Fix loss of backslash at end of heredoc; For bug #44830 (Very mi…
Matt Wilmas authored May 9, 2008
883
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
884 switch(*s) {
885 case 'n':
886 *t++ = '\n';
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
887 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
888 break;
889 case 'r':
890 *t++ = '\r';
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
891 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
892 break;
893 case 't':
894 *t++ = '\t';
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
895 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
896 break;
8ff3149 Fixed bug #42590 (Make the engine recornize \v and \f escape sequences)
Ilia Alshanetsky authored Sep 9, 2007
897 case 'f':
898 *t++ = '\f';
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
899 Z_STRLEN_P(zendlval)--;
8ff3149 Fixed bug #42590 (Make the engine recornize \v and \f escape sequences)
Ilia Alshanetsky authored Sep 9, 2007
900 break;
901 case 'v':
902 *t++ = '\v';
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
903 Z_STRLEN_P(zendlval)--;
8ff3149 Fixed bug #42590 (Make the engine recornize \v and \f escape sequences)
Ilia Alshanetsky authored Sep 9, 2007
904 break;
3970865 @felipensp - Fixed bug #60350 (No string escape code for ESC (ascii 27), normall…
felipensp authored Nov 30, 2011
905 case 'e':
ce2cd89 @KalleZ Replace references to PHP_WIN32 and TSRM_WIN32 with ZEND_WIN32 in Zen…
KalleZ authored Jul 4, 2015
906 #ifdef ZEND_WIN32
3120387 @felipensp - Changed last commit to use VK_ESCAPE on Windows
felipensp authored Apr 30, 2012
907 *t++ = VK_ESCAPE;
cc5b995 @felipensp - Fixed bug #61827 (incorrect \e processing on Windows) patch by: ab@…
felipensp authored Apr 29, 2012
908 #else
3970865 @felipensp - Fixed bug #60350 (No string escape code for ESC (ascii 27), normall…
felipensp authored Nov 30, 2011
909 *t++ = '\e';
cc5b995 @felipensp - Fixed bug #61827 (incorrect \e processing on Windows) patch by: ab@…
felipensp authored Apr 29, 2012
910 #endif
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
911 Z_STRLEN_P(zendlval)--;
3970865 @felipensp - Fixed bug #60350 (No string escape code for ESC (ascii 27), normall…
felipensp authored Nov 30, 2011
912 break;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
913 case '"':
914 case '`':
915 if (*s != quote_type) {
916 *t++ = '\\';
917 *t++ = *s;
918 break;
919 }
920 case '\\':
921 case '$':
922 *t++ = *s;
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
923 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
924 break;
925 case 'x':
926 case 'X':
927 if (ZEND_IS_HEX(*(s+1))) {
928 char hex_buf[3] = { 0, 0, 0 };
929
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
930 Z_STRLEN_P(zendlval)--; /* for the 'x' */
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
931
932 hex_buf[0] = *(++s);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
933 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
934 if (ZEND_IS_HEX(*(s+1))) {
935 hex_buf[1] = *(++s);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
936 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
937 }
4d997f6 @weltling master renames phase 3
weltling authored Aug 25, 2014
938 *t++ = (char) ZEND_STRTOL(hex_buf, NULL, 16);
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
939 } else {
940 *t++ = '\\';
941 *t++ = *s;
942 }
943 break;
bae46f3 @TazeTSchnitzel Unicode Codepoint Escape Syntax
TazeTSchnitzel authored Dec 19, 2014
944 /* UTF-8 codepoint escape, format: /\\u\{\x+\}/ */
945 case 'u':
946 {
947 /* cache where we started so we can parse after validating */
948 char *start = s + 1;
949 size_t len = 0;
950 zend_bool valid = 1;
951 unsigned long codepoint;
6b59b27 @weltling C89 compat
weltling authored Dec 19, 2014
952 size_t byte_len = 0;
bae46f3 @TazeTSchnitzel Unicode Codepoint Escape Syntax
TazeTSchnitzel authored Dec 19, 2014
953
954 if (*start != '{') {
955 /* we silently let this pass to avoid breaking code
956 * with JSON in string literals (e.g. "\"\u202e\""
957 */
958 *t++ = '\\';
959 *t++ = 'u';
960 break;
961 } else {
962 /* on the other hand, invalid \u{blah} errors */
963 s++;
964 len++;
965 s++;
966 while (*s != '}') {
967 if (!ZEND_IS_HEX(*s)) {
968 valid = 0;
969 break;
970 } else {
971 len++;
972 }
973 s++;
974 }
975 if (*s == '}') {
976 valid = 1;
977 len++;
978 }
979 }
980
981 /* \u{} is invalid */
982 if (len <= 2) {
983 valid = 0;
984 }
985
986 if (!valid) {
ed1b648 @trowski Switch position of ce in exception ce variable names
trowski authored Jul 3, 2015
987 zend_throw_exception(zend_ce_parse_error,
a1a83bf @trowski Switch code on thrown TypeError and ParseError to 0, update related t…
trowski authored Jul 7, 2015
988 "Invalid UTF-8 codepoint escape sequence", 0);
a8bf1c5 @nikic Throw ParseException from lexer
nikic authored Mar 21, 2015
989 zval_ptr_dtor(zendlval);
d91aad5 @nikic Fix bug #69430
nikic authored Jul 9, 2015
990 ZVAL_UNDEF(zendlval);
a8bf1c5 @nikic Throw ParseException from lexer
nikic authored Mar 21, 2015
991 return FAILURE;
bae46f3 @TazeTSchnitzel Unicode Codepoint Escape Syntax
TazeTSchnitzel authored Dec 19, 2014
992 }
993
994 errno = 0;
995 codepoint = strtoul(start + 1, NULL, 16);
996
997 /* per RFC 3629, UTF-8 can only represent 21 bits */
998 if (codepoint > 0x10FFFF || errno) {
ed1b648 @trowski Switch position of ce in exception ce variable names
trowski authored Jul 3, 2015
999 zend_throw_exception(zend_ce_parse_error,
a1a83bf @trowski Switch code on thrown TypeError and ParseError to 0, update related t…
trowski authored Jul 7, 2015
1000 "Invalid UTF-8 codepoint escape sequence: Codepoint too large", 0);
a8bf1c5 @nikic Throw ParseException from lexer
nikic authored Mar 21, 2015
1001 zval_ptr_dtor(zendlval);
d91aad5 @nikic Fix bug #69430
nikic authored Jul 9, 2015
1002 ZVAL_UNDEF(zendlval);
a8bf1c5 @nikic Throw ParseException from lexer
nikic authored Mar 21, 2015
1003 return FAILURE;
bae46f3 @TazeTSchnitzel Unicode Codepoint Escape Syntax
TazeTSchnitzel authored Dec 19, 2014
1004 }
1005
1006 /* based on https://en.wikipedia.org/wiki/UTF-8#Sample_code */
1007 if (codepoint < 0x80) {
1008 byte_len = 1;
1009 *t++ = codepoint;
1010 } else if (codepoint <= 0x7FF) {
1011 byte_len = 2;
1012 *t++ = (codepoint >> 6) + 0xC0;
1013 *t++ = (codepoint & 0x3F) + 0x80;
1014 } else if (codepoint <= 0xFFFF) {
1015 byte_len = 3;
1016 *t++ = (codepoint >> 12) + 0xE0;
1017 *t++ = ((codepoint >> 6) & 0x3F) + 0x80;
1018 *t++ = (codepoint & 0x3F) + 0x80;
1019 } else if (codepoint <= 0x10FFFF) {
1020 byte_len = 4;
1021 *t++ = (codepoint >> 18) + 0xF0;
1022 *t++ = ((codepoint >> 12) & 0x3F) + 0x80;
1023 *t++ = ((codepoint >> 6) & 0x3F) + 0x80;
1024 *t++ = (codepoint & 0x3F) + 0x80;
1025 }
1026
1027 Z_STRLEN_P(zendlval) -= 2; /* \u */
1028 Z_STRLEN_P(zendlval) -= (len - byte_len);
1029 }
1030 break;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
1031 default:
1032 /* check for an octal */
1033 if (ZEND_IS_OCT(*s)) {
1034 char octal_buf[4] = { 0, 0, 0, 0 };
1035
1036 octal_buf[0] = *s;
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
1037 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
1038 if (ZEND_IS_OCT(*(s+1))) {
1039 octal_buf[1] = *(++s);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
1040 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
1041 if (ZEND_IS_OCT(*(s+1))) {
1042 octal_buf[2] = *(++s);
c3e3c98 @weltling master renames phase 1
weltling authored Aug 25, 2014
1043 Z_STRLEN_P(zendlval)--;
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
1044 }
1045 }
4d997f6 @weltling master renames phase 3
weltling authored Aug 25, 2014
1046 *t++ = (char) ZEND_STRTOL(octal_buf, NULL, 8);
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
1047 } else {
1048 *t++ = '\\';
1049 *t++ = *s;
1050 }
1051 break;
1052 }
1053 } else {
1054 *t++ = *s;
1055 }
1056
1057 if (*s == '\n' || (*s == '\r' && (*(s+1) != '\n'))) {
1058 CG(zend_lineno)++;
1059 }
1060 s++;
1061 }
1062 *t = 0;
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
1063 if (SCNG(output_filter)) {
4f42ed3 - Revived zend multibyte
Moriyoshi Koizumi authored Jul 24, 2008
1064 size_t sz = 0;
506f6a4 @laruence Refactor mbstring (incompleted)
laruence authored Mar 24, 2014
1065 unsigned char *str;
f9b26bc @dstogov Cleanup (2-nd round)
dstogov authored Apr 15, 2014
1066 // TODO: avoid realocation ???
d2950ac @nikic Make use of Z_*VAL and ZVAL_* in language scanner
nikic authored Sep 13, 2013
1067 s = Z_STRVAL_P(zendlval);
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
1068 SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval));
506f6a4 @laruence Refactor mbstring (incompleted)
laruence authored Mar 24, 2014
1069 zval_ptr_dtor(zendlval);
d2a3bf9 @nikic Fix compiler warnings
nikic authored Aug 25, 2014
1070 ZVAL_STRINGL(zendlval, (char *) str, sz);
506f6a4 @laruence Refactor mbstring (incompleted)
laruence authored Mar 24, 2014
1071 efree(str);
c3286f3 implemented again zend-multibyte for PHP 5.3
Rui Hirokawa authored Jun 29, 2008
1072 }
a8bf1c5 @nikic Throw ParseException from lexer
nikic authored Mar 21, 2015
1073 return SUCCESS;
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
1074 }
1075
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1076 static zend_always_inline int emit_token(int token, int token_line)
1077 {
1078 if(SCNG(on_event)) SCNG(on_event)(ON_TOKEN, token, token_line);
1079
1080 return token;
1081 }
1082
1083 #define RETURN_TOKEN(token) return emit_token(token, start_line);
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
1084
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
1085 int lex_scan(zval *zendlval)
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
1086 {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1087
1088 int start_line = CG(zend_lineno);
1089
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
1090 restart:
1091 SCNG(yy_text) = YYCURSOR;
1092
1093 /*!re2c
0893c3e - Another re2c version bump and scanner regeneration
Marcus Boerger authored Mar 22, 2008
1094 re2c:yyfill:check = 0;
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1095 LNUM [0-9]+
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
1096 DNUM ([0-9]*"."[0-9]+)|([0-9]+"."[0-9]*)
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1097 EXPONENT_DNUM (({LNUM}|{DNUM})[eE][+-]?{LNUM})
1098 HNUM "0x"[0-9a-fA-F]+
4d0f1bf @pierrejoye - add binary suport, FR #50638, as defined in RFC https://wiki.php.ne…
pierrejoye authored Jul 27, 2011
1099 BNUM "0b"[01]+
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1100 LABEL [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
1101 WHITESPACE [ \n\r\t]+
1102 TABS_AND_SPACES [ \t]*
1103 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
09034cf MFH: Implemented manual scanning for strings/comments, plus misc. fixes
Matt Wilmas authored May 5, 2009
1104 ANY_CHAR [^]
62bec3a @andigutmans - Handle MAC OS X \r line endings
andigutmans authored May 2, 2001
1105 NEWLINE ("\r"|"\n"|"\r\n")
ddcf7a2 Added NEWDOC
Dmitry Stogov authored Feb 12, 2008
1106
af31602 - Rewrite scanner to be based on re2c instead of flex
Marcus Boerger authored Mar 16, 2008
1107 /* compute yyleng before each rule */
1108 <!*> := yyleng = YYCURSOR - SCNG(yy_text);
1109
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1110 <ST_IN_SCRIPTING>"exit" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1111 RETURN_TOKEN(T_EXIT);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1112 }
1113
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1114 <ST_IN_SCRIPTING>"die" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1115 RETURN_TOKEN(T_EXIT);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1116 }
1117
983be5c @andigutmans - ATTENTION: Finally nuke old_function and cfunction. I think it is time
andigutmans authored Nov 5, 2002
1118 <ST_IN_SCRIPTING>"function" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1119 RETURN_TOKEN(T_FUNCTION);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1120 }
1121
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1122 <ST_IN_SCRIPTING>"const" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1123 RETURN_TOKEN(T_CONST);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1124 }
1125
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1126 <ST_IN_SCRIPTING>"return" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1127 RETURN_TOKEN(T_RETURN);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1128 }
1129
b4a142a @bwoebi Added yield from operator
bwoebi authored Mar 7, 2015
1130 <ST_IN_SCRIPTING>"yield"{WHITESPACE}"from" {
860dc17 @nikic Fixed bug #71724
nikic authored Mar 6, 2016
1131 HANDLE_NEWLINES(yytext, yyleng);
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1132 RETURN_TOKEN(T_YIELD_FROM);
b4a142a @bwoebi Added yield from operator
bwoebi authored Mar 6, 2015
1133 }
1134
9b101ac @nikic Add T_YIELD "yield" keyword
nikic authored May 15, 2012
1135 <ST_IN_SCRIPTING>"yield" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1136 RETURN_TOKEN(T_YIELD);
9b101ac @nikic Add T_YIELD "yield" keyword
nikic authored May 15, 2012
1137 }
1138
29f5dbe @andigutmans - Initial support for exceptions.
andigutmans authored Aug 30, 2001
1139 <ST_IN_SCRIPTING>"try" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1140 RETURN_TOKEN(T_TRY);
29f5dbe @andigutmans - Initial support for exceptions.
andigutmans authored Aug 30, 2001
1141 }
1142
1143 <ST_IN_SCRIPTING>"catch" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1144 RETURN_TOKEN(T_CATCH);
29f5dbe @andigutmans - Initial support for exceptions.
andigutmans authored Aug 30, 2001
1145 }
1146
80d5ae3 @laruence Implemented 'finally' keywords for php
laruence authored Aug 13, 2012
1147 <ST_IN_SCRIPTING>"finally" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1148 RETURN_TOKEN(T_FINALLY);
80d5ae3 @laruence Implemented 'finally' keywords for php
laruence authored Aug 13, 2012
1149 }
1150
29f5dbe @andigutmans - Initial support for exceptions.
andigutmans authored Aug 30, 2001
1151 <ST_IN_SCRIPTING>"throw" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1152 RETURN_TOKEN(T_THROW);
29f5dbe @andigutmans - Initial support for exceptions.
andigutmans authored Aug 30, 2001
1153 }
1154
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1155 <ST_IN_SCRIPTING>"if" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1156 RETURN_TOKEN(T_IF);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1157 }
1158
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1159 <ST_IN_SCRIPTING>"elseif" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1160 RETURN_TOKEN(T_ELSEIF);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1161 }
1162
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1163 <ST_IN_SCRIPTING>"endif" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1164 RETURN_TOKEN(T_ENDIF);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1165 }
1166
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1167 <ST_IN_SCRIPTING>"else" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1168 RETURN_TOKEN(T_ELSE);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1169 }
1170
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1171 <ST_IN_SCRIPTING>"while" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1172 RETURN_TOKEN(T_WHILE);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1173 }
1174
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1175 <ST_IN_SCRIPTING>"endwhile" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1176 RETURN_TOKEN(T_ENDWHILE);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1177 }
1178
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1179 <ST_IN_SCRIPTING>"do" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1180 RETURN_TOKEN(T_DO);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1181 }
1182
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1183 <ST_IN_SCRIPTING>"for" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1184 RETURN_TOKEN(T_FOR);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1185 }
1186
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1187 <ST_IN_SCRIPTING>"endfor" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1188 RETURN_TOKEN(T_ENDFOR);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1189 }
1190
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1191 <ST_IN_SCRIPTING>"foreach" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1192 RETURN_TOKEN(T_FOREACH);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1193 }
1194
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1195 <ST_IN_SCRIPTING>"endforeach" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1196 RETURN_TOKEN(T_ENDFOREACH);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1197 }
1198
fafbf6d @zsuraski - Implement declare() with declarables framework
zsuraski authored Jan 24, 2000
1199 <ST_IN_SCRIPTING>"declare" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1200 RETURN_TOKEN(T_DECLARE);
fafbf6d @zsuraski - Implement declare() with declarables framework
zsuraski authored Jan 24, 2000
1201 }
1202
1203 <ST_IN_SCRIPTING>"enddeclare" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1204 RETURN_TOKEN(T_ENDDECLARE);
fafbf6d @zsuraski - Implement declare() with declarables framework
zsuraski authored Jan 24, 2000
1205 }
1206
c073b76 @andigutmans - Change "is" to "instanceof" as it explains better what the operator…
andigutmans authored Jan 14, 2003
1207 <ST_IN_SCRIPTING>"instanceof" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1208 RETURN_TOKEN(T_INSTANCEOF);
82c72f2 @- Adding 'is' operator that can be used to check the type of a varia…
Andrei Zmievski authored Jul 30, 2002
1209 }
1210
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1211 <ST_IN_SCRIPTING>"as" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1212 RETURN_TOKEN(T_AS);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1213 }
1214
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1215 <ST_IN_SCRIPTING>"switch" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1216 RETURN_TOKEN(T_SWITCH);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1217 }
1218
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1219 <ST_IN_SCRIPTING>"endswitch" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1220 RETURN_TOKEN(T_ENDSWITCH);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1221 }
1222
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1223 <ST_IN_SCRIPTING>"case" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1224 RETURN_TOKEN(T_CASE);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1225 }
1226
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1227 <ST_IN_SCRIPTING>"default" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1228 RETURN_TOKEN(T_DEFAULT);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1229 }
1230
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1231 <ST_IN_SCRIPTING>"break" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1232 RETURN_TOKEN(T_BREAK);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1233 }
1234
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1235 <ST_IN_SCRIPTING>"continue" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1236 RETURN_TOKEN(T_CONTINUE);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1237 }
1238
f66f55e @felipensp MFH: Implemented "jump label" operator (limited "goto")
felipensp authored Mar 28, 2008
1239 <ST_IN_SCRIPTING>"goto" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1240 RETURN_TOKEN(T_GOTO);
f66f55e @felipensp MFH: Implemented "jump label" operator (limited "goto")
felipensp authored Mar 28, 2008
1241 }
1242
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1243 <ST_IN_SCRIPTING>"echo" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1244 RETURN_TOKEN(T_ECHO);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1245 }
1246
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1247 <ST_IN_SCRIPTING>"print" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1248 RETURN_TOKEN(T_PRINT);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1249 }
1250
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1251 <ST_IN_SCRIPTING>"class" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1252 RETURN_TOKEN(T_CLASS);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1253 }
1254
26dd849 @zsuraski Add support for interfaces
zsuraski authored Mar 5, 2003
1255 <ST_IN_SCRIPTING>"interface" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1256 RETURN_TOKEN(T_INTERFACE);
26dd849 @zsuraski Add support for interfaces
zsuraski authored Mar 5, 2003
1257 }
1258
cd6415f Implemented Traits for PHP as proposed in the RFC [TRAITS]
Stefan Marr authored Apr 22, 2010
1259 <ST_IN_SCRIPTING>"trait" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1260 RETURN_TOKEN(T_TRAIT);
cd6415f Implemented Traits for PHP as proposed in the RFC [TRAITS]
Stefan Marr authored Apr 22, 2010
1261 }
1262
f33c22c @zsuraski * Fix the comments issue. yymore() worked like a charm.
zsuraski authored May 21, 1999
1263 <ST_IN_SCRIPTING>"extends" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1264 RETURN_TOKEN(T_EXTENDS);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1265 }
1266
26dd849 @zsuraski Add support for interfaces
zsuraski authored Mar 5, 2003
1267 <ST_IN_SCRIPTING>"implements" {
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1268 RETURN_TOKEN(T_IMPLEMENTS);
26dd849 @zsuraski Add support for interfaces
zsuraski authored Mar 5, 2003
1269 }
1270
80d2409 Improved compilation of heredocs and interpolated strings. (Matt, Dmi…
Dmitry Stogov authored May 18, 2007
1271 <ST_IN_SCRIPTING>"->" {
bdeb220 @weltling first shot remove TSRMLS_* things
weltling authored Dec 13, 2014
1272 yy_push_state(ST_LOOKING_FOR_PROPERTY);
1107593 @marcioAlmada ext tokenizer port + cleanup unused lexer states
marcioAlmada authored Apr 5, 2015
1273 RETURN_TOKEN(T_OBJECT_OPERATOR);
573b460 @andigutmans Zend Library
andigutmans authored Apr 7, 1999
1274 }
1275