json: fix naming of top-level c++ function (+ drop unused one)
This commit is contained in:
parent
6dcf856259
commit
df00efbba1
2 changed files with 3 additions and 15 deletions
|
@ -125,7 +125,7 @@ static std::string replacePattern(const std::string& input, const regex& regex,
|
|||
return result;
|
||||
}
|
||||
|
||||
static string _format_literal(const string& literal) {
|
||||
static string format_literal(const string& literal) {
|
||||
string escaped = replacePattern(json(literal).dump(), GRAMMAR_LITERAL_ESCAPE_RE, [&](const smatch& match) {
|
||||
char c = match.str()[0];
|
||||
return GRAMMAR_LITERAL_ESCAPES.at(c);
|
||||
|
@ -133,13 +133,6 @@ static string _format_literal(const string& literal) {
|
|||
return "\"" + escaped + "\"";
|
||||
}
|
||||
|
||||
static string _format_range_char(const string& ch) {
|
||||
return replacePattern(ch, GRAMMAR_RANGE_LITERAL_ESCAPE_RE, [&](const smatch& match) {
|
||||
char c = match.str()[0];
|
||||
return GRAMMAR_LITERAL_ESCAPES.at(c);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
class SchemaConverter {
|
||||
private:
|
||||
|
@ -422,7 +415,7 @@ private:
|
|||
string prop_rule_name = visit(prop_schema, name + (name.empty() ? "" : "-") + prop_name);
|
||||
prop_kv_rule_names[prop_name] = _add_rule(
|
||||
name + (name.empty() ? "" : "-") + prop_name + "-kv",
|
||||
_format_literal(prop_name) + " space \":\" space " + prop_rule_name
|
||||
format_literal(prop_name) + " space \":\" space " + prop_rule_name
|
||||
);
|
||||
if (required.find(prop_name) != required.end()) {
|
||||
required_props.push_back(prop_name);
|
||||
|
@ -570,7 +563,7 @@ public:
|
|||
_errors.push_back("Only string constants are supported, got " + value.dump());
|
||||
return "";
|
||||
}
|
||||
return _format_literal(value.get<string>());
|
||||
return format_literal(value.get<string>());
|
||||
}
|
||||
|
||||
string visit(const json& schema, const string& name) {
|
||||
|
|
|
@ -65,11 +65,6 @@ class SchemaConverter:
|
|||
)
|
||||
return f'"{escaped}"'
|
||||
|
||||
def _format_range_char(self, literal):
|
||||
return GRAMMAR_RANGE_LITERAL_ESCAPE_RE.sub(
|
||||
lambda m: GRAMMAR_LITERAL_ESCAPES.get(m.group(0)), json.dumps(literal)[1:-1]
|
||||
)
|
||||
|
||||
def _add_rule(self, name, rule):
|
||||
esc_name = INVALID_RULE_CHARS_RE.sub('-', name)
|
||||
if esc_name not in self._rules or self._rules[esc_name] == rule:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue