boost::optional<command::iterator> metashell::parse_pragma(const command& cmd_) { command::iterator i = skip_whitespace(cmd_.begin(), cmd_.end()); if ( i != cmd_.end() && ( i->type() == token_type::p_pragma || i->type() == token_type::operator_pound ) ) { i = skip_whitespace(skip(i), cmd_.end()); if ( i != cmd_.end() && i->type() == token_type::identifier && (i->value() == "metashell" || i->value() == "msh") ) { i = skip_whitespace(skip(i), cmd_.end()); if (i == cmd_.end() || i->value().empty()) { throw exception("The name of the metashell pragma is missing."); } else if (i->type() == token_type::identifier) { return i; } else { std::ostringstream s; s << "Invalid pragma name " << i->value(); throw exception(s.str()); } } } return boost::optional<command::iterator>(); }