From 395526a447ee6b4da68fc7ac4b6a120230be9944 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 22 Nov 2011 23:48:39 +0000 Subject: [PATCH] Quickbook: Check that code snippet grammars always succeed. [SVN r75625] --- src/code_snippet.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp index ca4e421..73b73fc 100644 --- a/src/code_snippet.cpp +++ b/src/code_snippet.cpp @@ -368,18 +368,20 @@ namespace quickbook bool is_python = extension == ".py"; code_snippet_actions a(storage, load(filename, qbk_version_n), is_python ? "[python]" : "[c++]"); - // TODO: Should I check that parse succeeded? - string_iterator first(a.source_file->source.begin()); string_iterator last(a.source_file->source.end()); + cl::parse_info info; + if(is_python) { - boost::spirit::classic::parse(first, last, python_code_snippet_grammar(a)); + info = boost::spirit::classic::parse(first, last, python_code_snippet_grammar(a)); } else { - boost::spirit::classic::parse(first, last, cpp_code_snippet_grammar(a)); + info = boost::spirit::classic::parse(first, last, cpp_code_snippet_grammar(a)); } + assert(info.full); + return 0; }