aboutsummaryrefslogtreecommitdiff
path: root/src/yuescript/yue_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
-rw-r--r--src/yuescript/yue_parser.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 294f1e5..66ef373 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -98,6 +98,11 @@ YueParser::YueParser() {
98 return false; 98 return false;
99 }); 99 });
100 100
101 invalid_interpolation_error = pl::user(true_(), [](const item_t& item) {
102 throw ParserError("invalid string interpolation"sv, item.begin);
103 return false;
104 });
105
101 #define ensure(patt, finally) ((patt) >> (finally) | (finally) >> cut) 106 #define ensure(patt, finally) ((patt) >> (finally) | (finally) >> cut)
102 107
103 #define key(str) (expr(str) >> not_alpha_num) 108 #define key(str) (expr(str) >> not_alpha_num)
@@ -529,9 +534,9 @@ YueParser::YueParser() {
529 single_string_inner = '\\' >> set("'\\") | not_('\'') >> any_char; 534 single_string_inner = '\\' >> set("'\\") | not_('\'') >> any_char;
530 SingleString = '\'' >> *single_string_inner >> '\''; 535 SingleString = '\'' >> *single_string_inner >> '\'';
531 536
532 interp = "#{" >> space >> Exp >> space >> '}'; 537 interp = "#{" >> space >> (Exp >> space >> '}' | invalid_interpolation_error);
533 double_string_plain = '\\' >> set("\"\\") | not_('"') >> any_char; 538 double_string_plain = '\\' >> set("\"\\#") | not_('"') >> any_char;
534 DoubleStringInner = +(not_(interp) >> double_string_plain); 539 DoubleStringInner = +(not_("#{") >> double_string_plain);
535 DoubleStringContent = DoubleStringInner | interp; 540 DoubleStringContent = DoubleStringInner | interp;
536 DoubleString = '"' >> Seperator >> *DoubleStringContent >> '"'; 541 DoubleString = '"' >> Seperator >> *DoubleStringContent >> '"';
537 String = DoubleString | SingleString | LuaString; 542 String = DoubleString | SingleString | LuaString;