#include "phrase_tags.hpp"
#include "parsers.hpp"
#include "scoped.hpp"
-#include "native_text.hpp"
+#include "stream.hpp"
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_chset.hpp>
#include <boost/spirit/include/classic_if.hpp>
// * List item
// |indent2
- list_stack_item(list_item_type r) :
+ explicit list_stack_item(list_item_type r) :
type(r), indent(0), indent2(0), mark('\0') {}
- list_stack_item(char mark, unsigned int indent, unsigned int indent2) :
- type(syntactic_list), indent(indent), indent2(indent2), mark(mark)
+ explicit list_stack_item(char mark_, unsigned int indent_, unsigned int indent2_) :
+ type(syntactic_list), indent(indent_), indent2(indent2_), mark(mark_)
{}
};
template_args_1_6, template_arg_1_6, template_arg_1_6_content,
break_,
command_line_macro_identifier,
- dummy_block, line_dummy_block, square_brackets,
+ dummy_block, line_dummy_block, square_brackets, error_brackets,
skip_escape
;
};
struct process_element_impl : scoped_action_base {
- process_element_impl(main_grammar_local& l) :
- l(l), pushed_source_mode_(false), element_context_error_(false) {}
+ process_element_impl(main_grammar_local& l_) :
+ l(l_), pushed_source_mode_(false), element_context_error_(false) {}
bool start()
{
}
template <typename ResultT, typename ScannerT>
- bool result(ResultT result, ScannerT const& scan)
+ bool result(ResultT r, ScannerT const& scan)
{
if (element_context_error_) {
error_message_action error(l.state_,
error(scan.first, scan.first);
return true;
}
- else if (result) {
+ else if (r) {
return true;
}
else if (qbk_version_n < 107u &&
struct scoped_paragraph : scoped_action_base
{
- scoped_paragraph(quickbook::state& state) :
- state(state), pushed(false) {}
+ scoped_paragraph(quickbook::state& state_) :
+ state(state_), pushed(false) {}
bool start() {
state.push_tagged_source_mode(state.source_mode_next);
struct in_list_impl {
main_grammar_local& l;
- in_list_impl(main_grammar_local& l) :
- l(l) {}
+ explicit in_list_impl(main_grammar_local& l_) :
+ l(l_) {}
bool operator()() const {
return !l.list_stack.empty() &&
{
typedef M T::*member_ptr;
- set_scoped_value_impl(T& l, member_ptr ptr)
- : l(l), ptr(ptr), saved_value() {}
+ explicit set_scoped_value_impl(T& l_, member_ptr ptr_)
+ : l(l_), ptr(ptr_), saved_value() {}
bool start(M const& value) {
saved_value = l.*ptr;
scoped_parser<to_value_scoped_action> to_value(state);
scoped_parser<scoped_paragraph> scope_paragraph(state);
+ quickbook_strict strict_mode(state);
+
// Local Actions
scoped_parser<process_element_impl> process_element(local);
in_list_impl in_list(local);
// Note that we don't do this for lists in 1.6, as it causes
// the list block to end. The support for nested syntactic
// blocks in 1.7 will fix that. Although it does mean the
- // following line will need to be indented. TODO: Flag that
- // the indentation check shouldn't be made?
+ // following line will need to be indented.
>> !( cl::eps_p(in_list) >> qbk_ver(106u, 107u)
| cl::eps_p
(
| local.simple_markup
| escape
| comment
- | qbk_ver(106u) >> local.square_brackets
+ | strict_mode
+ >> ( local.error_brackets [error("Invalid template/tag (strict mode)")]
+ | cl::eps_p('[') [error("Mismatched open bracket (strict mode)")]
+ >> cl::anychar_p
+ | cl::eps_p(']') [error("Mismatched close bracket (strict mode)")]
+ >> cl::anychar_p
+ )
+ | qbk_ver(106u)
+ >> local.square_brackets
| cl::space_p [raw_char]
| cl::anychar_p [plain_char]
;
)
;
+ local.error_brackets =
+ cl::ch_p('[') [plain_char]
+ >> ( local.error_brackets
+ | (cl::anychar_p - ']')
+ )
+ >> cl::ch_p(']')
+ ;
+
local.macro =
cl::eps_p
( ( state.macro
>> state.templates.scope
[state.values.entry(ph::arg1, ph::arg2, template_tags::escape)]
[state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)]
- >> !qbk_ver(106u)
+ >> !( qbk_ver(106u)
[error("Templates with punctuation names can't be escaped in quickbook 1.6+")]
+ | strict_mode
+ [error("Templates with punctuation names can't be escaped (strict mode)")]
+ )
| cl::str_p('`')
>> state.templates.scope
[state.values.entry(ph::arg1, ph::arg2, template_tags::escape)]
local.skip_code_block =
"```"
>> ~cl::eps_p("`")
- >> ( !( *(*cl::blank_p >> cl::eol_p)
+ >> ( (!( *(*cl::blank_p >> cl::eol_p)
>> ( *( "````" >> *cl::ch_p('`')
| ( cl::anychar_p
- (*cl::space_p >> "```" >> ~cl::eps_p("`"))
>> !(*cl::blank_p >> cl::eol_p)
)
>> (*cl::space_p >> "```")
- )
+ ))
| *cl::anychar_p
)
| "``"
>> space
;
-
attribute_value_1_7 =
state.values.save() [
+( ~cl::eps_p(']' | cl::space_p | comment)
{
// If this nested block is part of a list, then tell the
// output state.
- //
- // TODO: This is a bit dodgy, it would be better if this
- // was handled when the output state is pushed (currently
- // in to_value_scoped_action).
state_.in_list = state_.explicit_list;
state_.explicit_list = false;
if (qbk_version_n == 106u &&
list_stack.top().type == list_stack_item::syntactic_list) {
detail::outerr(state_.current_file, first)
- << "Nested blocks in lists won't be supported in "
- << "quickbook 1.6"
+ << "Paragraphs in lists aren't supported in quickbook 1.6."
<< std::endl;
++state_.error_count;
}
{
unsigned int new_indent = indent_length(first, mark_pos);
unsigned int new_indent2 = indent_length(first, last);
- char mark = *mark_pos;
+ char list_mark = *mark_pos;
if (list_stack.top().type == list_stack_item::top_level &&
new_indent > 0) {
if (list_stack.top().type != list_stack_item::syntactic_list ||
new_indent > list_indent) {
- list_stack.push(list_stack_item(mark, new_indent, new_indent2));
- state_.start_list(mark);
+ list_stack.push(list_stack_item(list_mark, new_indent, new_indent2));
+ state_.start_list(list_mark);
}
else if (new_indent == list_indent) {
state_.end_list_item();
list_indent = new_indent;
- if (mark != list_stack.top().mark)
+ if (list_mark != list_stack.top().mark)
{
detail::outerr(state_.current_file, first)
<< "Illegal change of list style.\n";