common: consolidate PEG string parsers (#20263)

* common : consolidate PEG string parsers
* cont : fix json_string_content()
This commit is contained in:
Aldehir Rojas 2026-03-09 18:29:21 -05:00 committed by GitHub
parent 0842b9b465
commit c96f608d98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 142 additions and 159 deletions

View file

@ -90,7 +90,7 @@ common_peg_arena autoparser::build_parser(const templates_params & inputs) const
// pre-register a json-string rule that accepts both quote styles. This must happen
// before any call to p.json() so that all JSON parsing inherits the flexible rule.
if (tools.format.uses_python_dicts) {
p.rule("json-string", [&]() { return p.choice({ p.double_quoted_string(), p.single_quoted_string() }); });
p.rule("json-string", p.quoted_string());
}
parser_build_context ctx(p, inputs);