From: Michael Wallner Date: Fri, 31 Mar 2017 08:20:38 +0000 (+0200) Subject: parser: fix string handling X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=370510d04a5e22140e1e7f90f5d1f0002e6dbee6;p=m6w6%2Fext-psi parser: fix string handling --- diff --git a/src/parser.re b/src/parser.re index 2cdb1e8..d5d1078 100644 --- a/src/parser.re +++ b/src/parser.re @@ -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; } */