parser: fix string handling
authorMichael Wallner <mike@php.net>
Fri, 31 Mar 2017 08:20:38 +0000 (10:20 +0200)
committerMichael Wallner <mike@php.net>
Wed, 3 May 2017 06:47:54 +0000 (08:47 +0200)
src/parser.re

index 2cdb1e84bf0dbcc59b5b0f7eabe86376dbca024b..d5d10787c1a1a42d8e71b66e65b0f14f531d019a 100644 (file)
@@ -455,19 +455,40 @@ struct psi_plist *psi_parser_scan(struct psi_parser *P, struct psi_parser_input
        character: ;
                /*!re2c
 
-               "'"             { if (escaped) goto character; cur -= 1; NEWTOKEN(PSI_T_QUOTED_CHAR); cur += 1; token->flags = char_width; goto start; }
                EOL             { NEWLINE(); goto character; }
                "\\"    { escaped = !escaped; }
-               *               { goto character; }
+               "'"             {
+                       if (escaped) {
+                               escaped = false;
+                               goto character;
+                       }
+                       cur -= 1;
+                       NEWTOKEN(PSI_T_QUOTED_CHAR);
+                       cur += 1;
+                       token->flags = char_width;
+                       goto start;
+               }
+               *               { escaped = false; goto character; }
 
                */
+
        string: ;
                /*!re2c
 
-               "\""    { if (escaped) goto string; cur -= 1; NEWTOKEN(PSI_T_QUOTED_STRING); cur += 1; token->flags = char_width; goto start; }
                EOL             { NEWLINE(); goto string; }
                "\\"    { escaped = !escaped; goto string; }
-               *               { goto string; }
+               "\""    {
+                       if (escaped) {
+                               escaped = false;
+                               goto string;
+                       }
+                       cur -= 1;
+                       NEWTOKEN(PSI_T_QUOTED_STRING);
+                       cur += 1;
+                       token->flags = char_width;
+                       goto start;
+               }
+               *               { escaped = false; goto string; }
 
                */