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" |
| 11 | |
| 12 | namespace x3 = boost::spirit::x3; |
| 13 | namespace ascii = boost::spirit::x3::ascii; |
| 14 | |
| 15 | using ascii::space; |
| 16 | using x3::_attr; |
| 17 | using x3::alnum; |
| 18 | using x3::alpha; |
| 19 | using x3::char_; |
| 20 | using x3::expect; |
| 21 | using x3::lexeme; |
| 22 | using x3::lit; |
| 23 | |
| 24 | struct parser_context_tag; |
| 25 | |
| 26 | using keyValue_ = std::pair<std::string, std::string>; |
| 27 | |
| 28 | struct cd_ : x3::position_tagged { |
| 29 | bool operator==(const cd_& b) const; |
| 30 | path_ m_path; |
| 31 | }; |
| 32 | |
| 33 | struct create_ : x3::position_tagged { |
| 34 | bool operator==(const create_& b) const; |
| 35 | path_ m_path; |
| 36 | }; |
| 37 | |
| 38 | struct delete_ : x3::position_tagged { |
| 39 | bool operator==(const delete_& b) const; |
| 40 | path_ m_path; |
| 41 | }; |
| 42 | |
| 43 | struct set_ : x3::position_tagged { |
| 44 | bool operator==(const set_& b) const; |
| 45 | path_ m_path; |
| 46 | std::string m_data; |
| 47 | }; |
| 48 | |
| 49 | using command_ = boost::variant<cd_, create_, delete_, set_>; |
| 50 | |
| 51 | BOOST_FUSION_ADAPT_STRUCT(cd_, m_path) |
| 52 | BOOST_FUSION_ADAPT_STRUCT(create_, m_path) |
| 53 | BOOST_FUSION_ADAPT_STRUCT(delete_, m_path) |
| 54 | BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data) |