I'm trying to parse an object where the order of the attributes should not matter.
For example, parsing employee
employee { surname = "doe", firstname = "john", age = 30 }
should be the same as
employee { age = 30, firstname = "john", surname = "doe"}
So ideally my rule should be something like (don't mind the lack of formal definition)
unordered_rule %= lit("employee") >> "{"
>> kwd("surname")["=" > quoted_string]
/ kwd("age")["=" > int_]
/ kwd("firstname")["=" > quoted_string]
/ kwd("age")["=" > int] >> "}";
But firstly, how do I incorporate the separating commas into the parsing rule? And for my C++ struct struct employee { std::string firstname; ... int age; }
, does the order of the attributes matter or how does boost know which keyword corresponds to which attribute even after the struct has been converted to a fusion vector?
This doesn't really add up for me even after reading the documentation on keyword list operators.