]> granicus.if.org Git - php/commitdiff
Impoved error reporting on parser errors (Matt, Dmitry)
authorDmitry Stogov <dmitry@php.net>
Thu, 24 May 2007 08:56:50 +0000 (08:56 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 24 May 2007 08:56:50 +0000 (08:56 +0000)
Zend/zend_language_scanner.l

index 718867bda483f14ee41f74ce672eef58a4aa08ca..e252411c13b4be7bb399e1286a9de2f1f8d9c0de 100644 (file)
@@ -2186,14 +2186,17 @@ HEREDOC_CHARS       ("{"*([^$\n\r\\{]|("\\"[^\n\r]))|{HEREDOC_LITERAL_DOLLAR}|({
        return ']';
 }
 
-<ST_VAR_OFFSET>{TOKENS}|[{}] {
+<ST_VAR_OFFSET>{TOKENS}|[{}"`] {
        /* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */
        return yytext[0];
 }
 
-<ST_VAR_OFFSET>[ \n\r\t'"`\\#] {
+<ST_VAR_OFFSET>[ \n\r\t\\'#] {
+       /* Invalid rule to return a more explicit parse error with proper line number */
        yyless(0);
        yy_pop_state(TSRMLS_C);
+       ZVAL_EMPTY_TEXT(zendlval); /* Empty since it won't be used */
+       return T_ENCAPSED_AND_WHITESPACE;
 }
 
 <ST_IN_SCRIPTING>{LABEL} {
@@ -2483,8 +2486,8 @@ HEREDOC_CHARS       ("{"*([^$\n\r\\{]|("\\"[^\n\r]))|{HEREDOC_LITERAL_DOLLAR}|({
                        return T_ENCAPSED_AND_WHITESPACE;
                }
        } else {
-               /* Go back to end of label, so there's something to match again in case
-                * there's a variable at the beginning of the next line */
+               /* Go back to end of label, so the next match works correctly in case of
+                * a variable or another label at the beginning of the next line */
                yyless(yyleng - 1);
                yymore();
        }