blob: 98ed8b7eb83db6461d451946bd4dc9fa492ee394 [file] [log] [blame]
Václav Kubernát0a2a2e82018-05-11 13:59:12 +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
9#pragma once
10
Václav Kubernát509ce652019-05-29 19:46:44 +020011#include <boost/spirit/home/x3.hpp>
Václav Kubernát24df80e2018-06-06 15:18:03 +020012#include "ast_commands.hpp"
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020013#include "ast_handlers.hpp"
14
Václav Kubernát60d6f292018-05-25 09:45:32 +020015
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020016x3::rule<keyValue_class, keyValue_> const keyValue = "keyValue";
Václav Kubernát89728d82018-09-13 16:28:28 +020017x3::rule<key_identifier_class, std::string> const key_identifier = "key_identifier";
Václav Kubernát744f57f2018-06-29 22:46:26 +020018x3::rule<node_identifier_class, std::string> const node_identifier = "node_identifier";
19x3::rule<module_identifier_class, std::string> const module_identifier = "module_identifier";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020020x3::rule<listPrefix_class, std::string> const listPrefix = "listPrefix";
21x3::rule<listSuffix_class, std::vector<keyValue_>> const listSuffix = "listSuffix";
22x3::rule<listElement_class, listElement_> const listElement = "listElement";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020023x3::rule<list_class, list_> const list = "list";
Václav Kubernát60d6f292018-05-25 09:45:32 +020024x3::rule<nodeup_class, nodeup_> const nodeup = "nodeup";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020025x3::rule<container_class, container_> const container = "container";
Václav Kubernát07204242018-06-04 18:12:09 +020026x3::rule<leaf_class, leaf_> const leaf = "leaf";
Václav Kubernát744f57f2018-06-29 22:46:26 +020027x3::rule<module_class, module_> const module = "module";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020028x3::rule<dataNode_class, dataNode_> const dataNode = "dataNode";
29x3::rule<schemaNode_class, schemaNode_> const schemaNode = "schemaNode";
Václav Kubernát37171a12018-08-31 17:01:48 +020030x3::rule<absoluteStart_class, Scope> const absoluteStart = "absoluteStart";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020031x3::rule<schemaPath_class, schemaPath_> const schemaPath = "schemaPath";
Václav Kubernátd6fd2492018-11-19 15:11:16 +010032x3::rule<trailingSlash_class, TrailingSlash> const trailingSlash = "trailingSlash";
Václav Kubernát5c75b252018-10-10 18:33:47 +020033x3::rule<dataNodeList_class, decltype(dataPath_::m_nodes)::value_type> const dataNodeList = "dataNodeList";
34x3::rule<dataNodesListEnd_class, decltype(dataPath_::m_nodes)> const dataNodesListEnd = "dataNodesListEnd";
35x3::rule<dataPathListEnd_class, dataPath_> const dataPathListEnd = "dataPathListEnd";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020036x3::rule<dataPath_class, dataPath_> const dataPath = "dataPath";
37x3::rule<leaf_path_class, dataPath_> const leafPath = "leafPath";
Václav Kubernát6797df02019-03-18 20:21:50 +010038x3::rule<presenceContainerPath_class, dataPath_> const presenceContainerPath = "presenceContainerPath";
Václav Kubernátf5f64f02019-03-19 17:15:47 +010039x3::rule<listInstancePath_class, dataPath_> const listInstancePath = "listInstancePath";
Václav Kubernát8028f942019-09-25 16:03:23 +020040x3::rule<space_separator_class, x3::unused_type> const space_separator = "space_separator";
Václav Kubernátebca2552018-06-08 19:06:02 +020041
42x3::rule<leaf_data_class, leaf_data_> const leaf_data = "leaf_data";
43x3::rule<leaf_data_enum_class, enum_> const leaf_data_enum = "leaf_data_enum";
Ivona Oboňová88c78ca2019-07-02 18:40:07 +020044x3::rule<leaf_data_base_class<yang::LeafDataTypes::Decimal>, double> const leaf_data_decimal = "leaf_data_decimal";
45x3::rule<leaf_data_base_class<yang::LeafDataTypes::Bool>, bool> const leaf_data_bool = "leaf_data_bool";
46x3::rule<leaf_data_base_class<yang::LeafDataTypes::Int8>, int8_t> const leaf_data_int8 = "leaf_data_int8";
47x3::rule<leaf_data_base_class<yang::LeafDataTypes::Uint8>, uint8_t> const leaf_data_uint8 = "leaf_data_uint8";
48x3::rule<leaf_data_base_class<yang::LeafDataTypes::Int16>, int16_t> const leaf_data_int16 = "leaf_data_int16";
49x3::rule<leaf_data_base_class<yang::LeafDataTypes::Uint16>, uint16_t> const leaf_data_uint16 = "leaf_data_uint16";
50x3::rule<leaf_data_base_class<yang::LeafDataTypes::Int32>, int32_t> const leaf_data_int32 = "leaf_data_int32";
51x3::rule<leaf_data_base_class<yang::LeafDataTypes::Uint32>, uint32_t> const leaf_data_uint32 = "leaf_data_uint32";
52x3::rule<leaf_data_base_class<yang::LeafDataTypes::Int64>, int64_t> const leaf_data_int64 = "leaf_data_int64";
53x3::rule<leaf_data_base_class<yang::LeafDataTypes::Uint64>, uint64_t> const leaf_data_uint64 = "leaf_data_uint64";
54x3::rule<leaf_data_base_class<yang::LeafDataTypes::String>, std::string> const leaf_data_string = "leaf_data_string";
Václav Kubernátab538992019-03-06 15:30:50 +010055x3::rule<leaf_data_binary_data_class, std::string> const leaf_data_binary_data = "leaf_data_binary_data";
Ivona Oboňová88c78ca2019-07-02 18:40:07 +020056x3::rule<leaf_data_base_class<yang::LeafDataTypes::Binary>, binary_> const leaf_data_binary = "leaf_data_binary";
Václav Kubernáteeb38842019-03-20 19:46:05 +010057x3::rule<leaf_data_identityRef_data_class, identityRef_> const leaf_data_identityRef_data = "leaf_data_identityRef_data";
58x3::rule<leaf_data_identityRef_class, identityRef_> const leaf_data_identityRef = "leaf_data_identityRef";
Václav Kubernátebca2552018-06-08 19:06:02 +020059
Václav Kubernát6d791432018-10-25 16:00:35 +020060x3::rule<discard_class, discard_> const discard = "discard";
Václav Kubernát11afac72018-07-18 14:59:53 +020061x3::rule<ls_class, ls_> const ls = "ls";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020062x3::rule<cd_class, cd_> const cd = "cd";
Václav Kubernát07204242018-06-04 18:12:09 +020063x3::rule<set_class, set_> const set = "set";
Václav Kubernátb6ff0b62018-08-30 16:14:53 +020064x3::rule<get_class, get_> const get = "get";
Václav Kubernátb61336d2018-05-28 17:35:03 +020065x3::rule<create_class, create_> const create = "create";
66x3::rule<delete_class, delete_> const delete_rule = "delete_rule";
Václav Kubernát812ee282018-08-30 17:10:03 +020067x3::rule<commit_class, commit_> const commit = "commit";
Václav Kubernát054cc992019-02-21 14:23:52 +010068x3::rule<help_class, help_> const help = "help";
Václav Kubernátb61336d2018-05-28 17:35:03 +020069x3::rule<command_class, command_> const command = "command";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020070
Václav Kubernát4108e0d2018-10-29 13:32:22 +010071x3::rule<initializePath_class, x3::unused_type> const initializePath = "initializePath";
72x3::rule<createPathSuggestions_class, x3::unused_type> const createPathSuggestions = "createPathSuggestions";
Václav Kubernát329c6c32019-02-06 16:41:53 +010073x3::rule<createKeySuggestions_class, x3::unused_type> const createKeySuggestions = "createKeySuggestions";
74x3::rule<suggestKeysEnd_class, x3::unused_type> const suggestKeysEnd = "suggestKeysEnd";
Václav Kubernát57272422019-02-08 12:48:24 +010075x3::rule<createCommandSuggestions_class, x3::unused_type> const createCommandSuggestions = "createCommandSuggestions";
Václav Kubernátac035d62019-02-18 10:59:08 +010076x3::rule<completing_class, x3::unused_type> const completing = "completing";
Václav Kubernát989b5de2019-02-20 16:28:35 +010077x3::rule<createEnumSuggestions_class, x3::unused_type> const createEnumSuggestions = "createEnumSuggestions";
Václav Kubernáteeb38842019-03-20 19:46:05 +010078x3::rule<createIdentitySuggestions_class, x3::unused_type> const createIdentitySuggestions = "createIdentitySuggestions";
Václav Kubernát5c75b252018-10-10 18:33:47 +020079
Václav Kubernát41378452018-06-06 16:29:40 +020080#if __clang__
81#pragma GCC diagnostic push
82#pragma GCC diagnostic ignored "-Woverloaded-shift-op-parentheses"
83#endif
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020084
Václav Kubernát509ce652019-05-29 19:46:44 +020085namespace ascii = boost::spirit::x3::ascii;
86
87using ascii::space;
88using x3::_attr;
89using x3::alnum;
90using x3::alpha;
91using x3::char_;
92using x3::double_;
93using x3::expect;
94using x3::lexeme;
95using x3::lit;
96using x3::int8;
97using x3::int16;
98using x3::int32;
99using x3::int64;
100using x3::uint8;
101using x3::uint16;
102using x3::uint32;
103using x3::uint64;
104
Václav Kubernát89728d82018-09-13 16:28:28 +0200105auto const key_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100106 lexeme[
107 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
108 ];
Václav Kubernát89728d82018-09-13 16:28:28 +0200109
Václav Kubernát329c6c32019-02-06 16:41:53 +0100110auto const createKeySuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100111 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100112
113auto const suggestKeysEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100114 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100115
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200116auto const keyValue_def =
Václav Kubernát7707cae2020-01-16 12:04:53 +0100117 key_identifier > '=' > leaf_data;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100118
119auto const keyValueWrapper =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100120 lexeme['[' > createKeySuggestions > keyValue > suggestKeysEnd > ']'];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200121
Václav Kubernát744f57f2018-06-29 22:46:26 +0200122auto const module_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100123 lexeme[
124 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
125 ];
Václav Kubernát744f57f2018-06-29 22:46:26 +0200126
127auto const node_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100128 lexeme[
129 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
130 ];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200131
132auto const listPrefix_def =
Václav Kubernát4c325482019-04-11 17:51:55 +0200133 node_identifier;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200134
Václav Kubernát7e4e82f2018-05-14 20:04:58 +0200135// even though we don't allow no keys to be supplied, the star allows me to check which keys are missing
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200136auto const listSuffix_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100137 *keyValueWrapper;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200138
139auto const listElement_def =
Václav Kubernáte69133a2019-11-01 19:01:34 +0100140 listPrefix >> &char_('[') > listSuffix;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200141
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200142auto const list_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100143 node_identifier >> !char_('[');
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200144
Václav Kubernát60d6f292018-05-25 09:45:32 +0200145auto const nodeup_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100146 lit("..") > x3::attr(nodeup_());
Václav Kubernát60d6f292018-05-25 09:45:32 +0200147
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200148auto const container_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100149 node_identifier;
Václav Kubernát744f57f2018-06-29 22:46:26 +0200150
151auto const module_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100152 module_identifier >> x3::no_skip[':'] >> !x3::no_skip[space];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200153
Václav Kubernát07204242018-06-04 18:12:09 +0200154auto const leaf_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100155 node_identifier;
Václav Kubernát07204242018-06-04 18:12:09 +0200156
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100157auto const createPathSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100158 x3::eps;
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100159
Václav Kubernát07204242018-06-04 18:12:09 +0200160// leaf cannot be in the middle of a path, however, I need the grammar's attribute to be a vector of variants
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200161auto const schemaNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100162 createPathSuggestions >> -(module) >> (container | list | nodeup | leaf);
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200163
164auto const dataNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100165 createPathSuggestions >> -(module) >> (container | listElement | nodeup | leaf);
Václav Kubernát744f57f2018-06-29 22:46:26 +0200166
Václav Kubernát37171a12018-08-31 17:01:48 +0200167auto const absoluteStart_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100168 x3::omit['/'] >> x3::attr(Scope::Absolute);
Václav Kubernát37171a12018-08-31 17:01:48 +0200169
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100170auto const trailingSlash_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100171 x3::omit['/'] >> x3::attr(TrailingSlash::Present);
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100172
Václav Kubernát8028f942019-09-25 16:03:23 +0200173auto const space_separator_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100174 x3::omit[x3::no_skip[space]];
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100175
Václav Kubernátac035d62019-02-18 10:59:08 +0100176// This is a pseudo-parser, that fails if we're not completing a command
177auto const completing_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100178 x3::eps;
Václav Kubernátac035d62019-02-18 10:59:08 +0100179
Václav Kubernát37171a12018-08-31 17:01:48 +0200180// I have to insert an empty vector to the first alternative, otherwise they won't have the same attribute
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200181auto const dataPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100182 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
183 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200184
Václav Kubernát5c75b252018-10-10 18:33:47 +0200185auto const dataNodeList_def =
Václav Kubernát51853b22019-04-16 21:53:44 +0200186 createPathSuggestions >> -(module) >> list;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200187
188// This intermediate rule is mandatory, because we need the first alternative
189// to be collapsed to a vector. If we didn't use the intermediate rule,
190// Spirit wouldn't know we want it to collapse.
191// https://github.com/boostorg/spirit/issues/408
192auto const dataNodesListEnd_def =
Václav Kubernát211383d2020-01-06 18:07:50 +0100193 dataNode % '/' >> '/' >> dataNodeList >> -(&char_('/') >> createPathSuggestions) |
194 x3::attr(decltype(dataPath_::m_nodes)()) >> dataNodeList;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200195
196auto const dataPathListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100197 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
198 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNodesListEnd >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát5c75b252018-10-10 18:33:47 +0200199
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200200auto const schemaPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100201 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(schemaPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
202 initializePath >> -(absoluteStart >> createPathSuggestions) >> schemaNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát07204242018-06-04 18:12:09 +0200203
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200204auto const leafPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100205 dataPath;
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200206
Václav Kubernát6797df02019-03-18 20:21:50 +0100207auto const presenceContainerPath_def =
208 dataPath;
209
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100210auto const listInstancePath_def =
211 dataPath;
212
Václav Kubernát989b5de2019-02-20 16:28:35 +0100213auto const createEnumSuggestions_def =
214 x3::eps;
215
Václav Kubernátebca2552018-06-08 19:06:02 +0200216auto const leaf_data_enum_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100217 createEnumSuggestions >> +char_;
Václav Kubernát90de9502019-11-20 17:19:44 +0100218
Václav Kubernátebca2552018-06-08 19:06:02 +0200219auto const leaf_data_decimal_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100220 double_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200221
222struct bool_symbol_table : x3::symbols<bool> {
223 bool_symbol_table()
224 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100225 add
226 ("true", true)
227 ("false", false);
Václav Kubernátebca2552018-06-08 19:06:02 +0200228 }
229} const bool_rule;
230
231auto const leaf_data_bool_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100232 bool_rule;
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200233auto const leaf_data_int8_def =
234 int8;
235auto const leaf_data_int16_def =
236 int16;
237auto const leaf_data_int32_def =
238 int32;
239auto const leaf_data_int64_def =
240 int64;
241auto const leaf_data_uint8_def =
242 uint8;
243auto const leaf_data_uint16_def =
244 uint16;
245auto const leaf_data_uint32_def =
246 uint32;
247auto const leaf_data_uint64_def =
248 uint64;
Václav Kubernátebca2552018-06-08 19:06:02 +0200249auto const leaf_data_string_def =
Václav Kubernát1bbac7c2020-01-15 17:45:41 +0100250 '\'' >> *(char_-'\'') >> '\'' |
251 '\"' >> *(char_-'\"') >> '\"';
Václav Kubernátebca2552018-06-08 19:06:02 +0200252
Václav Kubernátab538992019-03-06 15:30:50 +0100253// This intermediate rule is neccessary for coercing to std::string.
254auto const leaf_data_binary_data_def =
255 +(x3::alnum | char_('+') | char_('/')) >> -char_('=') >> -char_('=');
256
257auto const leaf_data_binary_def =
258 leaf_data_binary_data;
259
Václav Kubernáteeb38842019-03-20 19:46:05 +0100260auto const leaf_data_identityRef_data_def =
261 -module >> node_identifier;
262
263auto const createIdentitySuggestions_def =
264 x3::eps;
265
266auto const leaf_data_identityRef_def =
267 createIdentitySuggestions >> leaf_data_identityRef_data;
268
Václav Kubernátebca2552018-06-08 19:06:02 +0200269auto const leaf_data_def =
Václav Kubernátc18ffac2020-01-10 16:06:06 +0100270x3::no_skip[x3::expect[
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100271 leaf_data_enum |
272 leaf_data_decimal |
273 leaf_data_bool |
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200274 leaf_data_int8 |
275 leaf_data_int16 |
276 leaf_data_int32 |
277 leaf_data_int64 |
278 leaf_data_uint8 |
279 leaf_data_uint16 |
280 leaf_data_uint32 |
281 leaf_data_uint64 |
Václav Kubernátab538992019-03-06 15:30:50 +0100282 leaf_data_binary |
Václav Kubernáteeb38842019-03-20 19:46:05 +0100283 leaf_data_identityRef |
Václav Kubernátc18ffac2020-01-10 16:06:06 +0100284 leaf_data_string]];
Václav Kubernát07204242018-06-04 18:12:09 +0200285
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200286struct ls_options_table : x3::symbols<LsOption> {
287 ls_options_table()
288 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100289 add
290 ("--recursive", LsOption::Recursive);
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200291 }
292} const ls_options;
293
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100294// A "nothing" parser, which is used to indicate we tried to parse a path
295auto const initializePath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100296 x3::eps;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200297
Václav Kubernát11afac72018-07-18 14:59:53 +0200298auto const ls_def =
Václav Kubernát9456b5c2019-10-02 21:14:52 +0200299 ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> ((dataPathListEnd | dataPath | schemaPath) | (module >> "*")));
Václav Kubernát11afac72018-07-18 14:59:53 +0200300
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200301auto const cd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100302 cd_::name >> space_separator > dataPath;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200303
Václav Kubernátb61336d2018-05-28 17:35:03 +0200304auto const create_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100305 create_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernátb61336d2018-05-28 17:35:03 +0200306
307auto const delete_rule_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100308 delete_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernát07204242018-06-04 18:12:09 +0200309
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200310auto const get_def =
Václav Kubernát9456b5c2019-10-02 21:14:52 +0200311 get_::name >> -(space_separator >> ((dataPathListEnd | dataPath) | (module >> "*")));
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200312
Václav Kubernát07204242018-06-04 18:12:09 +0200313auto const set_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100314 set_::name >> space_separator > leafPath > space_separator > leaf_data;
Václav Kubernátb61336d2018-05-28 17:35:03 +0200315
Václav Kubernát812ee282018-08-30 17:10:03 +0200316auto const commit_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100317 commit_::name >> x3::attr(commit_());
Václav Kubernát812ee282018-08-30 17:10:03 +0200318
Václav Kubernát6d791432018-10-25 16:00:35 +0200319auto const discard_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100320 discard_::name >> x3::attr(discard_());
Václav Kubernát6d791432018-10-25 16:00:35 +0200321
Václav Kubernát054cc992019-02-21 14:23:52 +0100322struct command_names_table : x3::symbols<decltype(help_::m_cmd)> {
323 command_names_table()
324 {
325 boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([this](auto cmd) {
326 add(commandNamesVisitor()(cmd), decltype(help_::m_cmd)(cmd));
327 });
328 }
329} const command_names;
330
331auto const help_def =
332 help_::name > createCommandSuggestions >> -command_names;
333
Václav Kubernát57272422019-02-08 12:48:24 +0100334auto const createCommandSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100335 x3::eps;
Václav Kubernát57272422019-02-08 12:48:24 +0100336
Václav Kubernátb61336d2018-05-28 17:35:03 +0200337auto const command_def =
Václav Kubernát054cc992019-02-21 14:23:52 +0100338 createCommandSuggestions >> x3::expect[cd | create | delete_rule | set | commit | get | ls | discard | help];
Václav Kubernát41378452018-06-06 16:29:40 +0200339
340#if __clang__
341#pragma GCC diagnostic pop
342#endif
Václav Kubernátb61336d2018-05-28 17:35:03 +0200343
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200344BOOST_SPIRIT_DEFINE(keyValue)
Václav Kubernát89728d82018-09-13 16:28:28 +0200345BOOST_SPIRIT_DEFINE(key_identifier)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200346BOOST_SPIRIT_DEFINE(node_identifier)
347BOOST_SPIRIT_DEFINE(module_identifier)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200348BOOST_SPIRIT_DEFINE(listPrefix)
349BOOST_SPIRIT_DEFINE(listSuffix)
350BOOST_SPIRIT_DEFINE(listElement)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200351BOOST_SPIRIT_DEFINE(list)
Václav Kubernát60d6f292018-05-25 09:45:32 +0200352BOOST_SPIRIT_DEFINE(nodeup)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200353BOOST_SPIRIT_DEFINE(schemaNode)
354BOOST_SPIRIT_DEFINE(dataNode)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200355BOOST_SPIRIT_DEFINE(container)
Václav Kubernát07204242018-06-04 18:12:09 +0200356BOOST_SPIRIT_DEFINE(leaf)
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200357BOOST_SPIRIT_DEFINE(leafPath)
Václav Kubernát6797df02019-03-18 20:21:50 +0100358BOOST_SPIRIT_DEFINE(presenceContainerPath)
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100359BOOST_SPIRIT_DEFINE(listInstancePath)
Václav Kubernát8028f942019-09-25 16:03:23 +0200360BOOST_SPIRIT_DEFINE(space_separator)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200361BOOST_SPIRIT_DEFINE(schemaPath)
362BOOST_SPIRIT_DEFINE(dataPath)
Václav Kubernát5c75b252018-10-10 18:33:47 +0200363BOOST_SPIRIT_DEFINE(dataNodeList)
364BOOST_SPIRIT_DEFINE(dataNodesListEnd)
365BOOST_SPIRIT_DEFINE(dataPathListEnd)
Václav Kubernát37171a12018-08-31 17:01:48 +0200366BOOST_SPIRIT_DEFINE(absoluteStart)
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100367BOOST_SPIRIT_DEFINE(trailingSlash)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200368BOOST_SPIRIT_DEFINE(module)
Václav Kubernátebca2552018-06-08 19:06:02 +0200369BOOST_SPIRIT_DEFINE(leaf_data)
370BOOST_SPIRIT_DEFINE(leaf_data_enum)
371BOOST_SPIRIT_DEFINE(leaf_data_decimal)
372BOOST_SPIRIT_DEFINE(leaf_data_bool)
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200373BOOST_SPIRIT_DEFINE(leaf_data_int8)
374BOOST_SPIRIT_DEFINE(leaf_data_int16)
375BOOST_SPIRIT_DEFINE(leaf_data_int32)
376BOOST_SPIRIT_DEFINE(leaf_data_int64)
377BOOST_SPIRIT_DEFINE(leaf_data_uint8)
378BOOST_SPIRIT_DEFINE(leaf_data_uint16)
379BOOST_SPIRIT_DEFINE(leaf_data_uint32)
380BOOST_SPIRIT_DEFINE(leaf_data_uint64)
Václav Kubernátebca2552018-06-08 19:06:02 +0200381BOOST_SPIRIT_DEFINE(leaf_data_string)
Václav Kubernátab538992019-03-06 15:30:50 +0100382BOOST_SPIRIT_DEFINE(leaf_data_binary_data)
383BOOST_SPIRIT_DEFINE(leaf_data_binary)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100384BOOST_SPIRIT_DEFINE(leaf_data_identityRef_data)
385BOOST_SPIRIT_DEFINE(leaf_data_identityRef)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100386BOOST_SPIRIT_DEFINE(initializePath)
Václav Kubernát07204242018-06-04 18:12:09 +0200387BOOST_SPIRIT_DEFINE(set)
Václav Kubernát812ee282018-08-30 17:10:03 +0200388BOOST_SPIRIT_DEFINE(commit)
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200389BOOST_SPIRIT_DEFINE(get)
Václav Kubernát11afac72018-07-18 14:59:53 +0200390BOOST_SPIRIT_DEFINE(ls)
Václav Kubernát6d791432018-10-25 16:00:35 +0200391BOOST_SPIRIT_DEFINE(discard)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200392BOOST_SPIRIT_DEFINE(cd)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200393BOOST_SPIRIT_DEFINE(create)
394BOOST_SPIRIT_DEFINE(delete_rule)
Václav Kubernát054cc992019-02-21 14:23:52 +0100395BOOST_SPIRIT_DEFINE(help)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200396BOOST_SPIRIT_DEFINE(command)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100397BOOST_SPIRIT_DEFINE(createPathSuggestions)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100398BOOST_SPIRIT_DEFINE(createKeySuggestions)
399BOOST_SPIRIT_DEFINE(suggestKeysEnd)
Václav Kubernát57272422019-02-08 12:48:24 +0100400BOOST_SPIRIT_DEFINE(createCommandSuggestions)
Václav Kubernátac035d62019-02-18 10:59:08 +0100401BOOST_SPIRIT_DEFINE(completing)
Václav Kubernát989b5de2019-02-20 16:28:35 +0100402BOOST_SPIRIT_DEFINE(createEnumSuggestions)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100403BOOST_SPIRIT_DEFINE(createIdentitySuggestions)