From 370510d04a5e22140e1e7f90f5d1f0002e6dbee6 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 31 Mar 2017 10:20:38 +0200 Subject: [PATCH] parser: fix string handling --- src/parser.re | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) 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; } */ -- 2.30.2