From 7688c14d43456af5a12f618e7cd1f3531c015413 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 29 Jan 2016 21:34:04 -0700 Subject: [PATCH] Parse strings in ${} closes #131 --- include/chaiscript/language/chaiscript_parser.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 84a9cef9..cdc23f62 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -881,9 +881,19 @@ namespace chaiscript char prev_char = *m_position; ++m_position; - while (m_position.has_more() && ((*m_position != '\"') || ((*m_position == '\"') && (prev_char == '\\')))) { + int in_interpolation = 0; + bool in_quote = false; + + while (m_position.has_more() && ((*m_position != '\"') || ((*m_position == '\"') && (in_interpolation > 0)) || ((*m_position == '\"') && (prev_char == '\\')))) { + if (!Eol_()) { - if (prev_char == '\\') { + if (prev_char == '$' && *m_position == '{') { + ++in_interpolation; + } else if (*m_position == '"') { + in_quote = !in_quote; + } else if (*m_position == '}' && !in_quote) { + --in_interpolation; + } else if (prev_char == '\\') { prev_char = 0; } else { prev_char = *m_position;