1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include "statement.hpp"
8 #include "error_handler.hpp"
9 #include "annotation.hpp"
11 namespace client { namespace parser
13 template <typename Iterator>
14 statement<Iterator>::statement(error_handler<Iterator>& error_handler)
15 : statement::base_type(statement_list), expr(error_handler)
24 qi::lexeme_type lexeme;
32 using boost::phoenix::function;
34 typedef function<client::error_handler<Iterator> > error_handler_function;
35 typedef function<client::annotation<Iterator> > annotation_function;
51 >> raw[lexeme[(alpha | '_') >> *(alnum | '_')]]
54 variable_declaration =
55 lexeme["var" >> !(alnum | '_')] // make sure we have whole words
56 > &identifier // expect an identifier
75 lexeme["else" >> !(alnum | '_')] // make sure we have whole words
89 '{' >> -statement_list >> '}'
92 // Debugging and error handling and reporting support.
93 BOOST_SPIRIT_DEBUG_NODES(
96 (variable_declaration)
100 // Error handling: on error in statement_list, call error_handler.
101 on_error<fail>(statement_list,
102 error_handler_function(error_handler)(
103 "Error! Expecting ", _4, _3));
105 // Annotation: on success in assignment, call annotation.
106 on_success(assignment,
107 annotation_function(error_handler.iters)(_val, _1));