- Allow HEREDOC syntax with double quotes [DOC]
(http://wiki.php.net/rfc/heredoc-with-double-quotes)
This commit is contained in:
Felipe Pena 2008-04-05 23:13:21 +00:00
parent 99286928ea
commit cdf42e7638
6 changed files with 2640 additions and 2521 deletions

View File

@ -0,0 +1,12 @@
--TEST--
Heredoc with double quotes
--FILE--
<?php
$test = "foo";
$var = <<<"MYLABEL"
test: $test
MYLABEL;
echo $var;
?>
--EXPECT--
test: foo

View 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

View 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

View File

@ -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)--;

View File

@ -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 {