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_; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 20 | using x3::double_; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 21 | using x3::expect; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 22 | using x3::int_; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 23 | using x3::lexeme; |
| 24 | using x3::lit; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 25 | using x3::uint_; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 26 | |
| 27 | struct parser_context_tag; |
| 28 | |
| 29 | using keyValue_ = std::pair<std::string, std::string>; |
| 30 | |
| 31 | struct cd_ : x3::position_tagged { |
| 32 | bool operator==(const cd_& b) const; |
| 33 | path_ m_path; |
| 34 | }; |
| 35 | |
| 36 | struct create_ : x3::position_tagged { |
| 37 | bool operator==(const create_& b) const; |
| 38 | path_ m_path; |
| 39 | }; |
| 40 | |
| 41 | struct delete_ : x3::position_tagged { |
| 42 | bool operator==(const delete_& b) const; |
| 43 | path_ m_path; |
| 44 | }; |
| 45 | |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 46 | struct enum_ { |
| 47 | enum_(); |
| 48 | enum_(const std::string& value); |
| 49 | bool operator==(const enum_& b) const; |
| 50 | std::string m_value; |
| 51 | }; |
| 52 | |
| 53 | using leaf_data_ = boost::variant<enum_, |
| 54 | double, |
| 55 | bool, |
| 56 | int32_t, |
| 57 | uint32_t, |
| 58 | std::string>; |
| 59 | |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 60 | struct set_ : x3::position_tagged { |
| 61 | bool operator==(const set_& b) const; |
| 62 | path_ m_path; |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 63 | leaf_data_ m_data; |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | using command_ = boost::variant<cd_, create_, delete_, set_>; |
| 67 | |
| 68 | BOOST_FUSION_ADAPT_STRUCT(cd_, m_path) |
| 69 | BOOST_FUSION_ADAPT_STRUCT(create_, m_path) |
| 70 | BOOST_FUSION_ADAPT_STRUCT(delete_, m_path) |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame^] | 71 | BOOST_FUSION_ADAPT_STRUCT(enum_, m_value) |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 72 | BOOST_FUSION_ADAPT_STRUCT(set_, m_path, m_data) |