Use callbacks without parameters either with or without parenthesis

This commit is contained in:
pantor committed 2018-03-19 10:46:49 +01:00
1 parent b68f745866
commit 776af96b0b
3 files changed
+10 -8

No files matched your search

+8 -7
View File
@@ -597,13 +597,14 @@ public:
*/
static Regex function_regex(std::string name, int number_arguments) {
std::string pattern = name;
if (number_arguments > 0) {
pattern.append("\\(");
for (int i = 0; i < number_arguments; i++) {
if (i != 0) pattern.append(",");
pattern.append("(.*)");
}
pattern.append("\\)");
pattern.append("\\(");
for (int i = 0; i < number_arguments; i++) {
if (i != 0) pattern.append(",");
pattern.append("(.*)");
}
pattern.append("\\)");
if (number_arguments == 0) { // Without arguments, allow to use the callback without parenthesis
pattern = "(?:" + name + "|" + pattern + ")";
}
return Regex{"\\s*" + pattern + "\\s*"};
}