MCPcopy Create free account
hub / github.com/MhmRdd/NoHello / validateSyntax

Method validateSyntax

module/src/main/cpp/MountRuleParser.cpp:223–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221
222private:
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;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected