I have several large logical expressions (length upto 300K) of the form -
( ( ( 1 ) and ( 5933 or 561 or 1641 ) ) or ( ( 71 or 1 or 15 or 20 ) and ( 436 ) ) or ( ( 398 or 22 or 33 ) ) )
that are parsed using Boost Spirit (as shown in the example here - Boolean expression (grammar) parser in c++)
The parsing takes more than a minute for each expression.
I would like to do the parsing offline which results in an expression represented by -
typedef boost::variant <var,
boost::recursive_wrapper<unop <op_not> >,
boost::recursive_wrapper<binop<op_and> >,
boost::recursive_wrapper<binop<op_or> >
> expr;
This expression needs to be propagated to multiple machines for real-time evaluation against inputs. These machines cannot be made to spend the necessary time for the initial parsing.
Is it possible to propagate the parsed expression in the boost::variant representation above via Boost Interprocess managed_mapped_file? I have tried doing this via a unique_ptr of the expression object and was able to write to a memory mapped file, but evaluation against this object on the other hand resulted in a segmentation fault.
Note that I have also tried boost serialization, which fails for very large expressions.
Looking forward to any advice around this.
Thanks!