Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 1 | /* |
| 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" |
Václav Kubernát | 627f615 | 2018-08-29 13:23:56 +0200 | [diff] [blame] | 11 | #include "ast_values.hpp" |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 12 | |
| 13 | namespace x3 = boost::spirit::x3; |
| 14 | namespace ascii = boost::spirit::x3::ascii; |
| 15 | |
| 16 | using ascii::space; |
| 17 | using x3::_attr; |
| 18 | using x3::alnum; |
| 19 | using x3::alpha; |
| 20 | using x3::char_; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 21 | using x3::double_; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 22 | using x3::expect; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 23 | using x3::int_; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 24 | using x3::lexeme; |
| 25 | using x3::lit; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 26 | using x3::uint_; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 27 | |
| 28 | struct parser_context_tag; |
| 29 | |
| 30 | using keyValue_ = std::pair<std::string, std::string>; |
| 31 | |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 32 | enum class LsOption { |
| 33 | Recursive |
| 34 | }; |
| 35 | |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 36 | struct discard_ : x3::position_tagged { |
| 37 | bool operator==(const discard_& b) const; |
| 38 | }; |
| 39 | |
Václav Kubernát | 11afac7 | 2018-07-18 14:59:53 +0200 | [diff] [blame] | 40 | struct ls_ : x3::position_tagged { |
| 41 | bool operator==(const ls_& b) const; |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 42 | std::vector<LsOption> m_options; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame^] | 43 | boost::optional<dataPath_> m_path; |
Václav Kubernát | 11afac7 | 2018-07-18 14:59:53 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 46 | struct cd_ : x3::position_tagged { |
| 47 | bool operator==(const cd_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame^] | 48 | dataPath_ m_path; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct create_ : x3::position_tagged { |
| 52 | bool operator==(const create_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame^] | 53 | dataPath_ m_path; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct delete_ : x3::position_tagged { |
| 57 | bool operator==(const delete_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame^] | 58 | dataPath_ m_path; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | struct set_ : x3::position_tagged { |
| 62 | bool operator==(const set_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame^] | 63 | dataPath_ m_path; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 64 | leaf_data_ m_data; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 65 | }; |
| 66 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 67 | struct commit_ : x3::position_tagged { |
| 68 | bool operator==(const set_& b) const; |
| 69 | }; |
| 70 | |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 71 | struct get_ : x3::position_tagged { |
| 72 | bool operator==(const get_& b) const; |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame^] | 73 | boost::optional<dataPath_> m_path; |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 74 | }; |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 75 | |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 76 | using command_ = boost::variant<discard_, ls_, cd_, create_, delete_, set_, commit_, get_>; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 77 | |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 78 | BOOST_FUSION_ADAPT_STRUCT(ls_, m_options, m_path) |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 79 | BOOST_FUSION_ADAPT_STRUCT(cd_, m_path) |
| 80 | BOOST_FUSION_ADAPT_STRUCT(create_, m_path) |
| 81 | BOOST_FUSION_ADAPT_STRUCT(delete_, m_path) |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 82 | BOOST_FUSION_ADAPT_STRUCT(enum_, m_value) |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 83 | BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data) |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 84 | BOOST_FUSION_ADAPT_STRUCT(commit_) |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 85 | BOOST_FUSION_ADAPT_STRUCT(discard_) |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 86 | BOOST_FUSION_ADAPT_STRUCT(get_, m_path) |