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 "function.hpp"
9 #include "error_handler.hpp"
10 #include "annotation.hpp"
12 namespace client { namespace parser
14 template <typename Iterator, typename Lexer>
15 function<Iterator, Lexer>::function(
16 error_handler<typename Lexer::base_iterator_type, Iterator>& error_handler
18 : function::base_type(start), body(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;
37 identifier = body.expr.identifier;
38 argument_list = -(identifier % ',');
40 start = (l.token("void") | l.token("int"))
42 > '(' > argument_list > ')'
43 > (';' | '{' > body > '}')
46 // Debugging and error handling and reporting support.
47 BOOST_SPIRIT_DEBUG_NODES(
53 // Error handling: on error in start, call error_handler.
55 error_handler_function(error_handler)(
56 "Error! Expecting ", _4, _3));
58 // Annotation: on success in start, call annotation.
59 on_success(identifier,
60 annotation_function(error_handler.iters)(_val, _1));