Merge quickbook

- Define macros at the command line.
 - Some inspect fixes.


[SVN r61065]
This commit is contained in:
Daniel James 2010-04-05 09:03:29 +00:00
parent 962f63fef6
commit a42e360345
5 changed files with 114 additions and 11 deletions

View File

@ -43,6 +43,7 @@ namespace quickbook
extern tm* current_gm_time; // the current UTC time
extern bool debug_mode;
extern std::vector<std::string> include_path;
extern std::vector<std::string> preset_defines;
// forward declarations
struct actions;
@ -370,10 +371,10 @@ namespace quickbook
struct escape_unicode_action
{
escape_unicode_action(collector& phrase) : phrase(phrase) {}
void operator()(iterator first, iterator last) const;
collector& phrase;
escape_unicode_action(collector& phrase) : phrase(phrase) {}
void operator()(iterator first, iterator last) const;
collector& phrase;
};
struct attribute_action

View File

@ -43,6 +43,79 @@ namespace quickbook
unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
bool ms_errors = false; // output errors/warnings as if for VS
std::vector<std::string> include_path;
std::vector<std::string> preset_defines;
///////////////////////////////////////////////////////////////////////////
//
// Parse the macros passed as command line parameters
//
///////////////////////////////////////////////////////////////////////////
template <typename Actions>
struct command_line_grammar
: public grammar<command_line_grammar<Actions> >
{
command_line_grammar(Actions& actions)
: actions(actions) {}
template <typename Scanner>
struct definition
{
definition(command_line_grammar const& self)
: unused(false), common(self.actions, unused)
{
Actions& actions = self.actions;
macro =
*space_p
>> macro_identifier [actions.macro_identifier]
>> *space_p
>> ( '='
>> *space_p
>> phrase [actions.macro_definition]
>> *space_p
)
| eps_p [actions.macro_definition]
;
macro_identifier =
+(anychar_p - (space_p | ']'))
;
phrase =
*( common
| (anychar_p - ']') [actions.plain_char]
)
;
}
bool unused;
rule<Scanner> macro, macro_identifier, phrase;
phrase_grammar<Actions> common;
rule<Scanner> const&
start() const { return macro; }
};
Actions& actions;
};
static void set_macros(actions& actor)
{
quickbook::command_line_grammar<actions> grammar(actor);
for(std::vector<std::string>::const_iterator
it = preset_defines.begin(),
end = preset_defines.end();
it != end; ++it)
{
typedef position_iterator<std::string::const_iterator> iterator_type;
iterator_type first(it->begin(), it->end(), "command line parameter");
iterator_type last(it->end(), it->end());
parse(first, last, grammar);
// TODO: Check result?
}
}
///////////////////////////////////////////////////////////////////////////
//
@ -89,12 +162,6 @@ namespace quickbook
<< "Syntax Error near column " << pos.column << ".\n";
++actor.error_count;
}
if(actor.error_count)
{
detail::outerr(filein_)
<< "Error count: " << actor.error_count << ".\n";
}
return actor.error_count ? 1 : 0;
}
@ -103,11 +170,19 @@ namespace quickbook
parse(char const* filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
{
actions actor(filein_, outdir, out);
set_macros(actor);
bool r = parse(filein_, actor);
if (actor.section_level != 0)
detail::outwarn(filein_)
<< "Warning missing [endsect] detected at end of file."
<< std::endl;
if(actor.error_count)
{
detail::outerr(filein_)
<< "Error count: " << actor.error_count << ".\n";
}
return r;
}
@ -177,6 +252,7 @@ main(int argc, char* argv[])
("debug", "debug mode (for developers)")
("ms-errors", "use Microsoft Visual Studio style error & warn message format")
("include-path,I", value< std::vector<quickbook::detail::input_path> >(), "include path")
("define,D", value< std::vector<std::string> >(), "define macro")
;
positional_options_description p;
@ -247,6 +323,12 @@ main(int argc, char* argv[])
= std::vector<std::string>(paths.begin(), paths.end());
}
if (vm.count("define"))
{
quickbook::preset_defines
= vm["define"].as<std::vector<std::string> >();
}
if (vm.count("input-file"))
{
std::string filein
@ -274,7 +356,7 @@ main(int argc, char* argv[])
quickbook::detail::outerr("") << "Error: No filename given\n\n"
<< desc << std::endl;
return 1;
}
}
}
catch(std::exception& e)

View File

@ -1,3 +1,13 @@
#==============================================================================
# Copyright (c) 2002 2004 2006 Joel de Guzman
# Copyright (c) 2004 Eric Niebler
# http://spirit.sourceforge.net/
#
# Use, modification and distribution is subject to the Boost Software
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#==============================================================================
project boost/quickbook/doc ;
import boostbook : boostbook ;

View File

@ -6,5 +6,10 @@
<body>
Automatic redirection failed, click this
<a href="../../doc/html/quickbook.html">link</a>
<p>Copyright&nbsp;Eric Niebler 2005</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
</p>
</body>
</html>

View File

@ -1,3 +1,8 @@
// Copyright 2009 Daniel James.
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or move at http://www.boost.org/LICENSE_1_0.txt)
//[ example1
/*`