Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +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 | |
| 9 | #pragma once |
| 10 | |
Václav Kubernát | 509ce65 | 2019-05-29 19:46:44 +0200 | [diff] [blame] | 11 | #include <boost/spirit/home/x3.hpp> |
Václav Kubernát | 24df80e | 2018-06-06 15:18:03 +0200 | [diff] [blame] | 12 | #include "ast_commands.hpp" |
Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +0200 | [diff] [blame] | 13 | #include "ast_handlers.hpp" |
Václav Kubernát | 9ae8cc4 | 2020-03-25 19:17:41 +0100 | [diff] [blame] | 14 | #include "common_parsers.hpp" |
| 15 | #include "leaf_data.hpp" |
Václav Kubernát | d0ea9b2 | 2020-04-24 00:44:15 +0200 | [diff] [blame] | 16 | #include "path_parser.hpp" |
Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +0200 | [diff] [blame] | 17 | |
Václav Kubernát | 68c8942 | 2021-10-20 15:32:20 +0200 | [diff] [blame] | 18 | #if BOOST_VERSION <= 107700 |
Václav Kubernát | f5f6d24 | 2022-04-07 01:06:19 +0200 | [diff] [blame] | 19 | namespace boost::spirit::x3::traits { |
Václav Kubernát | 68c8942 | 2021-10-20 15:32:20 +0200 | [diff] [blame] | 20 | // Backport https://github.com/boostorg/spirit/pull/702 |
| 21 | // with instructions from https://github.com/boostorg/spirit/issues/701#issuecomment-946743099 |
| 22 | template <typename... Types, typename T> |
| 23 | struct variant_find_substitute<boost::variant<Types...>, T> |
| 24 | { |
| 25 | using variant_type = boost::variant<Types...>; |
| 26 | |
| 27 | typedef typename variant_type::types types; |
| 28 | typedef typename mpl::end<types>::type end; |
| 29 | |
| 30 | typedef typename mpl::find<types, T>::type iter_1; |
| 31 | |
| 32 | typedef typename |
| 33 | mpl::eval_if< |
| 34 | is_same<iter_1, end>, |
| 35 | mpl::find_if<types, traits::is_substitute<T, mpl::_1> >, |
| 36 | mpl::identity<iter_1> |
| 37 | >::type |
| 38 | iter; |
| 39 | |
| 40 | typedef typename |
| 41 | mpl::eval_if< |
| 42 | is_same<iter, end>, |
| 43 | mpl::identity<T>, |
| 44 | mpl::deref<iter> |
| 45 | >::type |
| 46 | type; |
| 47 | }; |
| 48 | } |
| 49 | #endif |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 50 | |
Václav Kubernát | 5c75b25 | 2018-10-10 18:33:47 +0200 | [diff] [blame] | 51 | |
Václav Kubernát | 4137845 | 2018-06-06 16:29:40 +0200 | [diff] [blame] | 52 | #if __clang__ |
| 53 | #pragma GCC diagnostic push |
| 54 | #pragma GCC diagnostic ignored "-Woverloaded-shift-op-parentheses" |
| 55 | #endif |
Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +0200 | [diff] [blame] | 56 | |
Václav Kubernát | 509ce65 | 2019-05-29 19:46:44 +0200 | [diff] [blame] | 57 | namespace ascii = boost::spirit::x3::ascii; |
| 58 | |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 59 | struct ls_options_table : x3::symbols<LsOption> { |
| 60 | ls_options_table() |
| 61 | { |
Václav Kubernát | bf083ec | 2019-02-19 13:58:09 +0100 | [diff] [blame] | 62 | add |
| 63 | ("--recursive", LsOption::Recursive); |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 64 | } |
| 65 | } const ls_options; |
| 66 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 67 | auto const ls = x3::rule<struct ls_class, ls_>{"ls"} = |
Václav Kubernát | 76bb8c2 | 2022-01-19 01:32:31 +0100 | [diff] [blame] | 68 | ls_::name >> *(space_separator >> ls_options) >> -(space_separator > (anyPath | (module >> "*"))); |
Václav Kubernát | 11afac7 | 2018-07-18 14:59:53 +0200 | [diff] [blame] | 69 | |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 70 | auto const cd = x3::rule<cd_class, cd_>{"cd"} = |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 71 | cd_::name >> space_separator > cdPath; |
Václav Kubernát | 0a2a2e8 | 2018-05-11 13:59:12 +0200 | [diff] [blame] | 72 | |
Václav Kubernát | 3817502 | 2021-11-04 14:58:57 +0100 | [diff] [blame] | 73 | #if BOOST_VERSION <= 107700 |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 74 | auto const create = x3::rule<create_class, create_>{"create"} = |
Václav Kubernát | 3817502 | 2021-11-04 14:58:57 +0100 | [diff] [blame] | 75 | create_::name >> space_separator > |
| 76 | (x3::eps >> presenceContainerPath | |
| 77 | x3::eps >> listInstancePath | |
| 78 | x3::eps >> leafListElementPath); |
| 79 | |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 80 | auto const delete_rule = x3::rule<delete_class, delete_>{"delete_rule"} = |
Václav Kubernát | 3817502 | 2021-11-04 14:58:57 +0100 | [diff] [blame] | 81 | delete_::name >> space_separator > |
| 82 | (x3::eps >> presenceContainerPath | |
| 83 | x3::eps >> listInstancePath | |
| 84 | x3::eps >> leafListElementPath | |
| 85 | x3::eps >> writableLeafPath); |
| 86 | #else |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 87 | auto const create = x3::rule<create_class, create_>{"create"} = |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 88 | create_::name >> space_separator > (presenceContainerPath | listInstancePath | leafListElementPath); |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 89 | |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 90 | auto const delete_rule = x3::rule<delete_class, delete_>{"delete_rule"} = |
Jan Kundrát | b7206ad | 2020-06-18 21:08:14 +0200 | [diff] [blame] | 91 | delete_::name >> space_separator > (presenceContainerPath | listInstancePath | leafListElementPath | writableLeafPath); |
Václav Kubernát | 3817502 | 2021-11-04 14:58:57 +0100 | [diff] [blame] | 92 | #endif |
Václav Kubernát | 0720424 | 2018-06-04 18:12:09 +0200 | [diff] [blame] | 93 | |
Václav Kubernát | e066fe2 | 2022-04-06 00:32:26 +0200 | [diff] [blame] | 94 | const auto dsTargetSuggestions = staticSuggestions({"running", "startup", "operational"}); |
| 95 | |
| 96 | struct ds_target_table : x3::symbols<DatastoreTarget> { |
| 97 | ds_target_table() |
| 98 | { |
| 99 | add |
| 100 | ("operational", DatastoreTarget::Operational) |
| 101 | ("startup", DatastoreTarget::Startup) |
| 102 | ("running", DatastoreTarget::Running); |
| 103 | } |
| 104 | } const ds_target_table; |
| 105 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 106 | auto const get = x3::rule<struct get_class, get_>{"get"} = |
Václav Kubernát | e066fe2 | 2022-04-06 00:32:26 +0200 | [diff] [blame] | 107 | get_::name |
| 108 | >> -(space_separator >> "-" > staticSuggestions({"-datastore"}) > "-datastore" > space_separator > dsTargetSuggestions > ds_target_table) |
Václav Kubernát | 76bb8c2 | 2022-01-19 01:32:31 +0100 | [diff] [blame] | 109 | >> -(space_separator > getPath); |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 110 | |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 111 | auto const set = x3::rule<set_class, set_>{"set"} = |
Václav Kubernát | abf5280 | 2020-05-19 01:31:17 +0200 | [diff] [blame] | 112 | set_::name >> space_separator > writableLeafPath > space_separator > leaf_data; |
Václav Kubernát | b61336d | 2018-05-28 17:35:03 +0200 | [diff] [blame] | 113 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 114 | auto const commit = x3::rule<struct commit_class, commit_>{"commit"} = |
Václav Kubernát | bf083ec | 2019-02-19 13:58:09 +0100 | [diff] [blame] | 115 | commit_::name >> x3::attr(commit_()); |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 116 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 117 | auto const discard = x3::rule<struct discard_class, discard_>{"discard"} = |
Václav Kubernát | bf083ec | 2019-02-19 13:58:09 +0100 | [diff] [blame] | 118 | discard_::name >> x3::attr(discard_()); |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 119 | |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 120 | struct command_names_table : x3::symbols<decltype(help_::m_cmd)> { |
| 121 | command_names_table() |
| 122 | { |
| 123 | boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([this](auto cmd) { |
Václav Kubernát | 672889c | 2020-05-27 04:11:36 +0200 | [diff] [blame] | 124 | add(commandNamesVisitor(cmd), decltype(help_::m_cmd)(cmd)); |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 125 | }); |
| 126 | } |
| 127 | } const command_names; |
| 128 | |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 129 | auto const createCommandSuggestions = x3::rule<createCommandSuggestions_class, x3::unused_type>{"createCommandSuggestions"} = |
| 130 | x3::eps; |
| 131 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 132 | auto const help = x3::rule<struct help_class, help_>{"help"} = |
Václav Kubernát | 054cc99 | 2019-02-21 14:23:52 +0100 | [diff] [blame] | 133 | help_::name > createCommandSuggestions >> -command_names; |
| 134 | |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 135 | struct datastore_symbol_table : x3::symbols<Datastore> { |
| 136 | datastore_symbol_table() |
| 137 | { |
| 138 | add |
| 139 | ("running", Datastore::Running) |
| 140 | ("startup", Datastore::Startup); |
| 141 | } |
| 142 | } const datastore; |
| 143 | |
Václav Kubernát | 60b4846 | 2022-04-27 12:23:15 +0200 | [diff] [blame] | 144 | const auto copy_source = x3::rule<struct source, Datastore>{"source datastore"} = datastore; |
| 145 | const auto copy_destination = x3::rule<struct source, Datastore>{"destination datastore"} = datastore; |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 146 | |
Václav Kubernát | 7ff2207 | 2022-04-05 10:22:40 +0200 | [diff] [blame] | 147 | const auto datastoreSuggestions = staticSuggestions({"running", "startup"}); |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 148 | |
| 149 | struct copy_args : x3::parser<copy_args> { |
| 150 | using attribute_type = copy_; |
| 151 | template <typename It, typename Ctx, typename RCtx> |
| 152 | bool parse(It& begin, It end, Ctx const& ctx, RCtx& rctx, copy_& attr) const |
| 153 | { |
| 154 | auto& parserContext = x3::get<parser_context_tag>(ctx); |
| 155 | auto iterBeforeDestination = begin; |
Václav Kubernát | 76bb8c2 | 2022-01-19 01:32:31 +0100 | [diff] [blame] | 156 | auto save_iter = x3::eps[([&iterBeforeDestination](auto& ctx) { iterBeforeDestination = _where(ctx).begin(); })]; |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 157 | auto grammar = datastoreSuggestions > copy_source > space_separator > datastoreSuggestions > save_iter > copy_destination; |
| 158 | |
| 159 | try { |
| 160 | grammar.parse(begin, end, ctx, rctx, attr); |
| 161 | } catch (x3::expectation_failure<It>& ex) { |
| 162 | using namespace std::string_literals; |
| 163 | parserContext.m_errorMsg = "Expected "s + ex.which() + " here:"; |
| 164 | throw; |
| 165 | } |
| 166 | |
| 167 | if (attr.m_source == attr.m_destination) { |
| 168 | begin = iterBeforeDestination; // Restoring the iterator here makes the error caret point to the second datastore |
| 169 | parserContext.m_errorMsg = "Source datastore and destination datastore can't be the same."; |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | return true; |
| 174 | } |
Václav Kubernát | 21fc5e2 | 2020-11-26 04:28:27 +0100 | [diff] [blame] | 175 | } const copy_args; |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 176 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 177 | auto const copy = x3::rule<struct copy_class, copy_>{"copy"} = |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 178 | copy_::name > space_separator > copy_args; |
| 179 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 180 | auto const describe = x3::rule<struct describe_class, describe_>{"describe"} = |
Václav Kubernát | 3200b86 | 2020-12-03 02:34:55 +0100 | [diff] [blame] | 181 | describe_::name >> space_separator > anyPath; |
Václav Kubernát | 9cfcd87 | 2020-02-18 12:34:02 +0100 | [diff] [blame] | 182 | |
Václav Kubernát | 162165e | 2021-02-22 09:46:53 +0100 | [diff] [blame] | 183 | struct move_mode_table : x3::symbols<MoveMode> { |
| 184 | move_mode_table() |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 185 | { |
| 186 | add |
| 187 | ("after", MoveMode::After) |
| 188 | ("before", MoveMode::Before) |
| 189 | ("begin", MoveMode::Begin) |
| 190 | ("end", MoveMode::End); |
| 191 | } |
Václav Kubernát | 162165e | 2021-02-22 09:46:53 +0100 | [diff] [blame] | 192 | } const move_mode_table; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 193 | |
| 194 | struct move_absolute_table : x3::symbols<yang::move::Absolute> { |
| 195 | move_absolute_table() |
| 196 | { |
| 197 | add |
| 198 | ("begin", yang::move::Absolute::Begin) |
| 199 | ("end", yang::move::Absolute::End); |
| 200 | } |
| 201 | } const move_absolute_table; |
| 202 | |
| 203 | struct move_relative_table : x3::symbols<yang::move::Relative::Position> { |
| 204 | move_relative_table() |
| 205 | { |
| 206 | add |
| 207 | ("before", yang::move::Relative::Position::Before) |
| 208 | ("after", yang::move::Relative::Position::After); |
| 209 | } |
| 210 | } const move_relative_table; |
| 211 | |
| 212 | struct move_args : x3::parser<move_args> { |
| 213 | using attribute_type = move_; |
| 214 | template <typename It, typename Ctx, typename RCtx> |
| 215 | bool parse(It& begin, It end, Ctx const& ctx, RCtx& rctx, move_& attr) const |
| 216 | { |
| 217 | ParserContext& parserContext = x3::get<parser_context_tag>(ctx); |
| 218 | dataPath_ movePath; |
Václav Kubernát | 3817502 | 2021-11-04 14:58:57 +0100 | [diff] [blame] | 219 | #if BOOST_VERSION <= 107700 |
| 220 | auto movePathGrammar = x3::eps >> listInstancePath | x3::eps >> leafListElementPath; |
| 221 | #else |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 222 | auto movePathGrammar = listInstancePath | leafListElementPath; |
Václav Kubernát | 3817502 | 2021-11-04 14:58:57 +0100 | [diff] [blame] | 223 | #endif |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 224 | auto res = movePathGrammar.parse(begin, end, ctx, rctx, attr.m_source); |
| 225 | if (!res) { |
| 226 | parserContext.m_errorMsg = "Expected source path here:"; |
| 227 | return false; |
| 228 | } |
| 229 | |
| 230 | // Try absolute move first. |
| 231 | res = (space_separator >> move_absolute_table).parse(begin, end, ctx, rctx, attr.m_destination); |
| 232 | if (res) { |
| 233 | // Absolute move parsing succeeded, we don't need to parse anything else. |
| 234 | return true; |
| 235 | } |
| 236 | |
| 237 | // If absolute move didn't succeed, try relative. |
| 238 | attr.m_destination = yang::move::Relative{}; |
| 239 | res = (space_separator >> move_relative_table).parse(begin, end, ctx, rctx, std::get<yang::move::Relative>(attr.m_destination).m_position); |
| 240 | |
| 241 | if (!res) { |
| 242 | parserContext.m_errorMsg = "Expected a move position (begin, end, before, after) here:"; |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | if (std::holds_alternative<leafListElement_>(attr.m_source.m_nodes.back().m_suffix)) { |
| 247 | leaf_data_ value; |
| 248 | res = (space_separator >> leaf_data).parse(begin, end, ctx, rctx, value); |
| 249 | if (res) { |
| 250 | std::get<yang::move::Relative>(attr.m_destination).m_path = {{".", value}}; |
| 251 | } |
| 252 | } else { |
| 253 | ListInstance listInstance; |
| 254 | // The source list instance will be stored inside the parser context path. |
| 255 | // The source list instance will be full data path (with keys included). |
| 256 | // However, m_tmpListPath is supposed to store a path with a list without the keys. |
| 257 | // So, I pop the last listElement_ (which has the keys) and put in a list_ (which doesn't have the keys). |
| 258 | // Example: /mod:cont/protocols[name='ftp'] gets turned into /mod:cont/protocols |
| 259 | parserContext.m_tmpListPath = parserContext.currentDataPath(); |
| 260 | parserContext.m_tmpListPath.m_nodes.pop_back(); |
| 261 | auto list = list_{std::get<listElement_>(attr.m_source.m_nodes.back().m_suffix).m_name}; |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 262 | parserContext.m_tmpListPath.m_nodes.emplace_back(attr.m_source.m_nodes.back().m_prefix, list); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 263 | |
| 264 | res = (space_separator >> listSuffix).parse(begin, end, ctx, rctx, listInstance); |
| 265 | if (res) { |
| 266 | std::get<yang::move::Relative>(attr.m_destination).m_path = listInstance; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if (!res) { |
| 271 | parserContext.m_errorMsg = "Expected a destination here:"; |
| 272 | } |
| 273 | |
| 274 | return res; |
| 275 | } |
| 276 | } const move_args; |
| 277 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 278 | auto const move = x3::rule<struct move_class, move_>{"move"} = |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 279 | move_::name >> space_separator >> move_args; |
| 280 | |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 281 | struct format_table : x3::symbols<DataFormat> { |
| 282 | format_table() |
| 283 | { |
| 284 | add |
| 285 | ("xml", DataFormat::Xml) |
| 286 | ("json", DataFormat::Json); |
| 287 | } |
| 288 | } const format_table; |
| 289 | |
Václav Kubernát | 3b5e652 | 2020-06-26 18:36:09 +0200 | [diff] [blame] | 290 | struct dump_args : x3::parser<dump_args> { |
| 291 | using attribute_type = dump_; |
| 292 | template <typename It, typename Ctx, typename RCtx> |
| 293 | bool parse(It& begin, It end, Ctx const& ctx, RCtx& rctx, dump_& attr) const |
| 294 | { |
| 295 | ParserContext& parserContext = x3::get<parser_context_tag>(ctx); |
| 296 | parserContext.m_suggestions = {{"xml"}, {"json"}}; |
| 297 | parserContext.m_completionIterator = begin; |
| 298 | auto res = format_table.parse(begin, end, ctx, rctx, attr); |
| 299 | if (!res) { |
| 300 | parserContext.m_errorMsg = "Expected a data format (xml, json) here:"; |
| 301 | } |
| 302 | return res; |
| 303 | } |
| 304 | } const dump_args; |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 305 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 306 | auto const prepare = x3::rule<struct prepare_class, prepare_>{"prepare"} = |
Václav Kubernát | d8408e0 | 2020-12-02 05:13:27 +0100 | [diff] [blame] | 307 | prepare_::name > space_separator > as<dataPath_>[RpcActionPath<AllowInput::Yes>{}]; |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 308 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 309 | auto const exec = x3::rule<struct exec_class, exec_>{"exec"} = |
Václav Kubernát | aff1f49 | 2021-02-17 10:56:28 +0100 | [diff] [blame] | 310 | exec_::name > -(space_separator > -as<dataPath_>[RpcActionPath<AllowInput::No>{}]); |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 311 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 312 | auto const switch_rule = x3::rule<struct switch_class, switch_>{"switch"} = |
Václav Kubernát | 7ff2207 | 2022-04-05 10:22:40 +0200 | [diff] [blame] | 313 | switch_::name > space_separator > dsTargetSuggestions > ds_target_table; |
Václav Kubernát | 162165e | 2021-02-22 09:46:53 +0100 | [diff] [blame] | 314 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 315 | auto const cancel = x3::rule<struct cancel_class, cancel_>{"cancel"} = |
Václav Kubernát | e7248b2 | 2020-06-26 15:38:59 +0200 | [diff] [blame] | 316 | cancel_::name >> x3::attr(cancel_{}); |
| 317 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 318 | auto const dump = x3::rule<struct dump_class, dump_>{"dump"} = |
Václav Kubernát | 3b5e652 | 2020-06-26 18:36:09 +0200 | [diff] [blame] | 319 | dump_::name > space_separator >> dump_args; |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 320 | |
Václav Kubernát | f20f6f9 | 2022-04-27 12:13:13 +0200 | [diff] [blame] | 321 | auto const quit = x3::rule<struct quit_class, quit_>{"quit"} = |
Petr Gotthard | 1c76dea | 2022-04-13 17:56:58 +0200 | [diff] [blame] | 322 | quit_::name >> x3::attr(quit_{}); |
| 323 | |
Václav Kubernát | 52b9022 | 2022-04-27 11:29:54 +0200 | [diff] [blame] | 324 | auto const command = x3::rule<command_class, command_>{"command"} = |
Václav Kubernát | 5b8e282 | 2022-01-14 03:19:54 +0100 | [diff] [blame] | 325 | #if BOOST_VERSION <= 107800 |
Václav Kubernát | f9533c2 | 2021-11-04 15:13:30 +0100 | [diff] [blame] | 326 | x3::eps >> |
| 327 | #endif |
Václav Kubernát | 76bb8c2 | 2022-01-19 01:32:31 +0100 | [diff] [blame] | 328 | -space_separator >> createCommandSuggestions >> x3::expect[cd | copy | create | delete_rule | set | commit | get | ls | discard | describe | help | move | dump | prepare | exec | cancel | switch_rule | quit] >> -space_separator; |
Václav Kubernát | 4137845 | 2018-06-06 16:29:40 +0200 | [diff] [blame] | 329 | |
| 330 | #if __clang__ |
| 331 | #pragma GCC diagnostic pop |
| 332 | #endif |