blob: 257401924ad09d04d058e44a837966712b31e6c2 [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
110auto const quotedValue =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100111 ('\'' > +(char_-'\'') > '\'') |
112 ('\"' > +(char_-'\"') > '\"');
Václav Kubernát89728d82018-09-13 16:28:28 +0200113
114auto const number =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100115 +x3::digit;
Václav Kubernát89728d82018-09-13 16:28:28 +0200116
Václav Kubernát329c6c32019-02-06 16:41:53 +0100117auto const createKeySuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100118 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100119
120auto const suggestKeysEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100121 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100122
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200123auto const keyValue_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100124 key_identifier > '=' > (quotedValue | number);
Václav Kubernát329c6c32019-02-06 16:41:53 +0100125
126auto const keyValueWrapper =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100127 lexeme['[' > createKeySuggestions > keyValue > suggestKeysEnd > ']'];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200128
Václav Kubernát744f57f2018-06-29 22:46:26 +0200129auto const module_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100130 lexeme[
131 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
132 ];
Václav Kubernát744f57f2018-06-29 22:46:26 +0200133
134auto const node_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100135 lexeme[
136 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
137 ];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200138
139auto const listPrefix_def =
Václav Kubernát4c325482019-04-11 17:51:55 +0200140 node_identifier;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200141
Václav Kubernát7e4e82f2018-05-14 20:04:58 +0200142// 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 +0200143auto const listSuffix_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100144 *keyValueWrapper;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200145
146auto const listElement_def =
Václav Kubernáte69133a2019-11-01 19:01:34 +0100147 listPrefix >> &char_('[') > listSuffix;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200148
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200149auto const list_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100150 node_identifier >> !char_('[');
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200151
Václav Kubernát60d6f292018-05-25 09:45:32 +0200152auto const nodeup_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100153 lit("..") > x3::attr(nodeup_());
Václav Kubernát60d6f292018-05-25 09:45:32 +0200154
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200155auto const container_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100156 node_identifier;
Václav Kubernát744f57f2018-06-29 22:46:26 +0200157
158auto const module_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100159 module_identifier >> x3::no_skip[':'] >> !x3::no_skip[space];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200160
Václav Kubernát07204242018-06-04 18:12:09 +0200161auto const leaf_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100162 node_identifier;
Václav Kubernát07204242018-06-04 18:12:09 +0200163
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100164auto const createPathSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100165 x3::eps;
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100166
Václav Kubernát07204242018-06-04 18:12:09 +0200167// 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 +0200168auto const schemaNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100169 createPathSuggestions >> -(module) >> (container | list | nodeup | leaf);
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200170
171auto const dataNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100172 createPathSuggestions >> -(module) >> (container | listElement | nodeup | leaf);
Václav Kubernát744f57f2018-06-29 22:46:26 +0200173
Václav Kubernát37171a12018-08-31 17:01:48 +0200174auto const absoluteStart_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100175 x3::omit['/'] >> x3::attr(Scope::Absolute);
Václav Kubernát37171a12018-08-31 17:01:48 +0200176
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100177auto const trailingSlash_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100178 x3::omit['/'] >> x3::attr(TrailingSlash::Present);
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100179
Václav Kubernát8028f942019-09-25 16:03:23 +0200180auto const space_separator_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100181 x3::omit[x3::no_skip[space]];
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100182
Václav Kubernátac035d62019-02-18 10:59:08 +0100183// This is a pseudo-parser, that fails if we're not completing a command
184auto const completing_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100185 x3::eps;
Václav Kubernátac035d62019-02-18 10:59:08 +0100186
Václav Kubernát37171a12018-08-31 17:01:48 +0200187// 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 +0200188auto const dataPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100189 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
190 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200191
Václav Kubernát5c75b252018-10-10 18:33:47 +0200192auto const dataNodeList_def =
Václav Kubernát51853b22019-04-16 21:53:44 +0200193 createPathSuggestions >> -(module) >> list;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200194
195// This intermediate rule is mandatory, because we need the first alternative
196// to be collapsed to a vector. If we didn't use the intermediate rule,
197// Spirit wouldn't know we want it to collapse.
198// https://github.com/boostorg/spirit/issues/408
199auto const dataNodesListEnd_def =
Václav Kubernát211383d2020-01-06 18:07:50 +0100200 dataNode % '/' >> '/' >> dataNodeList >> -(&char_('/') >> createPathSuggestions) |
201 x3::attr(decltype(dataPath_::m_nodes)()) >> dataNodeList;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200202
203auto const dataPathListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100204 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
205 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNodesListEnd >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát5c75b252018-10-10 18:33:47 +0200206
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200207auto const schemaPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100208 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(schemaPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
209 initializePath >> -(absoluteStart >> createPathSuggestions) >> schemaNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát07204242018-06-04 18:12:09 +0200210
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200211auto const leafPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100212 dataPath;
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200213
Václav Kubernát6797df02019-03-18 20:21:50 +0100214auto const presenceContainerPath_def =
215 dataPath;
216
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100217auto const listInstancePath_def =
218 dataPath;
219
Václav Kubernát989b5de2019-02-20 16:28:35 +0100220auto const createEnumSuggestions_def =
221 x3::eps;
222
Václav Kubernátebca2552018-06-08 19:06:02 +0200223auto const leaf_data_enum_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100224 createEnumSuggestions >> +char_;
Václav Kubernát90de9502019-11-20 17:19:44 +0100225
Václav Kubernátebca2552018-06-08 19:06:02 +0200226auto const leaf_data_decimal_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100227 double_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200228
229struct bool_symbol_table : x3::symbols<bool> {
230 bool_symbol_table()
231 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100232 add
233 ("true", true)
234 ("false", false);
Václav Kubernátebca2552018-06-08 19:06:02 +0200235 }
236} const bool_rule;
237
238auto const leaf_data_bool_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100239 bool_rule;
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200240auto const leaf_data_int8_def =
241 int8;
242auto const leaf_data_int16_def =
243 int16;
244auto const leaf_data_int32_def =
245 int32;
246auto const leaf_data_int64_def =
247 int64;
248auto const leaf_data_uint8_def =
249 uint8;
250auto const leaf_data_uint16_def =
251 uint16;
252auto const leaf_data_uint32_def =
253 uint32;
254auto const leaf_data_uint64_def =
255 uint64;
Václav Kubernátebca2552018-06-08 19:06:02 +0200256auto const leaf_data_string_def =
Václav Kubernát1bbac7c2020-01-15 17:45:41 +0100257 '\'' >> *(char_-'\'') >> '\'' |
258 '\"' >> *(char_-'\"') >> '\"';
Václav Kubernátebca2552018-06-08 19:06:02 +0200259
Václav Kubernátab538992019-03-06 15:30:50 +0100260// This intermediate rule is neccessary for coercing to std::string.
261auto const leaf_data_binary_data_def =
262 +(x3::alnum | char_('+') | char_('/')) >> -char_('=') >> -char_('=');
263
264auto const leaf_data_binary_def =
265 leaf_data_binary_data;
266
Václav Kubernáteeb38842019-03-20 19:46:05 +0100267auto const leaf_data_identityRef_data_def =
268 -module >> node_identifier;
269
270auto const createIdentitySuggestions_def =
271 x3::eps;
272
273auto const leaf_data_identityRef_def =
274 createIdentitySuggestions >> leaf_data_identityRef_data;
275
Václav Kubernátebca2552018-06-08 19:06:02 +0200276auto const leaf_data_def =
Václav Kubernátc18ffac2020-01-10 16:06:06 +0100277x3::no_skip[x3::expect[
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100278 leaf_data_enum |
279 leaf_data_decimal |
280 leaf_data_bool |
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200281 leaf_data_int8 |
282 leaf_data_int16 |
283 leaf_data_int32 |
284 leaf_data_int64 |
285 leaf_data_uint8 |
286 leaf_data_uint16 |
287 leaf_data_uint32 |
288 leaf_data_uint64 |
Václav Kubernátab538992019-03-06 15:30:50 +0100289 leaf_data_binary |
Václav Kubernáteeb38842019-03-20 19:46:05 +0100290 leaf_data_identityRef |
Václav Kubernátc18ffac2020-01-10 16:06:06 +0100291 leaf_data_string]];
Václav Kubernát07204242018-06-04 18:12:09 +0200292
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200293struct ls_options_table : x3::symbols<LsOption> {
294 ls_options_table()
295 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100296 add
297 ("--recursive", LsOption::Recursive);
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200298 }
299} const ls_options;
300
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100301// A "nothing" parser, which is used to indicate we tried to parse a path
302auto const initializePath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100303 x3::eps;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200304
Václav Kubernát11afac72018-07-18 14:59:53 +0200305auto const ls_def =
Václav Kubernát9456b5c2019-10-02 21:14:52 +0200306 ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> ((dataPathListEnd | dataPath | schemaPath) | (module >> "*")));
Václav Kubernát11afac72018-07-18 14:59:53 +0200307
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200308auto const cd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100309 cd_::name >> space_separator > dataPath;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200310
Václav Kubernátb61336d2018-05-28 17:35:03 +0200311auto const create_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100312 create_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernátb61336d2018-05-28 17:35:03 +0200313
314auto const delete_rule_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100315 delete_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernát07204242018-06-04 18:12:09 +0200316
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200317auto const get_def =
Václav Kubernát9456b5c2019-10-02 21:14:52 +0200318 get_::name >> -(space_separator >> ((dataPathListEnd | dataPath) | (module >> "*")));
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200319
Václav Kubernát07204242018-06-04 18:12:09 +0200320auto const set_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100321 set_::name >> space_separator > leafPath > space_separator > leaf_data;
Václav Kubernátb61336d2018-05-28 17:35:03 +0200322
Václav Kubernát812ee282018-08-30 17:10:03 +0200323auto const commit_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100324 commit_::name >> x3::attr(commit_());
Václav Kubernát812ee282018-08-30 17:10:03 +0200325
Václav Kubernát6d791432018-10-25 16:00:35 +0200326auto const discard_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100327 discard_::name >> x3::attr(discard_());
Václav Kubernát6d791432018-10-25 16:00:35 +0200328
Václav Kubernát054cc992019-02-21 14:23:52 +0100329struct command_names_table : x3::symbols<decltype(help_::m_cmd)> {
330 command_names_table()
331 {
332 boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([this](auto cmd) {
333 add(commandNamesVisitor()(cmd), decltype(help_::m_cmd)(cmd));
334 });
335 }
336} const command_names;
337
338auto const help_def =
339 help_::name > createCommandSuggestions >> -command_names;
340
Václav Kubernát57272422019-02-08 12:48:24 +0100341auto const createCommandSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100342 x3::eps;
Václav Kubernát57272422019-02-08 12:48:24 +0100343
Václav Kubernátb61336d2018-05-28 17:35:03 +0200344auto const command_def =
Václav Kubernát054cc992019-02-21 14:23:52 +0100345 createCommandSuggestions >> x3::expect[cd | create | delete_rule | set | commit | get | ls | discard | help];
Václav Kubernát41378452018-06-06 16:29:40 +0200346
347#if __clang__
348#pragma GCC diagnostic pop
349#endif
Václav Kubernátb61336d2018-05-28 17:35:03 +0200350
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200351BOOST_SPIRIT_DEFINE(keyValue)
Václav Kubernát89728d82018-09-13 16:28:28 +0200352BOOST_SPIRIT_DEFINE(key_identifier)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200353BOOST_SPIRIT_DEFINE(node_identifier)
354BOOST_SPIRIT_DEFINE(module_identifier)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200355BOOST_SPIRIT_DEFINE(listPrefix)
356BOOST_SPIRIT_DEFINE(listSuffix)
357BOOST_SPIRIT_DEFINE(listElement)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200358BOOST_SPIRIT_DEFINE(list)
Václav Kubernát60d6f292018-05-25 09:45:32 +0200359BOOST_SPIRIT_DEFINE(nodeup)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200360BOOST_SPIRIT_DEFINE(schemaNode)
361BOOST_SPIRIT_DEFINE(dataNode)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200362BOOST_SPIRIT_DEFINE(container)
Václav Kubernát07204242018-06-04 18:12:09 +0200363BOOST_SPIRIT_DEFINE(leaf)
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200364BOOST_SPIRIT_DEFINE(leafPath)
Václav Kubernát6797df02019-03-18 20:21:50 +0100365BOOST_SPIRIT_DEFINE(presenceContainerPath)
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100366BOOST_SPIRIT_DEFINE(listInstancePath)
Václav Kubernát8028f942019-09-25 16:03:23 +0200367BOOST_SPIRIT_DEFINE(space_separator)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200368BOOST_SPIRIT_DEFINE(schemaPath)
369BOOST_SPIRIT_DEFINE(dataPath)
Václav Kubernát5c75b252018-10-10 18:33:47 +0200370BOOST_SPIRIT_DEFINE(dataNodeList)
371BOOST_SPIRIT_DEFINE(dataNodesListEnd)
372BOOST_SPIRIT_DEFINE(dataPathListEnd)
Václav Kubernát37171a12018-08-31 17:01:48 +0200373BOOST_SPIRIT_DEFINE(absoluteStart)
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100374BOOST_SPIRIT_DEFINE(trailingSlash)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200375BOOST_SPIRIT_DEFINE(module)
Václav Kubernátebca2552018-06-08 19:06:02 +0200376BOOST_SPIRIT_DEFINE(leaf_data)
377BOOST_SPIRIT_DEFINE(leaf_data_enum)
378BOOST_SPIRIT_DEFINE(leaf_data_decimal)
379BOOST_SPIRIT_DEFINE(leaf_data_bool)
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200380BOOST_SPIRIT_DEFINE(leaf_data_int8)
381BOOST_SPIRIT_DEFINE(leaf_data_int16)
382BOOST_SPIRIT_DEFINE(leaf_data_int32)
383BOOST_SPIRIT_DEFINE(leaf_data_int64)
384BOOST_SPIRIT_DEFINE(leaf_data_uint8)
385BOOST_SPIRIT_DEFINE(leaf_data_uint16)
386BOOST_SPIRIT_DEFINE(leaf_data_uint32)
387BOOST_SPIRIT_DEFINE(leaf_data_uint64)
Václav Kubernátebca2552018-06-08 19:06:02 +0200388BOOST_SPIRIT_DEFINE(leaf_data_string)
Václav Kubernátab538992019-03-06 15:30:50 +0100389BOOST_SPIRIT_DEFINE(leaf_data_binary_data)
390BOOST_SPIRIT_DEFINE(leaf_data_binary)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100391BOOST_SPIRIT_DEFINE(leaf_data_identityRef_data)
392BOOST_SPIRIT_DEFINE(leaf_data_identityRef)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100393BOOST_SPIRIT_DEFINE(initializePath)
Václav Kubernát07204242018-06-04 18:12:09 +0200394BOOST_SPIRIT_DEFINE(set)
Václav Kubernát812ee282018-08-30 17:10:03 +0200395BOOST_SPIRIT_DEFINE(commit)
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200396BOOST_SPIRIT_DEFINE(get)
Václav Kubernát11afac72018-07-18 14:59:53 +0200397BOOST_SPIRIT_DEFINE(ls)
Václav Kubernát6d791432018-10-25 16:00:35 +0200398BOOST_SPIRIT_DEFINE(discard)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200399BOOST_SPIRIT_DEFINE(cd)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200400BOOST_SPIRIT_DEFINE(create)
401BOOST_SPIRIT_DEFINE(delete_rule)
Václav Kubernát054cc992019-02-21 14:23:52 +0100402BOOST_SPIRIT_DEFINE(help)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200403BOOST_SPIRIT_DEFINE(command)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100404BOOST_SPIRIT_DEFINE(createPathSuggestions)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100405BOOST_SPIRIT_DEFINE(createKeySuggestions)
406BOOST_SPIRIT_DEFINE(suggestKeysEnd)
Václav Kubernát57272422019-02-08 12:48:24 +0100407BOOST_SPIRIT_DEFINE(createCommandSuggestions)
Václav Kubernátac035d62019-02-18 10:59:08 +0100408BOOST_SPIRIT_DEFINE(completing)
Václav Kubernát989b5de2019-02-20 16:28:35 +0100409BOOST_SPIRIT_DEFINE(createEnumSuggestions)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100410BOOST_SPIRIT_DEFINE(createIdentitySuggestions)