Bayeux  3.4.1
Core Foundation library for SuperNEMO
variant_dependency_logic_parsing.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2016-11-02
4  * Last modified : 2016-11-02
5  *
6  * Copyright (C) 2016 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Parsing tools (AST, grammar) for variant dependency logic formulas.
26  *
27  */
28 
29 #ifndef DATATOOLS_CONFIGURATION_VARIANT_DEPENDENCY_LOGIC_PARSING_H
30 #define DATATOOLS_CONFIGURATION_VARIANT_DEPENDENCY_LOGIC_PARSING_H
31 
32 // Standard library:
33 #include <iostream>
34 #include <string>
35 #include <vector>
36 #include <limits>
37 
38 // Third party:
39 #include <boost/variant.hpp>
40 
41 namespace datatools {
42 
43  namespace configuration {
44 
45  namespace parsing {
46 
49 
51  typedef boost::variant<
52  boost::recursive_wrapper<dependency_logic_ast_op>
54  >
56  void print(const dependency_logic_ast_node & node_, std::ostream & out_, int indent_ = 0);
57 
60  {
61  unsigned int slot_id = std::numeric_limits<unsigned int>::max();
62  void print(std::ostream & out_, int indent_ = 0) const;
63  };
64 
67  {
68  std::string op_symbol;
69  std::vector<dependency_logic_ast_node> children;
70  void print(std::ostream & out_, int indent_ = 0) const;
71  };
72 
75  {
79  bool is_valid() const;
80  void invalidate();
81  void print(std::ostream & out_, int indent_ = 0) const;
82  bool parse(const std::string & formula_);
83 
84  };
85 
86  } // end of namespace parsing
87 
88  } // end of namespace configuration
89 
90 } // end of namespace datatools
91 
92 #endif // DATATOOLS_CONFIGURATION_VARIANT_DEPENDENCY_LOGIC_PARSING_H
93 
94 // Local Variables: --
95 // mode: c++ --
96 // c-file-style: "gnu" --
97 // tab-width: 2 --
98 // End: --
void print(std::ostream &out_, int indent_=0) const
void print(std::ostream &out_, int indent_=0) const
boost::variant< boost::recursive_wrapper< dependency_logic_ast_op >, dependency_logic_ast_slot > dependency_logic_ast_node
AST node:
Definition: variant_dependency_logic_parsing.h:48
AST general operator node:
Definition: variant_dependency_logic_parsing.h:66
void print(std::ostream &out_, int indent_=0) const
AST leaf node:
Definition: variant_dependency_logic_parsing.h:59
std::vector< dependency_logic_ast_node > children
Child nodes.
Definition: variant_dependency_logic_parsing.h:69
Parsing AST:
Definition: variant_dependency_logic_parsing.h:74
unsigned int slot_id
Slot ID.
Definition: variant_dependency_logic_parsing.h:61
void print(const dependency_logic_ast_node &node_, std::ostream &out_, int indent_=0)
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
dependency_logic_ast_node top
Top node.
Definition: variant_dependency_logic_parsing.h:78
std::string op_symbol
Operator symbol.
Definition: variant_dependency_logic_parsing.h:68