LCOV - code coverage report
Current view: top level - src/qi - ast.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 10 50.0 %
Date: 2022-11-05 14:57:37 Functions: 5 8 62.5 %

          Line data    Source code
       1             : #ifndef MATHEVAL_IMPLEMENTATION
       2             : #error "Do not include ast.hpp directly!"
       3             : #endif
       4             : 
       5             : #pragma once
       6             : 
       7             : #include <boost/variant.hpp>
       8             : 
       9             : #include <list>
      10             : #include <string>
      11             : 
      12             : namespace matheval {
      13             : 
      14             : namespace ast {
      15             : 
      16             : struct nil {};
      17             : struct unary_op;
      18             : struct binary_op;
      19             : struct ternary_op;
      20             : struct expression;
      21             : 
      22             : // clang-format off
      23             : typedef boost::variant<
      24             :         nil // can't happen!
      25             :         , double
      26             :         , std::string
      27             :         , boost::recursive_wrapper<unary_op>
      28             :         , boost::recursive_wrapper<binary_op>
      29             :         , boost::recursive_wrapper<ternary_op>
      30             :         , boost::recursive_wrapper<expression>
      31             :         >
      32             : operand;
      33             : // clang-format on
      34             : 
      35             : struct unary_op {
      36             :     double (*op)(double);
      37             :     operand rhs;
      38         107 :     unary_op() {}
      39           0 :     unary_op(double (*op)(double), operand const &rhs) : op(op), rhs(rhs) {}
      40             : };
      41             : 
      42             : struct binary_op {
      43             :     double (*op)(double, double);
      44             :     operand lhs;
      45             :     operand rhs;
      46          51 :     binary_op() {}
      47           0 :     binary_op(double (*op)(double, double), operand const &lhs,
      48             :               operand const &rhs)
      49           0 :         : op(op), lhs(lhs), rhs(rhs) {}
      50             : };
      51             : 
      52             : struct ternary_op {
      53             :     double (*op)(double, double, double);
      54             :     operand cond;
      55             :     operand t;
      56             :     operand f;
      57          53 :     ternary_op() {}
      58           0 :     ternary_op(double (*op)(double, double, double), operand const &cond,
      59             :               operand const &t, operand const &f)
      60           0 :         : op(op), cond(cond), t(t), f(f) {}
      61             : };
      62             : 
      63             : struct operation {
      64             :     double (*op)(double, double);
      65             :     operand rhs;
      66        1296 :     operation() {}
      67             :     operation(double (*op)(double, double), operand const &rhs)
      68             :         : op(op), rhs(rhs) {}
      69             : };
      70             : 
      71             : struct expression {
      72             :     operand lhs;
      73             :     std::list<operation> rhs;
      74        1257 :     expression() {}
      75             :     expression(operand const &lhs, std::list<operation> const &rhs)
      76             :         : lhs(lhs), rhs(rhs) {}
      77             : };
      78             : 
      79             : } // namespace ast
      80             : 
      81             : } // namespace matheval

Generated by: LCOV version 1.14