MCPcopy Create free account
hub / github.com/MITK/MITK / Grammar

Class Grammar

Modules/ModelFit/src/Common/mitkFormulaParser.cpp:120–242  ·  view source on GitHub ↗

! * @brief The grammar that defines the language (i.e. what is allowed) for the parser. */

Source from the content-addressed store, hash-verified

118 * @brief The grammar that defines the language (i.e. what is allowed) for the parser.
119 */
120 class Grammar : public qi::grammar<Iter, FormulaParser::ValueType(), Skipper>
121 {
122 /*!
123 * @brief Helper structure that makes it easier to dynamically call any
124 * one-parameter-function by overloading the @c () operator.
125 */
126 struct func1_
127 {
128 // Required for Phoenix 3+
129 template<typename Sig>
130 struct result;
131
132 /*!
133 * @brief Helper structure that is needed for compatibility with
134 * @c boost::phoenix.
135 * @tparam Functor Type of the functor (this struct).
136 * @tparam Function Type of the function that should be called.
137 * @tparam Arg1 Type of the argument the function should be called with.
138 *
139 */
140 template<typename Functor, typename Function, typename Arg1>
141 struct result<Functor(Function, Arg1&)>
142 {
143 /*! @brief The result structure always needs this typedef */
144 typedef Arg1 type;
145 };
146
147 /*!
148 * @brief Calls the function @b f with the argument @b a1 and returns the
149 * result.
150 * The result always has the same type as the argument.
151 * @tparam Function Type of the function that should be called.
152 * @tparam Arg1 Type of the argument the function should be called with.
153 * @param[in] f The function that should be called.
154 * @param[in] a1 The argument the function should be called with.
155 * @return The result of the called function.
156 */
157 template<typename Function, typename Arg1>
158 Arg1 operator()(const Function f, const Arg1 a1) const
159 {
160 return f(a1);
161 }
162 };
163
164 /*!
165 * @brief Helper structure that maps strings to function calls so that parsing e.g.
166 * @c "cos(0)" actually calls the @c std::cos function with parameter @c 1 so it
167 * returns @c 0.
168 */
169 class unaryFunction_ :
170 public qi::symbols<typename std::iterator_traits<Iter>::value_type, FormulaParser::ValueType(*)(FormulaParser::ValueType)>
171 {
172 public:
173 /*!
174 * @brief Constructs the structure, this is where the mapping takes place.
175 */
176 unaryFunction_()
177 {

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected