0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::json: Recursive output grammar.

This commit is contained in:
Jason Volk 2018-03-20 16:07:22 -07:00
parent 7a9bb89506
commit 53a4fae580

View file

@ -201,7 +201,12 @@ struct ircd::json::output
rule<string_view> lit_null { karma::string("null") ,"literal null" };
rule<string_view> boolean { lit_true | lit_false ,"boolean" };
rule<string_view> literal { lit_true | lit_false | lit_null ,"literal" };
rule<string_view> number { double_ ,"number" };
rule<string_view> number
{
double_
,"number"
};
rule<string_view> chars
{
@ -221,6 +226,35 @@ struct ircd::json::output
,"name"
};
const rule<string_view> value
{
(&object << object)
| (&array << array)
| (&literal << literal)
| (&quote << chars << &quote)
| (&number << number)
| (&string << string)
,"value"
};
const rule<json::object::member> member
{
name << name_sep << value
,"member"
};
const rule<ircd::json::object> object
{
object_begin << -(member % value_sep) << object_end
,"object"
};
const rule<ircd::json::array> array
{
array_begin << -(value % value_sep) << array_end
,"array"
};
output()
:output::base_type{rule<>{}}
{}