Rework x3::phrase_parse into x3::parse
For commands, there is predefined places where we want to skip spaces:
on the start of the command, in between command arguments and at the
end of the command. Using phrase_parse just makes everything more
complicated, since I have to actually disable space skipping a lot of
the time.
For ls: the ">>" did unexpected stuff, because for example this input:
> ls foo
could fail if "foo" wasn't a valid node. However, because the ls path
argument is wrapped in in the optional parser, it would still parse it as
valid.
For get: same as ls.
Change-Id: I90b32e1a270da0c228691935cc7206d73248025a
diff --git a/src/grammars.hpp b/src/grammars.hpp
index b8d9456..b1f2878 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -105,7 +105,7 @@
} const ls_options;
auto const ls_def =
- ls_::name >> *(space_separator >> ls_options) >> -(space_separator >> (anyPath | (module >> "*")));
+ ls_::name >> *(space_separator >> ls_options) >> -(space_separator > (anyPath | (module >> "*")));
auto const cd_def =
cd_::name >> space_separator > cdPath;
@@ -146,7 +146,7 @@
auto const get_def =
get_::name
>> -(space_separator >> "-" > staticSuggestions({"-datastore"}) > "-datastore" > space_separator > dsTargetSuggestions > ds_target_table)
- >> -(space_separator >> getPath);
+ >> -(space_separator > getPath);
auto const set_def =
set_::name >> space_separator > writableLeafPath > space_separator > leaf_data;
@@ -190,7 +190,7 @@
{
auto& parserContext = x3::get<parser_context_tag>(ctx);
auto iterBeforeDestination = begin;
- auto save_iter = x3::no_skip[x3::eps[([&iterBeforeDestination](auto& ctx) { iterBeforeDestination = _where(ctx).begin(); })]];
+ auto save_iter = x3::eps[([&iterBeforeDestination](auto& ctx) { iterBeforeDestination = _where(ctx).begin(); })];
auto grammar = datastoreSuggestions > copy_source > space_separator > datastoreSuggestions > save_iter > copy_destination;
try {
@@ -365,7 +365,7 @@
#if BOOST_VERSION <= 107800
x3::eps >>
#endif
- createCommandSuggestions >> x3::expect[cd | copy | create | delete_rule | set | commit | get | ls | discard | describe | help | move | dump | prepare | exec | cancel | switch_rule | quit];
+ -space_separator >> createCommandSuggestions >> x3::expect[cd | copy | create | delete_rule | set | commit | get | ls | discard | describe | help | move | dump | prepare | exec | cancel | switch_rule | quit] >> -space_separator;
#if __clang__
#pragma GCC diagnostic pop