blob: e6a7fc72ecf869d41b78d701467d7d3833869d93 [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át24df80e2018-06-06 15:18:03 +020011#include "ast_commands.hpp"
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020012#include "ast_handlers.hpp"
13
Václav Kubernát60d6f292018-05-25 09:45:32 +020014
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020015x3::rule<keyValue_class, keyValue_> const keyValue = "keyValue";
Václav Kubernát89728d82018-09-13 16:28:28 +020016x3::rule<key_identifier_class, std::string> const key_identifier = "key_identifier";
Václav Kubernát744f57f2018-06-29 22:46:26 +020017x3::rule<node_identifier_class, std::string> const node_identifier = "node_identifier";
18x3::rule<module_identifier_class, std::string> const module_identifier = "module_identifier";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020019x3::rule<listPrefix_class, std::string> const listPrefix = "listPrefix";
20x3::rule<listSuffix_class, std::vector<keyValue_>> const listSuffix = "listSuffix";
21x3::rule<listElement_class, listElement_> const listElement = "listElement";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020022x3::rule<list_class, list_> const list = "list";
Václav Kubernát60d6f292018-05-25 09:45:32 +020023x3::rule<nodeup_class, nodeup_> const nodeup = "nodeup";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020024x3::rule<container_class, container_> const container = "container";
Václav Kubernát07204242018-06-04 18:12:09 +020025x3::rule<leaf_class, leaf_> const leaf = "leaf";
Václav Kubernát744f57f2018-06-29 22:46:26 +020026x3::rule<module_class, module_> const module = "module";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020027x3::rule<dataNode_class, dataNode_> const dataNode = "dataNode";
28x3::rule<schemaNode_class, schemaNode_> const schemaNode = "schemaNode";
Václav Kubernát37171a12018-08-31 17:01:48 +020029x3::rule<absoluteStart_class, Scope> const absoluteStart = "absoluteStart";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020030x3::rule<schemaPath_class, schemaPath_> const schemaPath = "schemaPath";
Václav Kubernátd6fd2492018-11-19 15:11:16 +010031x3::rule<trailingSlash_class, TrailingSlash> const trailingSlash = "trailingSlash";
Václav Kubernát5c75b252018-10-10 18:33:47 +020032x3::rule<dataNodeList_class, decltype(dataPath_::m_nodes)::value_type> const dataNodeList = "dataNodeList";
33x3::rule<dataNodesListEnd_class, decltype(dataPath_::m_nodes)> const dataNodesListEnd = "dataNodesListEnd";
34x3::rule<dataPathListEnd_class, dataPath_> const dataPathListEnd = "dataPathListEnd";
Václav Kubernát2eaceb82018-10-08 19:56:30 +020035x3::rule<dataPath_class, dataPath_> const dataPath = "dataPath";
36x3::rule<leaf_path_class, dataPath_> const leafPath = "leafPath";
Václav Kubernát6797df02019-03-18 20:21:50 +010037x3::rule<presenceContainerPath_class, dataPath_> const presenceContainerPath = "presenceContainerPath";
Václav Kubernátf5f64f02019-03-19 17:15:47 +010038x3::rule<listInstancePath_class, dataPath_> const listInstancePath = "listInstancePath";
Václav Kubernátebca2552018-06-08 19:06:02 +020039
40x3::rule<leaf_data_class, leaf_data_> const leaf_data = "leaf_data";
41x3::rule<leaf_data_enum_class, enum_> const leaf_data_enum = "leaf_data_enum";
42x3::rule<leaf_data_decimal_class, double> const leaf_data_decimal = "leaf_data_decimal";
43x3::rule<leaf_data_bool_class, bool> const leaf_data_bool = "leaf_data_bool";
44x3::rule<leaf_data_int_class, int32_t> const leaf_data_int = "leaf_data_int";
45x3::rule<leaf_data_uint_class, uint32_t> const leaf_data_uint = "leaf_data_uint";
46x3::rule<leaf_data_string_class, std::string> const leaf_data_string = "leaf_data_string";
Václav Kubernátab538992019-03-06 15:30:50 +010047x3::rule<leaf_data_binary_data_class, std::string> const leaf_data_binary_data = "leaf_data_binary_data";
48x3::rule<leaf_data_binary_class, binary_> const leaf_data_binary = "leaf_data_binary";
Václav Kubernáteeb38842019-03-20 19:46:05 +010049x3::rule<leaf_data_identityRef_data_class, identityRef_> const leaf_data_identityRef_data = "leaf_data_identityRef_data";
50x3::rule<leaf_data_identityRef_class, identityRef_> const leaf_data_identityRef = "leaf_data_identityRef";
Václav Kubernátebca2552018-06-08 19:06:02 +020051
Václav Kubernát6d791432018-10-25 16:00:35 +020052x3::rule<discard_class, discard_> const discard = "discard";
Václav Kubernát11afac72018-07-18 14:59:53 +020053x3::rule<ls_class, ls_> const ls = "ls";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020054x3::rule<cd_class, cd_> const cd = "cd";
Václav Kubernát07204242018-06-04 18:12:09 +020055x3::rule<set_class, set_> const set = "set";
Václav Kubernátb6ff0b62018-08-30 16:14:53 +020056x3::rule<get_class, get_> const get = "get";
Václav Kubernátb61336d2018-05-28 17:35:03 +020057x3::rule<create_class, create_> const create = "create";
58x3::rule<delete_class, delete_> const delete_rule = "delete_rule";
Václav Kubernát812ee282018-08-30 17:10:03 +020059x3::rule<commit_class, commit_> const commit = "commit";
Václav Kubernát054cc992019-02-21 14:23:52 +010060x3::rule<help_class, help_> const help = "help";
Václav Kubernátb61336d2018-05-28 17:35:03 +020061x3::rule<command_class, command_> const command = "command";
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020062
Václav Kubernát4108e0d2018-10-29 13:32:22 +010063x3::rule<initializePath_class, x3::unused_type> const initializePath = "initializePath";
64x3::rule<createPathSuggestions_class, x3::unused_type> const createPathSuggestions = "createPathSuggestions";
Václav Kubernát329c6c32019-02-06 16:41:53 +010065x3::rule<createKeySuggestions_class, x3::unused_type> const createKeySuggestions = "createKeySuggestions";
66x3::rule<suggestKeysEnd_class, x3::unused_type> const suggestKeysEnd = "suggestKeysEnd";
Václav Kubernát57272422019-02-08 12:48:24 +010067x3::rule<createCommandSuggestions_class, x3::unused_type> const createCommandSuggestions = "createCommandSuggestions";
Václav Kubernátac035d62019-02-18 10:59:08 +010068x3::rule<completing_class, x3::unused_type> const completing = "completing";
Václav Kubernát989b5de2019-02-20 16:28:35 +010069x3::rule<createEnumSuggestions_class, x3::unused_type> const createEnumSuggestions = "createEnumSuggestions";
Václav Kubernáteeb38842019-03-20 19:46:05 +010070x3::rule<createIdentitySuggestions_class, x3::unused_type> const createIdentitySuggestions = "createIdentitySuggestions";
Václav Kubernát5c75b252018-10-10 18:33:47 +020071
Václav Kubernát41378452018-06-06 16:29:40 +020072#if __clang__
73#pragma GCC diagnostic push
74#pragma GCC diagnostic ignored "-Woverloaded-shift-op-parentheses"
75#endif
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020076
Václav Kubernát89728d82018-09-13 16:28:28 +020077auto const key_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010078 lexeme[
79 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
80 ];
Václav Kubernát89728d82018-09-13 16:28:28 +020081
82auto const quotedValue =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010083 ('\'' > +(char_-'\'') > '\'') |
84 ('\"' > +(char_-'\"') > '\"');
Václav Kubernát89728d82018-09-13 16:28:28 +020085
86auto const number =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010087 +x3::digit;
Václav Kubernát89728d82018-09-13 16:28:28 +020088
Václav Kubernát329c6c32019-02-06 16:41:53 +010089auto const createKeySuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010090 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +010091
92auto const suggestKeysEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010093 x3::eps;
Václav Kubernát329c6c32019-02-06 16:41:53 +010094
Václav Kubernát0a2a2e82018-05-11 13:59:12 +020095auto const keyValue_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010096 key_identifier > '=' > (quotedValue | number);
Václav Kubernát329c6c32019-02-06 16:41:53 +010097
98auto const keyValueWrapper =
Václav Kubernátbf083ec2019-02-19 13:58:09 +010099 lexeme['[' > createKeySuggestions > keyValue > suggestKeysEnd > ']'];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200100
Václav Kubernát744f57f2018-06-29 22:46:26 +0200101auto const module_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100102 lexeme[
103 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
104 ];
Václav Kubernát744f57f2018-06-29 22:46:26 +0200105
106auto const node_identifier_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100107 lexeme[
108 ((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
109 ];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200110
111auto const listPrefix_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100112 node_identifier >> &char_('[');
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200113
Václav Kubernát7e4e82f2018-05-14 20:04:58 +0200114// 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 +0200115auto const listSuffix_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100116 *keyValueWrapper;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200117
118auto const listElement_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100119 listPrefix > listSuffix;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200120
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200121auto const list_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100122 node_identifier >> !char_('[');
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200123
Václav Kubernát60d6f292018-05-25 09:45:32 +0200124auto const nodeup_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100125 lit("..") > x3::attr(nodeup_());
Václav Kubernát60d6f292018-05-25 09:45:32 +0200126
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200127auto const container_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100128 node_identifier;
Václav Kubernát744f57f2018-06-29 22:46:26 +0200129
130auto const module_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100131 module_identifier >> x3::no_skip[':'] >> !x3::no_skip[space];
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200132
Václav Kubernát07204242018-06-04 18:12:09 +0200133auto const leaf_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100134 node_identifier;
Václav Kubernát07204242018-06-04 18:12:09 +0200135
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100136auto const createPathSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100137 x3::eps;
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100138
Václav Kubernát07204242018-06-04 18:12:09 +0200139// 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 +0200140auto const schemaNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100141 createPathSuggestions >> -(module) >> (container | list | nodeup | leaf);
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200142
143auto const dataNode_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100144 createPathSuggestions >> -(module) >> (container | listElement | nodeup | leaf);
Václav Kubernát744f57f2018-06-29 22:46:26 +0200145
Václav Kubernát37171a12018-08-31 17:01:48 +0200146auto const absoluteStart_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100147 x3::omit['/'] >> x3::attr(Scope::Absolute);
Václav Kubernát37171a12018-08-31 17:01:48 +0200148
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100149auto const trailingSlash_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100150 x3::omit['/'] >> x3::attr(TrailingSlash::Present);
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100151
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100152auto const space_separator =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100153 x3::omit[x3::no_skip[space]];
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100154
Václav Kubernátac035d62019-02-18 10:59:08 +0100155// This is a pseudo-parser, that fails if we're not completing a command
156auto const completing_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100157 x3::eps;
Václav Kubernátac035d62019-02-18 10:59:08 +0100158
Václav Kubernát37171a12018-08-31 17:01:48 +0200159// 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 +0200160auto const dataPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100161 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
162 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200163
Václav Kubernát5c75b252018-10-10 18:33:47 +0200164auto const dataNodeList_def =
Václav Kubernát51853b22019-04-16 21:53:44 +0200165 createPathSuggestions >> -(module) >> list;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200166
167// This intermediate rule is mandatory, because we need the first alternative
168// to be collapsed to a vector. If we didn't use the intermediate rule,
169// Spirit wouldn't know we want it to collapse.
170// https://github.com/boostorg/spirit/issues/408
171auto const dataNodesListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100172 initializePath >> dataNode % '/' >> '/' >> dataNodeList >> -(&char_('/') >> createPathSuggestions) |
173 initializePath >> x3::attr(decltype(dataPath_::m_nodes)()) >> dataNodeList;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200174
175auto const dataPathListEnd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100176 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(dataPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
177 initializePath >> -(absoluteStart >> createPathSuggestions) >> dataNodesListEnd >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát5c75b252018-10-10 18:33:47 +0200178
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200179auto const schemaPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100180 initializePath >> absoluteStart >> createPathSuggestions >> x3::attr(decltype(schemaPath_::m_nodes)()) >> x3::attr(TrailingSlash::NonPresent) >> x3::eoi |
181 initializePath >> -(absoluteStart >> createPathSuggestions) >> schemaNode % '/' >> (trailingSlash >> createPathSuggestions >> (completing | x3::eoi) | (&space_separator | x3::eoi));
Václav Kubernát07204242018-06-04 18:12:09 +0200182
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200183auto const leafPath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100184 dataPath;
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200185
Václav Kubernát6797df02019-03-18 20:21:50 +0100186auto const presenceContainerPath_def =
187 dataPath;
188
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100189auto const listInstancePath_def =
190 dataPath;
191
Václav Kubernát989b5de2019-02-20 16:28:35 +0100192auto const createEnumSuggestions_def =
193 x3::eps;
194
Václav Kubernátebca2552018-06-08 19:06:02 +0200195auto const leaf_data_enum_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100196 createEnumSuggestions >> +char_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200197auto const leaf_data_decimal_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100198 double_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200199
200struct bool_symbol_table : x3::symbols<bool> {
201 bool_symbol_table()
202 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100203 add
204 ("true", true)
205 ("false", false);
Václav Kubernátebca2552018-06-08 19:06:02 +0200206 }
207} const bool_rule;
208
209auto const leaf_data_bool_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100210 bool_rule;
Václav Kubernátebca2552018-06-08 19:06:02 +0200211auto const leaf_data_int_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100212 int_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200213auto const leaf_data_uint_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100214 uint_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200215auto const leaf_data_string_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100216 *char_;
Václav Kubernátebca2552018-06-08 19:06:02 +0200217
Václav Kubernátab538992019-03-06 15:30:50 +0100218// This intermediate rule is neccessary for coercing to std::string.
219auto const leaf_data_binary_data_def =
220 +(x3::alnum | char_('+') | char_('/')) >> -char_('=') >> -char_('=');
221
222auto const leaf_data_binary_def =
223 leaf_data_binary_data;
224
Václav Kubernáteeb38842019-03-20 19:46:05 +0100225auto const leaf_data_identityRef_data_def =
226 -module >> node_identifier;
227
228auto const createIdentitySuggestions_def =
229 x3::eps;
230
231auto const leaf_data_identityRef_def =
232 createIdentitySuggestions >> leaf_data_identityRef_data;
233
Václav Kubernátebca2552018-06-08 19:06:02 +0200234auto const leaf_data_def =
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200235x3::expect[
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100236 leaf_data_enum |
237 leaf_data_decimal |
238 leaf_data_bool |
239 leaf_data_int |
240 leaf_data_uint |
Václav Kubernátab538992019-03-06 15:30:50 +0100241 leaf_data_binary |
Václav Kubernáteeb38842019-03-20 19:46:05 +0100242 leaf_data_identityRef |
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100243 leaf_data_string];
Václav Kubernát07204242018-06-04 18:12:09 +0200244
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200245struct ls_options_table : x3::symbols<LsOption> {
246 ls_options_table()
247 {
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100248 add
249 ("--recursive", LsOption::Recursive);
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200250 }
251} const ls_options;
252
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100253// A "nothing" parser, which is used to indicate we tried to parse a path
254auto const initializePath_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100255 x3::eps;
Václav Kubernát5c75b252018-10-10 18:33:47 +0200256
Václav Kubernát11afac72018-07-18 14:59:53 +0200257auto const ls_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100258 ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> (dataPathListEnd | dataPath | schemaPath));
Václav Kubernát11afac72018-07-18 14:59:53 +0200259
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200260auto const cd_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100261 cd_::name >> space_separator > dataPath;
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200262
Václav Kubernátb61336d2018-05-28 17:35:03 +0200263auto const create_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100264 create_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernátb61336d2018-05-28 17:35:03 +0200265
266auto const delete_rule_def =
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100267 delete_::name >> space_separator > (presenceContainerPath | listInstancePath);
Václav Kubernát07204242018-06-04 18:12:09 +0200268
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200269auto const get_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100270 get_::name >> -(space_separator >> (dataPathListEnd | dataPath));
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200271
Václav Kubernát07204242018-06-04 18:12:09 +0200272auto const set_def =
Václav Kubernát989b5de2019-02-20 16:28:35 +0100273 set_::name >> space_separator > leafPath > space_separator > leaf_data;
Václav Kubernátb61336d2018-05-28 17:35:03 +0200274
Václav Kubernát812ee282018-08-30 17:10:03 +0200275auto const commit_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100276 commit_::name >> x3::attr(commit_());
Václav Kubernát812ee282018-08-30 17:10:03 +0200277
Václav Kubernát6d791432018-10-25 16:00:35 +0200278auto const discard_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100279 discard_::name >> x3::attr(discard_());
Václav Kubernát6d791432018-10-25 16:00:35 +0200280
Václav Kubernát054cc992019-02-21 14:23:52 +0100281struct command_names_table : x3::symbols<decltype(help_::m_cmd)> {
282 command_names_table()
283 {
284 boost::mpl::for_each<CommandTypes, boost::type<boost::mpl::_>>([this](auto cmd) {
285 add(commandNamesVisitor()(cmd), decltype(help_::m_cmd)(cmd));
286 });
287 }
288} const command_names;
289
290auto const help_def =
291 help_::name > createCommandSuggestions >> -command_names;
292
Václav Kubernát57272422019-02-08 12:48:24 +0100293auto const createCommandSuggestions_def =
Václav Kubernátbf083ec2019-02-19 13:58:09 +0100294 x3::eps;
Václav Kubernát57272422019-02-08 12:48:24 +0100295
Václav Kubernátb61336d2018-05-28 17:35:03 +0200296auto const command_def =
Václav Kubernát054cc992019-02-21 14:23:52 +0100297 createCommandSuggestions >> x3::expect[cd | create | delete_rule | set | commit | get | ls | discard | help];
Václav Kubernát41378452018-06-06 16:29:40 +0200298
299#if __clang__
300#pragma GCC diagnostic pop
301#endif
Václav Kubernátb61336d2018-05-28 17:35:03 +0200302
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200303BOOST_SPIRIT_DEFINE(keyValue)
Václav Kubernát89728d82018-09-13 16:28:28 +0200304BOOST_SPIRIT_DEFINE(key_identifier)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200305BOOST_SPIRIT_DEFINE(node_identifier)
306BOOST_SPIRIT_DEFINE(module_identifier)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200307BOOST_SPIRIT_DEFINE(listPrefix)
308BOOST_SPIRIT_DEFINE(listSuffix)
309BOOST_SPIRIT_DEFINE(listElement)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200310BOOST_SPIRIT_DEFINE(list)
Václav Kubernát60d6f292018-05-25 09:45:32 +0200311BOOST_SPIRIT_DEFINE(nodeup)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200312BOOST_SPIRIT_DEFINE(schemaNode)
313BOOST_SPIRIT_DEFINE(dataNode)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200314BOOST_SPIRIT_DEFINE(container)
Václav Kubernát07204242018-06-04 18:12:09 +0200315BOOST_SPIRIT_DEFINE(leaf)
Václav Kubernát0b0272f2018-06-13 14:13:08 +0200316BOOST_SPIRIT_DEFINE(leafPath)
Václav Kubernát6797df02019-03-18 20:21:50 +0100317BOOST_SPIRIT_DEFINE(presenceContainerPath)
Václav Kubernátf5f64f02019-03-19 17:15:47 +0100318BOOST_SPIRIT_DEFINE(listInstancePath)
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200319BOOST_SPIRIT_DEFINE(schemaPath)
320BOOST_SPIRIT_DEFINE(dataPath)
Václav Kubernát5c75b252018-10-10 18:33:47 +0200321BOOST_SPIRIT_DEFINE(dataNodeList)
322BOOST_SPIRIT_DEFINE(dataNodesListEnd)
323BOOST_SPIRIT_DEFINE(dataPathListEnd)
Václav Kubernát37171a12018-08-31 17:01:48 +0200324BOOST_SPIRIT_DEFINE(absoluteStart)
Václav Kubernátd6fd2492018-11-19 15:11:16 +0100325BOOST_SPIRIT_DEFINE(trailingSlash)
Václav Kubernát744f57f2018-06-29 22:46:26 +0200326BOOST_SPIRIT_DEFINE(module)
Václav Kubernátebca2552018-06-08 19:06:02 +0200327BOOST_SPIRIT_DEFINE(leaf_data)
328BOOST_SPIRIT_DEFINE(leaf_data_enum)
329BOOST_SPIRIT_DEFINE(leaf_data_decimal)
330BOOST_SPIRIT_DEFINE(leaf_data_bool)
331BOOST_SPIRIT_DEFINE(leaf_data_int)
332BOOST_SPIRIT_DEFINE(leaf_data_uint)
333BOOST_SPIRIT_DEFINE(leaf_data_string)
Václav Kubernátab538992019-03-06 15:30:50 +0100334BOOST_SPIRIT_DEFINE(leaf_data_binary_data)
335BOOST_SPIRIT_DEFINE(leaf_data_binary)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100336BOOST_SPIRIT_DEFINE(leaf_data_identityRef_data)
337BOOST_SPIRIT_DEFINE(leaf_data_identityRef)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100338BOOST_SPIRIT_DEFINE(initializePath)
Václav Kubernát07204242018-06-04 18:12:09 +0200339BOOST_SPIRIT_DEFINE(set)
Václav Kubernát812ee282018-08-30 17:10:03 +0200340BOOST_SPIRIT_DEFINE(commit)
Václav Kubernátb6ff0b62018-08-30 16:14:53 +0200341BOOST_SPIRIT_DEFINE(get)
Václav Kubernát11afac72018-07-18 14:59:53 +0200342BOOST_SPIRIT_DEFINE(ls)
Václav Kubernát6d791432018-10-25 16:00:35 +0200343BOOST_SPIRIT_DEFINE(discard)
Václav Kubernát0a2a2e82018-05-11 13:59:12 +0200344BOOST_SPIRIT_DEFINE(cd)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200345BOOST_SPIRIT_DEFINE(create)
346BOOST_SPIRIT_DEFINE(delete_rule)
Václav Kubernát054cc992019-02-21 14:23:52 +0100347BOOST_SPIRIT_DEFINE(help)
Václav Kubernátb61336d2018-05-28 17:35:03 +0200348BOOST_SPIRIT_DEFINE(command)
Václav Kubernát4108e0d2018-10-29 13:32:22 +0100349BOOST_SPIRIT_DEFINE(createPathSuggestions)
Václav Kubernát329c6c32019-02-06 16:41:53 +0100350BOOST_SPIRIT_DEFINE(createKeySuggestions)
351BOOST_SPIRIT_DEFINE(suggestKeysEnd)
Václav Kubernát57272422019-02-08 12:48:24 +0100352BOOST_SPIRIT_DEFINE(createCommandSuggestions)
Václav Kubernátac035d62019-02-18 10:59:08 +0100353BOOST_SPIRIT_DEFINE(completing)
Václav Kubernát989b5de2019-02-20 16:28:35 +0100354BOOST_SPIRIT_DEFINE(createEnumSuggestions)
Václav Kubernáteeb38842019-03-20 19:46:05 +0100355BOOST_SPIRIT_DEFINE(createIdentitySuggestions)