blob: 2c511ad4b3715fe93afa28769fa80808d3603dd9 [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át4c325482019-04-11 17:51:55 +020074x3::rule<suggestKeysStart_class, x3::unused_type> const suggestKeysStart = "suggestKeysStart";
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
111auto const quotedValue =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100112 ('\'' > +(char_-'\'') > '\'') |
113 ('\"' > +(char_-'\"') > '\"');
Václav Kubernát89728d82018-09-13 16:28:28 +0200114
115auto const number =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100116 +x3::digit;
Václav Kubernát89728d82018-09-13 16:28:28 +0200117
Václav Kubernát329c6c32019-02-06 16:41:53 +0100118auto const createKeySuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100119 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100120
Václav Kubernát4c325482019-04-11 17:51:55 +0200121auto const suggestKeysStart_def =
122 x3::eps;
123
Václav Kubernát329c6c32019-02-06 16:41:53 +0100124auto const suggestKeysEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100125 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +0100126
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200127auto const keyValue_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100128 key_identifier > '=' > (quotedValue | number);
Václav Kubernát329c6c32019-02-06 16:41:53 +0100129
130auto const keyValueWrapper =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100131 lexeme['[' > createKeySuggestions > keyValue > suggestKeysEnd > ']'];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200132
Václav Kubernát744f57f2018-06-29 22:46:26 +0200133auto const module_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100134 lexeme[
135 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
136 ];
Václav Kubernát744f57f2018-06-29 22:46:26 +0200137
138auto const node_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100139 lexeme[
140 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
141 ];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200142
143auto const listPrefix_def =
Václav Kubernát4c325482019-04-11 17:51:55 +0200144 node_identifier;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200145
Václav Kubernát7e4e82f2018-05-14 20:04:58 +0200146// 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 +0200147auto const listSuffix_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100148 *keyValueWrapper;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200149
150auto const listElement_def =
Václav Kubernát4c325482019-04-11 17:51:55 +0200151 listPrefix >> -(!char_('[') >> suggestKeysStart) >> &char_('[') > listSuffix;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200152
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200153auto const list_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100154 node_identifier >> !char_('[');
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200155
Václav Kubernát60d6f292018-05-25 09:45:32 +0200156auto const nodeup_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100157 lit("..") > x3::attr(nodeup_());
Václav Kubernát60d6f292018-05-25 09:45:32 +0200158
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200159auto const container_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100160 node_identifier;
Václav Kubernát744f57f2018-06-29 22:46:26 +0200161
162auto const module_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100163 module_identifier >> x3::no_skip[':'] >> !x3::no_skip[space];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200164
Václav Kubernát07204242018-06-04 18:12:09 +0200165auto const leaf_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100166 node_identifier;
Václav Kubernát07204242018-06-04 18:12:09 +0200167
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100168auto const createPathSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100169 x3::eps;
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100170
Václav Kubernát07204242018-06-04 18:12:09 +0200171// 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 +0200172auto const schemaNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100173 createPathSuggestions >> -(module) >> (container | list | nodeup | leaf);
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200174
175auto const dataNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100176 createPathSuggestions >> -(module) >> (container | listElement | nodeup | leaf);
Václav Kubernát744f57f2018-06-29 22:46:26 +0200177
Václav Kubernát37171a12018-08-31 17:01:48 +0200178auto const absoluteStart_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100179 x3::omit['/'] >> x3::attr(Scope::Absolute);
Václav Kubernát37171a12018-08-31 17:01:48 +0200180
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100181auto const trailingSlash_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100182 x3::omit['/'] >> x3::attr(TrailingSlash::Present);
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100183
Václav Kubernát8028f942019-09-25 16:03:23 +0200184auto const space_separator_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100185 x3::omit[x3::no_skip[space]];
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100186
Václav Kubernátac035d62019-02-18 10:59:08 +0100187// This is a pseudo-parser, that fails if we're not completing a command
188auto const completing_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100189 x3::eps;
Václav Kubernátac035d62019-02-18 10:59:08 +0100190
Václav Kubernát37171a12018-08-31 17:01:48 +0200191// 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 +0200192auto const dataPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100193 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
194 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200195
Václav Kubernát5c75b252018-10-10 18:33:47 +0200196auto const dataNodeList_def =
Václav Kubernát51853b22019-04-16 21:53:44 +0200197 createPathSuggestions >> -(module) >> list;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200198
199// This intermediate rule is mandatory, because we need the first alternative
200// to be collapsed to a vector. If we didn't use the intermediate rule,
201// Spirit wouldn't know we want it to collapse.
202// https://github.com/boostorg/spirit/issues/408
203auto const dataNodesListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100204 initializePath >> dataNode % '/' >> '/' >> dataNodeList >> -(&char_('/') >> createPathSuggestions) |
205 initializePath >> x3::attr(decltype(dataPath_::m_nodes)()) >> dataNodeList;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200206
207auto const dataPathListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100208 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
209 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNodesListEnd >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát5c75b252018-10-10 18:33:47 +0200210
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200211auto const schemaPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100212 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(schemaPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
213 initializePath >> -(absoluteStart >> createPathSuggestions) >> schemaNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát07204242018-06-04 18:12:09 +0200214
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200215auto const leafPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100216 dataPath;
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200217
Václav Kubernát6797df02019-03-18 20:21:50 +0100218auto const presenceContainerPath_def =
219 dataPath;
220
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100221auto const listInstancePath_def =
222 dataPath;
223
Václav Kubernát989b5de2019-02-20 16:28:35 +0100224auto const createEnumSuggestions_def =
225 x3::eps;
226
Václav Kubernátebca2552018-06-08 19:06:02 +0200227auto const leaf_data_enum_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100228 createEnumSuggestions >> +char_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200229auto const leaf_data_decimal_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100230 double_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200231
232struct bool_symbol_table : x3::symbols<bool> {
233 bool_symbol_table()
234 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100235 add
236 ("true", true)
237 ("false", false);
Václav Kubernátebca2552018-06-08 19:06:02 +0200238 }
239} const bool_rule;
240
241auto const leaf_data_bool_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100242 bool_rule;
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200243auto const leaf_data_int8_def =
244 int8;
245auto const leaf_data_int16_def =
246 int16;
247auto const leaf_data_int32_def =
248 int32;
249auto const leaf_data_int64_def =
250 int64;
251auto const leaf_data_uint8_def =
252 uint8;
253auto const leaf_data_uint16_def =
254 uint16;
255auto const leaf_data_uint32_def =
256 uint32;
257auto const leaf_data_uint64_def =
258 uint64;
Václav Kubernátebca2552018-06-08 19:06:02 +0200259auto const leaf_data_string_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100260 *char_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200261
Václav Kubernátab538992019-03-06 15:30:50 +0100262// This intermediate rule is neccessary for coercing to std::string.
263auto const leaf_data_binary_data_def =
264 +(x3::alnum | char_('+') | char_('/')) >> -char_('=') >> -char_('=');
265
266auto const leaf_data_binary_def =
267 leaf_data_binary_data;
268
Václav Kubernáteeb38842019-03-20 19:46:05 +0100269auto const leaf_data_identityRef_data_def =
270 -module >> node_identifier;
271
272auto const createIdentitySuggestions_def =
273 x3::eps;
274
275auto const leaf_data_identityRef_def =
276 createIdentitySuggestions >> leaf_data_identityRef_data;
277
Václav Kubernátebca2552018-06-08 19:06:02 +0200278auto const leaf_data_def =
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200279x3::expect[
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100280 leaf_data_enum |
281 leaf_data_decimal |
282 leaf_data_bool |
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200283 leaf_data_int8 |
284 leaf_data_int16 |
285 leaf_data_int32 |
286 leaf_data_int64 |
287 leaf_data_uint8 |
288 leaf_data_uint16 |
289 leaf_data_uint32 |
290 leaf_data_uint64 |
Václav Kubernátab538992019-03-06 15:30:50 +0100291 leaf_data_binary |
Václav Kubernáteeb38842019-03-20 19:46:05 +0100292 leaf_data_identityRef |
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100293 leaf_data_string];
Václav Kubernát07204242018-06-04 18:12:09 +0200294
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200295struct ls_options_table : x3::symbols<LsOption> {
296 ls_options_table()
297 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100298 add
299 ("--recursive", LsOption::Recursive);
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200300 }
301} const ls_options;
302
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100303// A "nothing" parser, which is used to indicate we tried to parse a path
304auto const initializePath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100305 x3::eps;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200306
Václav Kubernát11afac72018-07-18 14:59:53 +0200307auto const ls_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100308 ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> (dataPathListEnd | dataPath | schemaPath));
Václav Kubernát11afac72018-07-18 14:59:53 +0200309
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200310auto const cd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100311 cd_::name >> space_separator > dataPath;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200312
Václav Kubernátb61336d2018-05-28 17:35:03 +0200313auto const create_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100314 create_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernátb61336d2018-05-28 17:35:03 +0200315
316auto const delete_rule_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100317 delete_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernát07204242018-06-04 18:12:09 +0200318
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200319auto const get_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100320 get_::name >> -(space_separator >> (dataPathListEnd | dataPath));
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200321
Václav Kubernát07204242018-06-04 18:12:09 +0200322auto const set_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100323 set_::name >> space_separator > leafPath > space_separator > leaf_data;
Václav Kubernátb61336d2018-05-28 17:35:03 +0200324
Václav Kubernát812ee282018-08-30 17:10:03 +0200325auto const commit_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100326 commit_::name >> x3::attr(commit_());
Václav Kubernát812ee282018-08-30 17:10:03 +0200327
Václav Kubernát6d791432018-10-25 16:00:35 +0200328auto const discard_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100329 discard_::name >> x3::attr(discard_());
Václav Kubernát6d791432018-10-25 16:00:35 +0200330
Václav Kubernát054cc992019-02-21 14:23:52 +0100331struct command_names_table : x3::symbols<decltype(help_::m_cmd)> {
332 command_names_table()
333 {
334 boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([this](auto cmd) {
335 add(commandNamesVisitor()(cmd), decltype(help_::m_cmd)(cmd));
336 });
337 }
338} const command_names;
339
340auto const help_def =
341 help_::name > createCommandSuggestions >> -command_names;
342
Václav Kubernát57272422019-02-08 12:48:24 +0100343auto const createCommandSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100344 x3::eps;
Václav Kubernát57272422019-02-08 12:48:24 +0100345
Václav Kubernátb61336d2018-05-28 17:35:03 +0200346auto const command_def =
Václav Kubernát054cc992019-02-21 14:23:52 +0100347 createCommandSuggestions >> x3::expect[cd | create | delete_rule | set | commit | get | ls | discard | help];
Václav Kubernát41378452018-06-06 16:29:40 +0200348
349#if __clang__
350#pragma GCC diagnostic pop
351#endif
Václav Kubernátb61336d2018-05-28 17:35:03 +0200352
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200353BOOST_SPIRIT_DEFINE(keyValue)
Václav Kubernát89728d82018-09-13 16:28:28 +0200354BOOST_SPIRIT_DEFINE(key_identifier)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200355BOOST_SPIRIT_DEFINE(node_identifier)
356BOOST_SPIRIT_DEFINE(module_identifier)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200357BOOST_SPIRIT_DEFINE(listPrefix)
358BOOST_SPIRIT_DEFINE(listSuffix)
359BOOST_SPIRIT_DEFINE(listElement)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200360BOOST_SPIRIT_DEFINE(list)
Václav Kubernát60d6f292018-05-25 09:45:32 +0200361BOOST_SPIRIT_DEFINE(nodeup)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200362BOOST_SPIRIT_DEFINE(schemaNode)
363BOOST_SPIRIT_DEFINE(dataNode)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200364BOOST_SPIRIT_DEFINE(container)
Václav Kubernát07204242018-06-04 18:12:09 +0200365BOOST_SPIRIT_DEFINE(leaf)
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200366BOOST_SPIRIT_DEFINE(leafPath)
Václav Kubernát6797df02019-03-18 20:21:50 +0100367BOOST_SPIRIT_DEFINE(presenceContainerPath)
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100368BOOST_SPIRIT_DEFINE(listInstancePath)
Václav Kubernát8028f942019-09-25 16:03:23 +0200369BOOST_SPIRIT_DEFINE(space_separator)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200370BOOST_SPIRIT_DEFINE(schemaPath)
371BOOST_SPIRIT_DEFINE(dataPath)
Václav Kubernát5c75b252018-10-10 18:33:47 +0200372BOOST_SPIRIT_DEFINE(dataNodeList)
373BOOST_SPIRIT_DEFINE(dataNodesListEnd)
374BOOST_SPIRIT_DEFINE(dataPathListEnd)
Václav Kubernát37171a12018-08-31 17:01:48 +0200375BOOST_SPIRIT_DEFINE(absoluteStart)
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100376BOOST_SPIRIT_DEFINE(trailingSlash)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200377BOOST_SPIRIT_DEFINE(module)
Václav Kubernátebca2552018-06-08 19:06:02 +0200378BOOST_SPIRIT_DEFINE(leaf_data)
379BOOST_SPIRIT_DEFINE(leaf_data_enum)
380BOOST_SPIRIT_DEFINE(leaf_data_decimal)
381BOOST_SPIRIT_DEFINE(leaf_data_bool)
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200382BOOST_SPIRIT_DEFINE(leaf_data_int8)
383BOOST_SPIRIT_DEFINE(leaf_data_int16)
384BOOST_SPIRIT_DEFINE(leaf_data_int32)
385BOOST_SPIRIT_DEFINE(leaf_data_int64)
386BOOST_SPIRIT_DEFINE(leaf_data_uint8)
387BOOST_SPIRIT_DEFINE(leaf_data_uint16)
388BOOST_SPIRIT_DEFINE(leaf_data_uint32)
389BOOST_SPIRIT_DEFINE(leaf_data_uint64)
Václav Kubernátebca2552018-06-08 19:06:02 +0200390BOOST_SPIRIT_DEFINE(leaf_data_string)
Václav Kubernátab538992019-03-06 15:30:50 +0100391BOOST_SPIRIT_DEFINE(leaf_data_binary_data)
392BOOST_SPIRIT_DEFINE(leaf_data_binary)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100393BOOST_SPIRIT_DEFINE(leaf_data_identityRef_data)
394BOOST_SPIRIT_DEFINE(leaf_data_identityRef)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100395BOOST_SPIRIT_DEFINE(initializePath)
Václav Kubernát07204242018-06-04 18:12:09 +0200396BOOST_SPIRIT_DEFINE(set)
Václav Kubernát812ee282018-08-30 17:10:03 +0200397BOOST_SPIRIT_DEFINE(commit)
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200398BOOST_SPIRIT_DEFINE(get)
Václav Kubernát11afac72018-07-18 14:59:53 +0200399BOOST_SPIRIT_DEFINE(ls)
Václav Kubernát6d791432018-10-25 16:00:35 +0200400BOOST_SPIRIT_DEFINE(discard)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200401BOOST_SPIRIT_DEFINE(cd)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200402BOOST_SPIRIT_DEFINE(create)
403BOOST_SPIRIT_DEFINE(delete_rule)
Václav Kubernát054cc992019-02-21 14:23:52 +0100404BOOST_SPIRIT_DEFINE(help)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200405BOOST_SPIRIT_DEFINE(command)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100406BOOST_SPIRIT_DEFINE(createPathSuggestions)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100407BOOST_SPIRIT_DEFINE(createKeySuggestions)
Václav Kubernát4c325482019-04-11 17:51:55 +0200408BOOST_SPIRIT_DEFINE(suggestKeysStart)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100409BOOST_SPIRIT_DEFINE(suggestKeysEnd)
Václav Kubernát57272422019-02-08 12:48:24 +0100410BOOST_SPIRIT_DEFINE(createCommandSuggestions)
Václav Kubernátac035d62019-02-18 10:59:08 +0100411BOOST_SPIRIT_DEFINE(completing)
Václav Kubernát989b5de2019-02-20 16:28:35 +0100412BOOST_SPIRIT_DEFINE(createEnumSuggestions)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100413BOOST_SPIRIT_DEFINE(createIdentitySuggestions)