mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
MFB:
- Allow HEREDOC syntax with double quotes [DOC] (http://wiki.php.net/rfc/heredoc-with-double-quotes)
This commit is contained in:
parent
99286928ea
commit
cdf42e7638
12
Zend/tests/heredoc_012.phpt
Normal file
12
Zend/tests/heredoc_012.phpt
Normal file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Heredoc with double quotes
|
||||
--FILE--
|
||||
<?php
|
||||
$test = "foo";
|
||||
$var = <<<"MYLABEL"
|
||||
test: $test
|
||||
MYLABEL;
|
||||
echo $var;
|
||||
?>
|
||||
--EXPECT--
|
||||
test: foo
|
12
Zend/tests/heredoc_013.phpt
Normal file
12
Zend/tests/heredoc_013.phpt
Normal file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Heredoc with double quotes and wrong prefix
|
||||
--FILE--
|
||||
<?php
|
||||
$test = "foo";
|
||||
$var = prefix<<<"MYLABEL"
|
||||
test: $test
|
||||
MYLABEL;
|
||||
echo $var;
|
||||
?>
|
||||
--EXPECTF--
|
||||
Parse error: syntax error, unexpected T_START_HEREDOC in %sheredoc_013.php on line %d
|
12
Zend/tests/heredoc_014.phpt
Normal file
12
Zend/tests/heredoc_014.phpt
Normal file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Heredoc with double quotes syntax but missing second quote
|
||||
--FILE--
|
||||
<?php
|
||||
$test = "foo";
|
||||
$var = <<<"MYLABEL
|
||||
test: $test
|
||||
MYLABEL;
|
||||
echo $var;
|
||||
?>
|
||||
--EXPECTF--
|
||||
Parse error: syntax error, unexpected T_SL in %sheredoc_014.php on line %d
|
File diff suppressed because it is too large
Load Diff
@ -2436,11 +2436,12 @@ inline_char_handler:
|
||||
return T_BINARY_DOUBLE;
|
||||
}
|
||||
|
||||
<ST_IN_SCRIPTING>b"<<<"{TABS_AND_SPACES}{LABEL}{NEWLINE} {
|
||||
<ST_IN_SCRIPTING>b"<<<"{TABS_AND_SPACES}({LABEL}|["]{LABEL}["]){NEWLINE} {
|
||||
char *s;
|
||||
int quotes = (yytext[4] == '"') ? 2 : 0;
|
||||
CG(zend_lineno)++;
|
||||
CG(heredoc_len) = yyleng-4-1-(yytext[yyleng-2]=='\r'?1:0);
|
||||
s = yytext+4;
|
||||
CG(heredoc_len) = yyleng-4-quotes-1-(yytext[yyleng-2]=='\r'?1:0);
|
||||
s = yytext+4+(quotes ? 1 : 0);
|
||||
while ((*s == ' ') || (*s == '\t')) {
|
||||
s++;
|
||||
CG(heredoc_len)--;
|
||||
@ -2451,11 +2452,12 @@ inline_char_handler:
|
||||
}
|
||||
|
||||
|
||||
<ST_IN_SCRIPTING>"<<<"{TABS_AND_SPACES}{LABEL}{NEWLINE} {
|
||||
<ST_IN_SCRIPTING>"<<<"{TABS_AND_SPACES}({LABEL}|["]{LABEL}["]){NEWLINE} {
|
||||
char *s;
|
||||
int quotes = (yytext[3] == '"') ? 2 : 0;
|
||||
CG(zend_lineno)++;
|
||||
CG(heredoc_len) = yyleng-3-1-(yytext[yyleng-2]=='\r'?1:0);
|
||||
s = yytext+3;
|
||||
CG(heredoc_len) = yyleng-3-quotes-1-(yytext[yyleng-2]=='\r'?1:0);
|
||||
s = yytext+3+(quotes ? 1 : 0);
|
||||
while ((*s == ' ') || (*s == '\t')) {
|
||||
s++;
|
||||
CG(heredoc_len)--;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Generated by re2c 0.13.4.dev on Fri Apr 4 16:08:19 2008 */
|
||||
/* Generated by re2c 0.13.4 on Sat Apr 5 19:52:57 2008 */
|
||||
#line 3 "Zend/zend_language_scanner_defs.h"
|
||||
|
||||
enum YYCONDTYPE {
|
||||
|
Loading…
Reference in New Issue
Block a user