Skip to content

Commit

Permalink
jl-generators: fix name collision with include and properly escape …
Browse files Browse the repository at this point in the history
…backslashes (#66)
  • Loading branch information
jumerckx authored Mar 23, 2024
1 parent 82382c9 commit 52685c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion deps/tblgen/jl-generators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ namespace
leading_spaces_str += "[ ]";
description = std::regex_replace(description, std::regex("\n" + leading_spaces_str), "\n");
}
description = std::regex_replace(description, std::regex(R"(\\)"), R"(\\)");
description = std::regex_replace(description, std::regex("(['\"$])"), "\\$1");
description = std::regex_replace(description, std::regex("(^|\n)(Example|Syntax):"), "$1# $2");

Expand Down Expand Up @@ -141,7 +142,7 @@ namespace
}
// check if name colides with Julia keywords, generated module name, or "location":
// https://docs.julialang.org/en/v1/base/base/#Keywords
std::vector<std::string> reservedKeywords = {"location", "baremodule", "begin", "break", "catch", "const", "continue", "do", "else", "elseif", "end", "export", "false", "finally", "for", "function", "global", "if", "import", "let", "local", "macro", "module", "public", "quote", "return", "struct", "true", "try", "using", "while"};
std::vector<std::string> reservedKeywords = {"include", "location", "baremodule", "begin", "break", "catch", "const", "continue", "do", "else", "elseif", "end", "export", "false", "finally", "for", "function", "global", "if", "import", "let", "local", "macro", "module", "public", "quote", "return", "struct", "true", "try", "using", "while"};
if (modulename.has_value()) {
reservedKeywords.push_back(modulename.value());
}
Expand Down

0 comments on commit 52685c0

Please sign in to comment.