diff --git a/libpub/scan.ll b/libpub/scan.ll index 2464b0e3..1846217b 100644 --- a/libpub/scan.ll +++ b/libpub/scan.ll @@ -9,6 +9,7 @@ #include "qhash.h" #include #include +#include #define YY_STR_BUFLEN 20*1024 static void begin_P3_STR (char ch); @@ -48,7 +49,7 @@ static char yy_p3_regex_close_char; static char yy_p3_regex_open_char; static int yy_p3_regex_start_line; strbuf yy_p3_regex_buf; -static char yy_p3_str_char; +static vec yy_p3_str_char; static strbuf yy_json_strbuf; static int yy_json_str_line; @@ -391,7 +392,7 @@ nlcount (int m) void begin_P3_STR (char ch) { - yy_p3_str_char = ch; + yy_p3_str_char.push_back(ch); yy_push_state (P3_STR); yy_ssln = pub3::plineno (); } @@ -399,12 +400,12 @@ begin_P3_STR (char ch) bool end_P3_STR (char ch) { - bool ret = false; - if (yy_p3_str_char == ch) { + if (ch == yy_p3_str_char.back()) { + yy_p3_str_char.pop_back(); yy_pop_state (); - ret = true; + return true; } - return ret; + return false; } int diff --git a/test/pub/Makefile.am b/test/pub/Makefile.am index 6834bdb3..25b438d3 100644 --- a/test/pub/Makefile.am +++ b/test/pub/Makefile.am @@ -1,6 +1,7 @@ PACKAGE_STRING=pub TESTS = \ dict_equal.pub \ + nested_quotes.pub \ scoping_for.pub \ scoping_globals-locals.pub \ scoping_order_of_decl.pub \ diff --git a/test/pub/nested_quotes.expected b/test/pub/nested_quotes.expected new file mode 100644 index 00000000..9766475a --- /dev/null +++ b/test/pub/nested_quotes.expected @@ -0,0 +1 @@ +ok diff --git a/test/pub/nested_quotes.pub b/test/pub/nested_quotes.pub new file mode 100644 index 00000000..dabdcf52 --- /dev/null +++ b/test/pub/nested_quotes.pub @@ -0,0 +1,9 @@ +{% +locals { + v1 : 'Test "A balanced nested par"', + v2 : 'Test "A non balanced nested par', + v3 : "An escaped quote\"", + v4 : "%{"o" + 'k' }" +} +print(v4); +%}