carl  24.04
Computer ARithmetic Library
RationalFunctionParser.h
Go to the documentation of this file.
1 /**
2  * @file RationalFunctionParser.h
3  * @author Gereon Kremer <gereon.kremer@cs.rwth-aachen.de>
4  */
5 
6 #pragma once
7 
8 #include "Common.h"
10 #include "PolynomialParser.h"
11 
12 namespace carl::io {
13 namespace parser {
14 
15 template<typename Pol>
16 struct RationalFunctionParser: public qi::grammar<Iterator, RatFun<Pol>(), Skipper> {
17  RationalFunctionParser(): RationalFunctionParser<Pol>::base_type(main, "rationalfunction") {
18  main = (polynomial >> -("/" >> polynomial))[qi::_val = px::bind(&RationalFunctionParser<Pol>::construct, px::ref(*this), qi::_1, qi::_2)];
19  }
21  polynomial.addVariable(v);
22  }
23 private:
24  RatFun<Pol> construct(const Pol& lhs, const boost::optional<Pol>& rhs) {
25  if (rhs) return RatFun<Pol>(lhs, *rhs);
26  return RatFun<Pol>(lhs);
27  }
29  qi::rule<Iterator, RatFun<Pol>(), Skipper> main;
30 };
31 
32 }
33 }
MultivariatePolynomial< Rational > Pol
Definition: HornerTest.cpp:17
boost::spirit::qi::space_type Skipper
Definition: Common.h:34
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
RatFun< Pol > construct(const Pol &lhs, const boost::optional< Pol > &rhs)
qi::rule< Iterator, RatFun< Pol >), Skipper > main