info_->builtin(ParseCommandInfo::BuiltinLS);
setBuiltinPathArg(path); }
- void pushDirectory(std::vector<Token> & 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();
void setBuiltinPathArg(std::vector<Token> & path)
{
- pushToken(ArgumentGroupOpenToken());
- for (std::vector<Token>::const_iterator i (path.begin());
- i != path.end(); ++i)
- pushToken(*i);
- pushToken(ArgumentGroupCloseToken());
+ info_->command(path);
+// pushToken(ArgumentGroupOpenToken());
+// for (std::vector<Token>::const_iterator i (path.begin());
+// i != path.end(); ++i)
+// pushToken(*i);
+// pushToken(ArgumentGroupCloseToken());
}
};
void throwParserError(Error const & err)
{
static char const * msg [] = { "end of statement expected",
- "'{' or arguments expected",
"path expected",
"')' expected",
"'\"' expected" };
}
}
+prefix_ void senf::console::CommandParser::parsePath(std::string const & path,
+ ParseCommandInfo & info)
+{
+ typedef boost::spirit::position_iterator<std::string::const_iterator> PositionIterator;
+ PositionIterator b (path.begin(), path.end(), std::string("<unknown>"));
+ PositionIterator e (path.end(), path.end(), std::string("<unknown>"));
+ detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
+ boost::spirit::parse_info<PositionIterator> result;
+ try {
+ result = boost::spirit::parse( b, e,
+ impl().grammar.use_parser<Impl::Grammar::PathParser>(),
+ impl().grammar.use_parser<Impl::Grammar::SkipParser>() );
+ }
+ catch (boost::spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & 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) {
parseLoop(commands.begin(), commands.end(), "<unknown>", cb) );
}
-///////////////////////////////cc.e////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+// Character sets
+
+prefix_ bool senf::console::CommandParser::isSpecialChar(char ch)
+{
+ return Impl::Grammar::special_p.test(ch);
+}
+
+prefix_ bool senf::console::CommandParser::isPunctuationChar(char ch)
+{
+ return Impl::Grammar::punctuation_p.test(ch);
+}
+
+prefix_ bool senf::console::CommandParser::isSpaceChar(char ch)
+{
+ return Impl::Grammar::space_p.test(ch);
+}
+
+prefix_ bool senf::console::CommandParser::isInvalidChar(char ch)
+{
+ return Impl::Grammar::invalid_p.test(ch);
+}
+
+prefix_ bool senf::console::CommandParser::isWordChar(char ch)
+{
+ return Impl::Grammar::word_p.test(ch);
+}
+
+/////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "Parse.mpp"