blob: 11d1db0f9be4a1033be9dac225c3f8a63688e5ac [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";
Václav Kubernát43908fb2020-01-02 19:05:51 +010074x3::rule<createValueSuggestions_class, x3::unused_type> const createValueSuggestions = "createValueSuggestions";
Václav Kubernát329c6c32019-02-06 16:41:53 +010075x3::rule<suggestKeysEnd_class, x3::unused_type> const suggestKeysEnd = "suggestKeysEnd";
Václav Kubernát57272422019-02-08 12:48:24 +010076x3::rule<createCommandSuggestions_class, x3::unused_type> const createCommandSuggestions = "createCommandSuggestions";
Václav Kubernátac035d62019-02-18 10:59:08 +010077x3::rule<completing_class, x3::unused_type> const completing = "completing";
Václav Kubernát989b5de2019-02-20 16:28:35 +010078x3::rule<createEnumSuggestions_class, x3::unused_type> const createEnumSuggestions = "createEnumSuggestions";
Václav Kubernáteeb38842019-03-20 19:46:05 +010079x3::rule<createIdentitySuggestions_class, x3::unused_type> const createIdentitySuggestions = "createIdentitySuggestions";
Václav Kubernát5c75b252018-10-10 18:33:47 +020080
Václav Kubernát41378452018-06-06 16:29:40 +020081#if __clang__
82#pragma GCC diagnostic push
83#pragma GCC diagnostic ignored "-Woverloaded-shift-op-parentheses"
84#endif
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020085
Václav Kubernát509ce652019-05-29 19:46:44 +020086namespace ascii = boost::spirit::x3::ascii;
87
88using ascii::space;
89using x3::_attr;
90using x3::alnum;
91using x3::alpha;
92using x3::char_;
93using x3::double_;
94using x3::expect;
95using x3::lexeme;
96using x3::lit;
97using x3::int8;
98using x3::int16;
99using x3::int32;
100using x3::int64;
101using x3::uint8;
102using x3::uint16;
103using x3::uint32;
104using x3::uint64;
105
Václav Kubernát89728d82018-09-13 16:28:28 +0200106auto const key_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100107 lexeme[
108 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
109 ];
Václav Kubernát89728d82018-09-13 16:28:28 +0200110
Václav Kubernát329c6c32019-02-06 16:41:53 +0100111auto const createKeySuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100112 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100113
Václav Kubernát43908fb2020-01-02 19:05:51 +0100114auto const createValueSuggestions_def =
115 x3::eps;
116
Václav Kubernát329c6c32019-02-06 16:41:53 +0100117auto const suggestKeysEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100118 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100119
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200120auto const keyValue_def =
Václav Kubernát43908fb2020-01-02 19:05:51 +0100121 key_identifier > '=' > createValueSuggestions > leaf_data;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100122
123auto const keyValueWrapper =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100124 lexeme['[' > createKeySuggestions > keyValue > suggestKeysEnd > ']'];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200125
Václav Kubernát744f57f2018-06-29 22:46:26 +0200126auto const module_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100127 lexeme[
128 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
129 ];
Václav Kubernát744f57f2018-06-29 22:46:26 +0200130
131auto const node_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100132 lexeme[
133 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
134 ];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200135
136auto const listPrefix_def =
Václav Kubernát4c325482019-04-11 17:51:55 +0200137 node_identifier;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200138
Václav Kubernát7e4e82f2018-05-14 20:04:58 +0200139// 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 +0200140auto const listSuffix_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100141 *keyValueWrapper;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200142
143auto const listElement_def =
Václav Kubernáte69133a2019-11-01 19:01:34 +0100144 listPrefix >> &char_('[') > listSuffix;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200145
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200146auto const list_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100147 node_identifier >> !char_('[');
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200148
Václav Kubernát60d6f292018-05-25 09:45:32 +0200149auto const nodeup_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100150 lit("..") > x3::attr(nodeup_());
Václav Kubernát60d6f292018-05-25 09:45:32 +0200151
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200152auto const container_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100153 node_identifier;
Václav Kubernát744f57f2018-06-29 22:46:26 +0200154
155auto const module_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100156 module_identifier >> x3::no_skip[':'] >> !x3::no_skip[space];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200157
Václav Kubernát07204242018-06-04 18:12:09 +0200158auto const leaf_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100159 node_identifier;
Václav Kubernát07204242018-06-04 18:12:09 +0200160
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100161auto const createPathSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100162 x3::eps;
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100163
Václav Kubernát07204242018-06-04 18:12:09 +0200164// 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 +0200165auto const schemaNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100166 createPathSuggestions >> -(module) >> (container | list | nodeup | leaf);
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200167
168auto const dataNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100169 createPathSuggestions >> -(module) >> (container | listElement | nodeup | leaf);
Václav Kubernát744f57f2018-06-29 22:46:26 +0200170
Václav Kubernát37171a12018-08-31 17:01:48 +0200171auto const absoluteStart_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100172 x3::omit['/'] >> x3::attr(Scope::Absolute);
Václav Kubernát37171a12018-08-31 17:01:48 +0200173
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100174auto const trailingSlash_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100175 x3::omit['/'] >> x3::attr(TrailingSlash::Present);
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100176
Václav Kubernát8028f942019-09-25 16:03:23 +0200177auto const space_separator_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100178 x3::omit[x3::no_skip[space]];
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100179
Václav Kubernátac035d62019-02-18 10:59:08 +0100180// This is a pseudo-parser, that fails if we're not completing a command
181auto const completing_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100182 x3::eps;
Václav Kubernátac035d62019-02-18 10:59:08 +0100183
Václav Kubernát37171a12018-08-31 17:01:48 +0200184// 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 +0200185auto const dataPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100186 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
187 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200188
Václav Kubernát5c75b252018-10-10 18:33:47 +0200189auto const dataNodeList_def =
Václav Kubernát51853b22019-04-16 21:53:44 +0200190 createPathSuggestions >> -(module) >> list;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200191
192// This intermediate rule is mandatory, because we need the first alternative
193// to be collapsed to a vector. If we didn't use the intermediate rule,
194// Spirit wouldn't know we want it to collapse.
195// https://github.com/boostorg/spirit/issues/408
196auto const dataNodesListEnd_def =
Václav Kubernát211383d2020-01-06 18:07:50 +0100197 dataNode % '/' >> '/' >> dataNodeList >> -(&char_('/') >> createPathSuggestions) |
198 x3::attr(decltype(dataPath_::m_nodes)()) >> dataNodeList;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200199
200auto const dataPathListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100201 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
202 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNodesListEnd >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát5c75b252018-10-10 18:33:47 +0200203
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200204auto const schemaPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100205 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(schemaPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
206 initializePath >> -(absoluteStart >> createPathSuggestions) >> schemaNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát07204242018-06-04 18:12:09 +0200207
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200208auto const leafPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100209 dataPath;
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200210
Václav Kubernát6797df02019-03-18 20:21:50 +0100211auto const presenceContainerPath_def =
212 dataPath;
213
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100214auto const listInstancePath_def =
215 dataPath;
216
Václav Kubernát989b5de2019-02-20 16:28:35 +0100217auto const createEnumSuggestions_def =
218 x3::eps;
219
Václav Kubernátebca2552018-06-08 19:06:02 +0200220auto const leaf_data_enum_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100221 createEnumSuggestions >> +char_;
Václav Kubernát90de9502019-11-20 17:19:44 +0100222
Václav Kubernátebca2552018-06-08 19:06:02 +0200223auto const leaf_data_decimal_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100224 double_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200225
226struct bool_symbol_table : x3::symbols<bool> {
227 bool_symbol_table()
228 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100229 add
230 ("true", true)
231 ("false", false);
Václav Kubernátebca2552018-06-08 19:06:02 +0200232 }
233} const bool_rule;
234
235auto const leaf_data_bool_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100236 bool_rule;
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200237auto const leaf_data_int8_def =
238 int8;
239auto const leaf_data_int16_def =
240 int16;
241auto const leaf_data_int32_def =
242 int32;
243auto const leaf_data_int64_def =
244 int64;
245auto const leaf_data_uint8_def =
246 uint8;
247auto const leaf_data_uint16_def =
248 uint16;
249auto const leaf_data_uint32_def =
250 uint32;
251auto const leaf_data_uint64_def =
252 uint64;
Václav Kubernátebca2552018-06-08 19:06:02 +0200253auto const leaf_data_string_def =
Václav Kubernát1bbac7c2020-01-15 17:45:41 +0100254 '\'' >> *(char_-'\'') >> '\'' |
255 '\"' >> *(char_-'\"') >> '\"';
Václav Kubernátebca2552018-06-08 19:06:02 +0200256
Václav Kubernátab538992019-03-06 15:30:50 +0100257// This intermediate rule is neccessary for coercing to std::string.
258auto const leaf_data_binary_data_def =
259 +(x3::alnum | char_('+') | char_('/')) >> -char_('=') >> -char_('=');
260
261auto const leaf_data_binary_def =
262 leaf_data_binary_data;
263
Václav Kubernáteeb38842019-03-20 19:46:05 +0100264auto const leaf_data_identityRef_data_def =
265 -module >> node_identifier;
266
267auto const createIdentitySuggestions_def =
268 x3::eps;
269
270auto const leaf_data_identityRef_def =
271 createIdentitySuggestions >> leaf_data_identityRef_data;
272
Václav Kubernátebca2552018-06-08 19:06:02 +0200273auto const leaf_data_def =
Václav Kubernátc18ffac2020-01-10 16:06:06 +0100274x3::no_skip[x3::expect[
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100275 leaf_data_enum |
276 leaf_data_decimal |
277 leaf_data_bool |
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200278 leaf_data_int8 |
279 leaf_data_int16 |
280 leaf_data_int32 |
281 leaf_data_int64 |
282 leaf_data_uint8 |
283 leaf_data_uint16 |
284 leaf_data_uint32 |
285 leaf_data_uint64 |
Václav Kubernátab538992019-03-06 15:30:50 +0100286 leaf_data_binary |
Václav Kubernáteeb38842019-03-20 19:46:05 +0100287 leaf_data_identityRef |
Václav Kubernátc18ffac2020-01-10 16:06:06 +0100288 leaf_data_string]];
Václav Kubernát07204242018-06-04 18:12:09 +0200289
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200290struct ls_options_table : x3::symbols<LsOption> {
291 ls_options_table()
292 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100293 add
294 ("--recursive", LsOption::Recursive);
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200295 }
296} const ls_options;
297
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100298// A "nothing" parser, which is used to indicate we tried to parse a path
299auto const initializePath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100300 x3::eps;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200301
Václav Kubernát11afac72018-07-18 14:59:53 +0200302auto const ls_def =
Václav Kubernát9456b5c2019-10-02 21:14:52 +0200303 ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> ((dataPathListEnd | dataPath | schemaPath) | (module >> "*")));
Václav Kubernát11afac72018-07-18 14:59:53 +0200304
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200305auto const cd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100306 cd_::name >> space_separator > dataPath;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200307
Václav Kubernátb61336d2018-05-28 17:35:03 +0200308auto const create_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100309 create_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernátb61336d2018-05-28 17:35:03 +0200310
311auto const delete_rule_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100312 delete_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernát07204242018-06-04 18:12:09 +0200313
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200314auto const get_def =
Václav Kubernát9456b5c2019-10-02 21:14:52 +0200315 get_::name >> -(space_separator >> ((dataPathListEnd | dataPath) | (module >> "*")));
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200316
Václav Kubernát07204242018-06-04 18:12:09 +0200317auto const set_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100318 set_::name >> space_separator > leafPath > space_separator > leaf_data;
Václav Kubernátb61336d2018-05-28 17:35:03 +0200319
Václav Kubernát812ee282018-08-30 17:10:03 +0200320auto const commit_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100321 commit_::name >> x3::attr(commit_());
Václav Kubernát812ee282018-08-30 17:10:03 +0200322
Václav Kubernát6d791432018-10-25 16:00:35 +0200323auto const discard_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100324 discard_::name >> x3::attr(discard_());
Václav Kubernát6d791432018-10-25 16:00:35 +0200325
Václav Kubernát054cc992019-02-21 14:23:52 +0100326struct command_names_table : x3::symbols<decltype(help_::m_cmd)> {
327 command_names_table()
328 {
329 boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([this](auto cmd) {
330 add(commandNamesVisitor()(cmd), decltype(help_::m_cmd)(cmd));
331 });
332 }
333} const command_names;
334
335auto const help_def =
336 help_::name > createCommandSuggestions >> -command_names;
337
Václav Kubernát57272422019-02-08 12:48:24 +0100338auto const createCommandSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100339 x3::eps;
Václav Kubernát57272422019-02-08 12:48:24 +0100340
Václav Kubernátb61336d2018-05-28 17:35:03 +0200341auto const command_def =
Václav Kubernát054cc992019-02-21 14:23:52 +0100342 createCommandSuggestions >> x3::expect[cd | create | delete_rule | set | commit | get | ls | discard | help];
Václav Kubernát41378452018-06-06 16:29:40 +0200343
344#if __clang__
345#pragma GCC diagnostic pop
346#endif
Václav Kubernátb61336d2018-05-28 17:35:03 +0200347
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200348BOOST_SPIRIT_DEFINE(keyValue)
Václav Kubernát89728d82018-09-13 16:28:28 +0200349BOOST_SPIRIT_DEFINE(key_identifier)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200350BOOST_SPIRIT_DEFINE(node_identifier)
351BOOST_SPIRIT_DEFINE(module_identifier)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200352BOOST_SPIRIT_DEFINE(listPrefix)
353BOOST_SPIRIT_DEFINE(listSuffix)
354BOOST_SPIRIT_DEFINE(listElement)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200355BOOST_SPIRIT_DEFINE(list)
Václav Kubernát60d6f292018-05-25 09:45:32 +0200356BOOST_SPIRIT_DEFINE(nodeup)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200357BOOST_SPIRIT_DEFINE(schemaNode)
358BOOST_SPIRIT_DEFINE(dataNode)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200359BOOST_SPIRIT_DEFINE(container)
Václav Kubernát07204242018-06-04 18:12:09 +0200360BOOST_SPIRIT_DEFINE(leaf)
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200361BOOST_SPIRIT_DEFINE(leafPath)
Václav Kubernát6797df02019-03-18 20:21:50 +0100362BOOST_SPIRIT_DEFINE(presenceContainerPath)
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100363BOOST_SPIRIT_DEFINE(listInstancePath)
Václav Kubernát8028f942019-09-25 16:03:23 +0200364BOOST_SPIRIT_DEFINE(space_separator)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200365BOOST_SPIRIT_DEFINE(schemaPath)
366BOOST_SPIRIT_DEFINE(dataPath)
Václav Kubernát5c75b252018-10-10 18:33:47 +0200367BOOST_SPIRIT_DEFINE(dataNodeList)
368BOOST_SPIRIT_DEFINE(dataNodesListEnd)
369BOOST_SPIRIT_DEFINE(dataPathListEnd)
Václav Kubernát37171a12018-08-31 17:01:48 +0200370BOOST_SPIRIT_DEFINE(absoluteStart)
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100371BOOST_SPIRIT_DEFINE(trailingSlash)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200372BOOST_SPIRIT_DEFINE(module)
Václav Kubernátebca2552018-06-08 19:06:02 +0200373BOOST_SPIRIT_DEFINE(leaf_data)
374BOOST_SPIRIT_DEFINE(leaf_data_enum)
375BOOST_SPIRIT_DEFINE(leaf_data_decimal)
376BOOST_SPIRIT_DEFINE(leaf_data_bool)
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200377BOOST_SPIRIT_DEFINE(leaf_data_int8)
378BOOST_SPIRIT_DEFINE(leaf_data_int16)
379BOOST_SPIRIT_DEFINE(leaf_data_int32)
380BOOST_SPIRIT_DEFINE(leaf_data_int64)
381BOOST_SPIRIT_DEFINE(leaf_data_uint8)
382BOOST_SPIRIT_DEFINE(leaf_data_uint16)
383BOOST_SPIRIT_DEFINE(leaf_data_uint32)
384BOOST_SPIRIT_DEFINE(leaf_data_uint64)
Václav Kubernátebca2552018-06-08 19:06:02 +0200385BOOST_SPIRIT_DEFINE(leaf_data_string)
Václav Kubernátab538992019-03-06 15:30:50 +0100386BOOST_SPIRIT_DEFINE(leaf_data_binary_data)
387BOOST_SPIRIT_DEFINE(leaf_data_binary)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100388BOOST_SPIRIT_DEFINE(leaf_data_identityRef_data)
389BOOST_SPIRIT_DEFINE(leaf_data_identityRef)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100390BOOST_SPIRIT_DEFINE(initializePath)
Václav Kubernát07204242018-06-04 18:12:09 +0200391BOOST_SPIRIT_DEFINE(set)
Václav Kubernát812ee282018-08-30 17:10:03 +0200392BOOST_SPIRIT_DEFINE(commit)
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200393BOOST_SPIRIT_DEFINE(get)
Václav Kubernát11afac72018-07-18 14:59:53 +0200394BOOST_SPIRIT_DEFINE(ls)
Václav Kubernát6d791432018-10-25 16:00:35 +0200395BOOST_SPIRIT_DEFINE(discard)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200396BOOST_SPIRIT_DEFINE(cd)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200397BOOST_SPIRIT_DEFINE(create)
398BOOST_SPIRIT_DEFINE(delete_rule)
Václav Kubernát054cc992019-02-21 14:23:52 +0100399BOOST_SPIRIT_DEFINE(help)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200400BOOST_SPIRIT_DEFINE(command)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100401BOOST_SPIRIT_DEFINE(createPathSuggestions)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100402BOOST_SPIRIT_DEFINE(createKeySuggestions)
Václav Kubernát43908fb2020-01-02 19:05:51 +0100403BOOST_SPIRIT_DEFINE(createValueSuggestions)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100404BOOST_SPIRIT_DEFINE(suggestKeysEnd)
Václav Kubernát57272422019-02-08 12:48:24 +0100405BOOST_SPIRIT_DEFINE(createCommandSuggestions)
Václav Kubernátac035d62019-02-18 10:59:08 +0100406BOOST_SPIRIT_DEFINE(completing)
Václav Kubernát989b5de2019-02-20 16:28:35 +0100407BOOST_SPIRIT_DEFINE(createEnumSuggestions)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100408BOOST_SPIRIT_DEFINE(createIdentitySuggestions)