Browse Source

MFB:

- Allow HEREDOC syntax with double quotes [DOC]
(http://wiki.php.net/rfc/heredoc-with-double-quotes)
experimental/first_unicode_implementation
Felipe Pena 18 years ago
parent
commit
cdf42e7638
  1. 12
      Zend/tests/heredoc_012.phpt
  2. 12
      Zend/tests/heredoc_013.phpt
  3. 12
      Zend/tests/heredoc_014.phpt
  4. 4277
      Zend/zend_language_scanner.c
  5. 14
      Zend/zend_language_scanner.l
  6. 2
      Zend/zend_language_scanner_defs.h

12
Zend/tests/heredoc_012.phpt

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

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

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

4277
Zend/zend_language_scanner.c
File diff suppressed because it is too large
View File

14
Zend/zend_language_scanner.l

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

2
Zend/zend_language_scanner_defs.h

@ -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…
Cancel
Save