Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
function_parsers.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/io/parsers.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//bertini2/io/parsing/function_parsers.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with bertini2/io/parsing/function_parsers.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22
28
29#pragma once
30
31
32
33
35
36
37
38namespace bertini {
39 namespace parsing {
40 namespace classic {
41
42
43
45 template <typename Iterator>
46 bool parse(Iterator first, Iterator last, std::shared_ptr<bertini::node::Node>& func)
47 {
48 using boost::spirit::qi::double_;
49 using boost::spirit::qi::_1;
50 using boost::spirit::qi::phrase_parse;
51 using boost::spirit::ascii::space;
52 using boost::phoenix::ref;
53
55
56 std::shared_ptr<bertini::node::Node> f{};
57 bool r = phrase_parse(first, last,
58 S,
59 space,
60 f);
61
62 if (!r || first != last) // fail if we did not get a full match
63 return false;
64
65 func = f;
66 return r;
67 }
68 } // re: namespace classic
69
70 }// re: namespace parsing
71}// re: namespace bertini
Provides the parsing rules for functions in bertini2.
Definition classic_utilities.hpp:41
bool parse(Iterator first, Iterator last, std::shared_ptr< bertini::node::Node > &func)
Parse a function expression from the iterator range into a node tree.
Definition function_parsers.hpp:46
Definition classic_utilities.hpp:40
Definition algorithm_builder.hpp:36
A Qi grammar parser for parsing text into function trees.
Definition function_rules.hpp:145