1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #include "statement.hpp"
9 #include "error_handler.hpp"
10 #include "annotation.hpp"
12 namespace client { namespace parser
14 template <typename Iterator, typename Lexer>
15 statement<Iterator, Lexer>::statement(
16 error_handler<typename Lexer::base_iterator_type, Iterator>& error_handler
18 : statement::base_type(statement_list), expr(error_handler, l)
30 using boost::phoenix::function;
32 typedef client::error_handler<typename Lexer::base_iterator_type, Iterator>
34 typedef function<error_handler_type> error_handler_function;
35 typedef function<client::annotation<Iterator> > annotation_function;
50 variable_declaration =
86 '{' >> -statement_list >> '}'
95 // Debugging and error handling and reporting support.
96 BOOST_SPIRIT_DEBUG_NODES(
99 (variable_declaration)
107 // Error handling: on error in statement_list, call error_handler.
108 on_error<fail>(statement_list,
109 error_handler_function(error_handler)(
110 "Error! Expecting ", _4, _3));
112 // Annotation: on success in variable_declaration,
113 // assignment and return_statement, call annotation.
114 on_success(variable_declaration,
115 annotation_function(error_handler.iters)(_val, _1));
116 on_success(assignment,
117 annotation_function(error_handler.iters)(_val, _1));
118 on_success(return_statement,
119 annotation_function(error_handler.iters)(_val, _1));