/local_config.hh
+/autoconf.hh
#include <cerrno>
#include <sys/stat.h>
#include <boost/iterator/transform_iterator.hpp>
-#include <boost/spirit/iterator/file_iterator.hpp>
-#include <boost/spirit/iterator/position_iterator.hpp>
+#include <senf/config.hh>
+
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+# include <boost/spirit/include/classic_file_iterator.hpp>
+# include <boost/spirit/include/classic_position_iterator.hpp>
+#else
+# include <boost/spirit/iterator/file_iterator.hpp>
+# include <boost/spirit/iterator/position_iterator.hpp>
+#endif
+
#include <senf/Utils/Exception.hh>
#include <senf/Utils/senfassert.hh>
namespace boost {
namespace spirit {
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+namespace classic {
+#endif
template <>
struct position_policy<senf::console::detail::FilePositionWithIndex>
}
};
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+}
+#endif
}}
prefix_ senf::console::CommandParser::CommandParser()
prefix_ Iterator senf::console::CommandParser::parseLoop(Iterator npb, Iterator npe,
std::string const & source, Callback cb)
{
- typedef boost::spirit::position_iterator<
+ typedef detail::boost_spirit::position_iterator<
Iterator, detail::FilePositionWithIndex> PositionIterator;
PositionIterator b (npb, npe, source);
PositionIterator e (npe, npe, source);
ParseCommandInfo info;
detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
- boost::spirit::parse_info<PositionIterator> result;
+ detail::boost_spirit::parse_info<PositionIterator> result;
for(;;) {
- result = boost::spirit::parse(
+ result = detail::boost_spirit::parse(
b, e, * impl().grammar.use_parser<Impl::Grammar::SkipParser>());
b = result.stop;
if (b == e)
return e.base();
info.clear();
try {
- result = boost::spirit::parse(b, e,
+ result = detail::boost_spirit::parse(b, e,
impl().grammar.use_parser<Impl::Grammar::CommandParser>(),
impl().grammar.use_parser<Impl::Grammar::SkipParser>());
}
- catch (boost::spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
+ catch (detail::boost_spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
if (impl().grammar.incremental && ex.where == e)
return b.base();
else
if (stat( filename.c_str(), &statBuf) != 0)
throw SystemException(filename, errno SENF_EXC_DEBUGINFO);
if (statBuf.st_size == 0) return;
- boost::spirit::file_iterator<> i (filename);
+ detail::boost_spirit::file_iterator<> i (filename);
if (!i) {
if (errno == 0)
// hmm.. errno==0 but the file_iterator is false; something is wrong but we
else
throw SystemException(filename, errno SENF_EXC_DEBUGINFO);
}
- boost::spirit::file_iterator<> const i_end (i.make_end());
+ detail::boost_spirit::file_iterator<> const i_end (i.make_end());
parseLoop(i, i_end, filename, cb);
}
prefix_ void senf::console::CommandParser::parseArguments(std::string const & arguments,
ParseCommandInfo & info)
{
- typedef boost::spirit::position_iterator<
+ typedef detail::boost_spirit::position_iterator<
std::string::const_iterator, detail::FilePositionWithIndex> PositionIterator;
PositionIterator b (arguments.begin(), arguments.end(), std::string("<unknown>"));
PositionIterator e (arguments.end(), arguments.end(), std::string("<unknown>"));
detail::ParseDispatcher::BindInfo bind (impl().dispatcher, info);
- boost::spirit::parse_info<PositionIterator> result;
+ detail::boost_spirit::parse_info<PositionIterator> result;
try {
- result = boost::spirit::parse( b, e,
+ result = detail::boost_spirit::parse( b, e,
impl().grammar.use_parser<Impl::Grammar::ArgumentsParser>(),
impl().grammar.use_parser<Impl::Grammar::SkipParser>() );
}
- catch (boost::spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
+ catch (detail::boost_spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
throwParserError(ex);
}
if (! result.full) {
prefix_ void senf::console::CommandParser::parsePath(std::string const & path,
ParseCommandInfo & info)
{
- typedef boost::spirit::position_iterator<
+ typedef detail::boost_spirit::position_iterator<
std::string::const_iterator, detail::FilePositionWithIndex> 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;
+ detail::boost_spirit::parse_info<PositionIterator> result;
try {
- result = boost::spirit::parse( b, e,
+ result = detail::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) {
+ catch (detail::boost_spirit::parser_error<Impl::Grammar::Errors, PositionIterator> & ex) {
throwParserError(ex);
}
if (! result.full) {
// Custom includes
#include <vector>
#include <senf/config.hh>
-#include <boost/spirit.hpp>
-#include <boost/spirit/utility/grammar_def.hpp>
-#include <boost/spirit/dynamic.hpp>
-#include <boost/spirit/phoenix.hpp>
+
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+# include <boost/spirit/include/classic.hpp>
+# include <boost/spirit/include/classic_grammar_def.hpp>
+# include <boost/spirit/include/classic_dynamic.hpp>
+# include <boost/spirit/include/phoenix1.hpp>
+#else
+# include <boost/spirit.hpp>
+# include <boost/spirit/utility/grammar_def.hpp>
+# include <boost/spirit/dynamic.hpp>
+# include <boost/spirit/phoenix.hpp>
+#endif
+
#include <senf/Utils/Phoenix.hh>
///////////////////////////////ih.p////////////////////////////////////////
namespace console {
namespace detail {
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+ namespace boost_spirit = ::boost::spirit::classic;
+#else
+ namespace boost_spirit = ::boost::spirit;
+#endif
+
#ifndef DOXYGEN
struct FilePositionWithIndex
- : public boost::spirit::file_position
+ : public boost_spirit::file_position
{
int index;
FilePositionWithIndex(std::string const & file_ = std::string(),
int line_ = 1, int column_ = 1, int index_ = 0)
- : boost::spirit::file_position (file_, line_, column_), index (index_)
+ : boost_spirit::file_position (file_, line_, column_), index (index_)
{}
bool operator==(const FilePositionWithIndex & fp) const
{
- return boost::spirit::file_position::operator==(fp) && index == fp.index;
+ return boost_spirit::file_position::operator==(fp) && index == fp.index;
}
};
// Grammar
template <class ParseDispatcher>
- struct CommandGrammar : boost::spirit::grammar<CommandGrammar<ParseDispatcher> >
+ struct CommandGrammar : boost_spirit::grammar<CommandGrammar<ParseDispatcher> >
{
///////////////////////////////////////////////////////////////////////////
// Start rules
//////////////////////////////////////////////////////////////////////////
// charachter sets
- static boost::spirit::chset<> special_p;
- static boost::spirit::chset<> punctuation_p;
- static boost::spirit::chset<> space_p;
- static boost::spirit::chset<> invalid_p;
- static boost::spirit::chset<> word_p;
- static boost::spirit::distinct_parser<> keyword_p;
+ static boost_spirit::chset<> special_p;
+ static boost_spirit::chset<> punctuation_p;
+ static boost_spirit::chset<> space_p;
+ static boost_spirit::chset<> invalid_p;
+ static boost_spirit::chset<> word_p;
+ static boost_spirit::distinct_parser<> keyword_p;
///////////////////////////////////////////////////////////////////////////
// Errors
template <class Scanner>
struct definition
- : public boost::spirit::grammar_def< boost::spirit::rule<Scanner>,
- boost::spirit::rule<Scanner>,
- boost::spirit::rule<Scanner>,
- boost::spirit::rule<Scanner> >
+ : public boost_spirit::grammar_def< boost_spirit::rule<Scanner>,
+ boost_spirit::rule<Scanner>,
+ boost_spirit::rule<Scanner>,
+ boost_spirit::rule<Scanner> >
{
- boost::spirit::rule<Scanner> command, path, argument, word, string, hexstring, token,
+ boost_spirit::rule<Scanner> command, path, argument, word, string, hexstring, token,
punctuation, hexbyte, balanced_tokens, simple_argument, complex_argument, builtin,
skip, statement, relpath, abspath, arguments, group_start, group_close,
statement_end, opt_path;
definition(CommandGrammar const & self)
{
- using namespace boost::spirit;
+ using namespace boost_spirit;
using namespace ::phoenix;
using namespace senf::phoenix;
typedef ParseDispatcher PD;
};
};
- template <class PD> boost::spirit::chset<> CommandGrammar<PD>::special_p (
+ template <class PD> boost_spirit::chset<> CommandGrammar<PD>::special_p (
"/(){};\"");
- template <class PD> boost::spirit::chset<> CommandGrammar<PD>::punctuation_p (
+ template <class PD> boost_spirit::chset<> CommandGrammar<PD>::punctuation_p (
",=");
- template <class PD> boost::spirit::chset<> CommandGrammar<PD>::space_p (
+ template <class PD> boost_spirit::chset<> CommandGrammar<PD>::space_p (
" \t\n\r");
- template <class PD> boost::spirit::chset<> CommandGrammar<PD>::invalid_p (
- (boost::spirit::chset<>('\0') | boost::spirit::chset<>("\x01-\x20")) - space_p );
- template <class PD> boost::spirit::chset<> CommandGrammar<PD>::word_p (
- boost::spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p);
- template <class PD> boost::spirit::distinct_parser<> CommandGrammar<PD>::keyword_p (
- word_p | boost::spirit::ch_p('/'));
+ template <class PD> boost_spirit::chset<> CommandGrammar<PD>::invalid_p (
+ (boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p );
+ template <class PD> boost_spirit::chset<> CommandGrammar<PD>::word_p (
+ boost_spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p);
+ template <class PD> boost_spirit::distinct_parser<> CommandGrammar<PD>::keyword_p (
+ word_p | boost_spirit::ch_p('/'));
#endif
" x\"01 02 # Inner comment\n"
" 0304\";";
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
text,
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"ls //foo/bar;",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"lr /foo/bar;",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"cd /foo/bar;",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"exit;",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"foo/bar// {",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"}",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
{
ss.str("");
- BOOST_CHECK( boost::spirit::parse(
+ BOOST_CHECK( senf::console::detail::boost_spirit::parse(
"help /foo/bar",
grammar.use_parser<Grammar::CommandParser>(),
grammar.use_parser<Grammar::SkipParser>() ) . full );
#define HH_SENF_Utils_Phoenix_ 1
// Custom includes
-#include <boost/spirit/phoenix/functions.hpp>
+#include <senf/config.hh>
+
+#if HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP
+# include <boost/spirit/include/phoenix1_functions.hpp>
+#else
+# include <boost/spirit/phoenix/functions.hpp>
+#endif
//#include "Phoenix.mpp"
#include "Phoenix.ih"
}}
+# include "autoconf.hh"
# include "local_config.hh"
#
# ifndef SENF_ABSOLUTE_INCLUDE_PATH
// ispell-local-dictionary: "american"
// compile-command: "scons -u all_tests"
// End:
-
def Configure(env):
- conf = env.Configure(clean=False, help=False, custom_tests = senfconf.Tests())
+ conf = env.Configure(clean=False,
+ help=False,
+ custom_tests=senfconf.Tests(),
+ config_h="#/senf/autoconf.hh")
env.Replace(
BOOST_VERSION = conf.CheckBoostVersion(),
BOOST_VARIANT = conf.CheckBoostVariants( '', 'mt' ),
NEED_BOOST_EXT = not conf.CheckCXXHeader("boost/bimap.hpp"),
+ HAVE_BOOST_SPIRIT_INCLUDE_CLASSIC_HPP = conf.CheckCXXHeader(
+ "boost/spirit/include/classic.hpp"),
)
conf.Finish()