mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd::json: Recursive output grammar.
This commit is contained in:
parent
7a9bb89506
commit
53a4fae580
1 changed files with 35 additions and 1 deletions
36
ircd/json.cc
36
ircd/json.cc
|
@ -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)
|
||||
| ("e << chars << "e)
|
||||
| (&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<>{}}
|
||||
{}
|
||||
|
|
Loading…
Reference in a new issue