| 221 | |
| 222 | private: |
| 223 | static bool validateSyntax(const std::string& text) { |
| 224 | int braceCount = 0; |
| 225 | bool inDoubleQuotes = false, inSingleQuotes = false; |
| 226 | |
| 227 | for (size_t i = 0; i < text.size(); ++i) { |
| 228 | char ch = text[i]; |
| 229 | if (ch == '"' && !inSingleQuotes && (i == 0 || text[i - 1] != '\\')) |
| 230 | inDoubleQuotes = !inDoubleQuotes; |
| 231 | else if (ch == '\'' && !inDoubleQuotes && (i == 0 || text[i - 1] != '\\')) |
| 232 | inSingleQuotes = !inSingleQuotes; |
| 233 | |
| 234 | if (!inDoubleQuotes && !inSingleQuotes) { |
| 235 | if (ch == '{') ++braceCount; |
| 236 | else if (ch == '}') { |
| 237 | --braceCount; |
| 238 | if (braceCount < 0) return false; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | return braceCount == 0 && !inDoubleQuotes && !inSingleQuotes; |
| 244 | } |
| 245 | |
| 246 | static std::vector<std::string> tokenizePreserveQuotes(const std::string& text) { |
| 247 | std::vector<std::string> tokens; |
nothing calls this directly
no outgoing calls
no test coverage detected