blob: 90e007afffa08ad6deb4762762eaeeb0b2e55656 [file] [log] [blame]
Václav Kubernát8cd63422018-03-19 17:10:13 +01001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
Václav Kubernátd6662962018-03-22 17:41:33 +01003 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
Václav Kubernát8cd63422018-03-19 17:10:13 +01004 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8#pragma once
9#include <boost/spirit/home/x3.hpp>
Václav Kubernát8cd63422018-03-19 17:10:13 +010010#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
Václav Kubernátb96eef72018-05-04 19:10:22 +020011#include <boost/spirit/home/x3/support/utility/error_reporting.hpp>
Václav Kubernátd6662962018-03-22 17:41:33 +010012
Václav Kubernát8cd63422018-03-19 17:10:13 +010013#include <boost/fusion/adapted/struct/adapt_struct.hpp>
14#include <boost/fusion/include/adapt_struct.hpp>
Václav Kubernátb96eef72018-05-04 19:10:22 +020015#include <boost/fusion/include/std_pair.hpp>
16#include <boost/variant.hpp>
17#include <map>
Václav Kubernátd6662962018-03-22 17:41:33 +010018#include <vector>
19
Václav Kubernát94938b72018-05-04 15:12:24 +020020#include "utils.hpp"
Václav Kubernát8cd63422018-03-19 17:10:13 +010021namespace x3 = boost::spirit::x3;
22namespace ascii = boost::spirit::x3::ascii;
23
Václav Kubernát8cd63422018-03-19 17:10:13 +010024using ascii::space;
Václav Kubernát48fc3832018-05-28 14:21:22 +020025using x3::_attr;
26using x3::alnum;
27using x3::alpha;
28using x3::char_;
29using x3::expect;
30using x3::lexeme;
31using x3::lit;
Václav Kubernátb96eef72018-05-04 19:10:22 +020032using boost::fusion::operator<<;
33
34
35using keyValue_ = std::pair<std::string, std::string>;
36
Václav Kubernát8cd63422018-03-19 17:10:13 +010037
38struct parser_context_tag;
39
Václav Kubernát60d6f292018-05-25 09:45:32 +020040
41struct nodeup_ {
42 bool operator==(const nodeup_&) const
43 {
Václav Kubernát48fc3832018-05-28 14:21:22 +020044 return true;
Václav Kubernát60d6f292018-05-25 09:45:32 +020045 }
46};
47
Václav Kubernátd6662962018-03-22 17:41:33 +010048struct container_ {
Václav Kubernátb96eef72018-05-04 19:10:22 +020049 container_() = default;
Václav Kubernátd6662962018-03-22 17:41:33 +010050 container_(const std::string& name);
51
52 bool operator==(const container_& b) const;
53
Václav Kubernát8cd63422018-03-19 17:10:13 +010054 std::string m_name;
55};
56
Václav Kubernátb96eef72018-05-04 19:10:22 +020057
58struct list_ {
59 std::vector<std::string> m_keys;
60};
61
62struct listElement_ {
63 listElement_() {}
64 listElement_(const std::string& listName, const std::map<std::string, std::string>& keys);
65
66 bool operator==(const listElement_& b) const;
67
Václav Kubernát0b76a042018-05-16 20:16:47 +020068 std::string m_name;
Václav Kubernátb96eef72018-05-04 19:10:22 +020069 std::map<std::string, std::string> m_keys;
70};
71
Václav Kubernát8cd63422018-03-19 17:10:13 +010072
Václav Kubernátd6662962018-03-22 17:41:33 +010073struct path_ {
74 bool operator==(const path_& b) const;
Václav Kubernát60d6f292018-05-25 09:45:32 +020075 std::vector<boost::variant<container_, listElement_, nodeup_>> m_nodes;
Václav Kubernát8cd63422018-03-19 17:10:13 +010076};
77
Václav Kubernát8cd63422018-03-19 17:10:13 +010078
Václav Kubernátb96eef72018-05-04 19:10:22 +020079struct cd_ : x3::position_tagged {
Václav Kubernátd6662962018-03-22 17:41:33 +010080 bool operator==(const cd_& b) const;
Václav Kubernát8cd63422018-03-19 17:10:13 +010081 path_ m_path;
82};
83
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020084BOOST_FUSION_ADAPT_STRUCT(container_, m_name)
Václav Kubernát0b76a042018-05-16 20:16:47 +020085BOOST_FUSION_ADAPT_STRUCT(listElement_, m_name, m_keys)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020086BOOST_FUSION_ADAPT_STRUCT(path_, m_nodes)
Václav Kubernát8cd63422018-03-19 17:10:13 +010087BOOST_FUSION_ADAPT_STRUCT(cd_, m_path)