blob: d7d47c9676f7523980188b4d6feffd5c54175e70 [file] [log] [blame]
Václav Kubernát24df80e2018-06-06 15:18:03 +02001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8#pragma once
9
10#include "ast_path.hpp"
11
12namespace x3 = boost::spirit::x3;
13namespace ascii = boost::spirit::x3::ascii;
14
15using ascii::space;
16using x3::_attr;
17using x3::alnum;
18using x3::alpha;
19using x3::char_;
Václav Kubernátebca2552018-06-08 19:06:02 +020020using x3::double_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020021using x3::expect;
Václav Kubernátebca2552018-06-08 19:06:02 +020022using x3::int_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020023using x3::lexeme;
24using x3::lit;
Václav Kubernátebca2552018-06-08 19:06:02 +020025using x3::uint_;
Václav Kubernát24df80e2018-06-06 15:18:03 +020026
27struct parser_context_tag;
28
29using keyValue_ = std::pair<std::string, std::string>;
30
Václav Kubernát11afac72018-07-18 14:59:53 +020031struct ls_ : x3::position_tagged {
32 bool operator==(const ls_& b) const;
33 boost::optional<path_> m_path;
34};
35
Václav Kubernát24df80e2018-06-06 15:18:03 +020036struct cd_ : x3::position_tagged {
37 bool operator==(const cd_& b) const;
38 path_ m_path;
39};
40
41struct create_ : x3::position_tagged {
42 bool operator==(const create_& b) const;
43 path_ m_path;
44};
45
46struct delete_ : x3::position_tagged {
47 bool operator==(const delete_& b) const;
48 path_ m_path;
49};
50
Václav Kubernátebca2552018-06-08 19:06:02 +020051struct enum_ {
52 enum_();
53 enum_(const std::string& value);
54 bool operator==(const enum_& b) const;
55 std::string m_value;
56};
57
58using leaf_data_ = boost::variant<enum_,
59 double,
60 bool,
61 int32_t,
62 uint32_t,
63 std::string>;
64
Václav Kubernát24df80e2018-06-06 15:18:03 +020065struct set_ : x3::position_tagged {
66 bool operator==(const set_& b) const;
67 path_ m_path;
Václav Kubernátebca2552018-06-08 19:06:02 +020068 leaf_data_ m_data;
Václav Kubernát24df80e2018-06-06 15:18:03 +020069};
70
Václav Kubernát11afac72018-07-18 14:59:53 +020071using command_ = boost::variant<ls_, cd_, create_, delete_, set_>;
Václav Kubernát24df80e2018-06-06 15:18:03 +020072
Václav Kubernát11afac72018-07-18 14:59:53 +020073BOOST_FUSION_ADAPT_STRUCT(ls_, m_path)
Václav Kubernát24df80e2018-06-06 15:18:03 +020074BOOST_FUSION_ADAPT_STRUCT(cd_, m_path)
75BOOST_FUSION_ADAPT_STRUCT(create_, m_path)
76BOOST_FUSION_ADAPT_STRUCT(delete_, m_path)
Václav Kubernátebca2552018-06-08 19:06:02 +020077BOOST_FUSION_ADAPT_STRUCT(enum_, m_value)
Václav Kubernát24df80e2018-06-06 15:18:03 +020078BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data)