Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
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) 2015 - 2017 by 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
44 template <typename Iterator>
45 bool parse(Iterator first, Iterator last, std::shared_ptr<bertini::node::Node>& func)
46 {
47 using boost::spirit::qi::double_;
48 using boost::spirit::qi::_1;
49 using boost::spirit::qi::phrase_parse;
50 using boost::spirit::ascii::space;
51 using boost::phoenix::ref;
52
54
55 std::shared_ptr<bertini::node::Node> f{};
56 bool r = phrase_parse(first, last,
57 S,
58 space,
59 f);
60
61 if (!r || first != last) // fail if we did not get a full match
62 return false;
63
64 func = f;
65 return r;
66 }
67 } // re: namespace classic
68
69 }// re: namespace parsing
70}// re: namespace bertini
Provides the parsing rules for functions in bertini2.
A Qi grammar parser for parsing text into function trees.
Definition function_rules.hpp:143