X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FParse.cc;h=dece5df2982ed8052ec857f38b453f357cc26000;hb=a22f6d21df6c911d65f76d7731bcf92b1906bb09;hp=dc1dbce4a6f5f30caf0b1debfe2ba20035731332;hpb=958bdb52c39fa39f4ef91cafd9628bcb4f85a03c;p=senf.git diff --git a/Utils/Console/Parse.cc b/Utils/Console/Parse.cc index dc1dbce..dece5df 100644 --- a/Utils/Console/Parse.cc +++ b/Utils/Console/Parse.cc @@ -76,10 +76,10 @@ namespace detail { info_->builtin(ParseCommandInfo::BuiltinLS); setBuiltinPathArg(path); } - void pushDirectory(std::vector & path) - { info_->clear(); - info_->builtin(ParseCommandInfo::BuiltinPUSHD); - setBuiltinPathArg(path); } + void pushDirectory() + { // Do NOT call clear since pushDirectory is set in ADDITION + // to an ordinary command (which may be only a directory name) + info_->builtin(ParseCommandInfo::BuiltinPUSHD); } void popDirectory() { info_->clear(); @@ -96,11 +96,12 @@ namespace detail { void setBuiltinPathArg(std::vector & path) { - pushToken(ArgumentGroupOpenToken()); - for (std::vector::const_iterator i (path.begin()); - i != path.end(); ++i) - pushToken(*i); - pushToken(ArgumentGroupCloseToken()); + info_->command(path); +// pushToken(ArgumentGroupOpenToken()); +// for (std::vector::const_iterator i (path.begin()); +// i != path.end(); ++i) +// pushToken(*i); +// pushToken(ArgumentGroupCloseToken()); } }; @@ -249,7 +250,6 @@ namespace { void throwParserError(Error const & err) { static char const * msg [] = { "end of statement expected", - "'{' or arguments expected", "path expected", "')' expected", "'\"' expected" }; @@ -349,6 +349,29 @@ prefix_ void senf::console::CommandParser::parseArguments(std::string const & ar } } +prefix_ void senf::console::CommandParser::parsePath(std::string const & path, + ParseCommandInfo & info) +{ + typedef boost::spirit::position_iterator PositionIterator; + PositionIterator b (path.begin(), path.end(), std::string("")); + PositionIterator e (path.end(), path.end(), std::string("")); + detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info); + boost::spirit::parse_info result; + try { + result = boost::spirit::parse( b, e, + impl().grammar.use_parser(), + impl().grammar.use_parser() ); + } + catch (boost::spirit::parser_error & ex) { + throwParserError(ex); + } + if (! result.full) { + boost::spirit::file_position pos (result.stop.get_position()); + throw ParserErrorException("path expected") + << "\nat " << pos.file << ":" << pos.line << ":" << pos.column; + } +} + struct senf::console::CommandParser::SetIncremental { SetIncremental(CommandParser & parser) : parser_ (parser) {