-
Notifications
You must be signed in to change notification settings - Fork 0
/
function_def.h
65 lines (53 loc) · 1.63 KB
/
function_def.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef FUNCTION_DEF_H
#define FUNCTION_DEF_H
#include <function.h>
namespace parser {
function::function(error_handler& error)
: function::base_type(translation_unit), body(error)
{
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_val_type _val;
using qi::on_error;
using qi::on_success;
using qi::fail;
using boost::phoenix::function;
typedef function<error_handler> error_handler_function;
typedef function<annotation> annotation_function;
translation_unit =
+( body
| function_definition
)
;
argument =
body.expr.type_specifier
> body.init_declarator
;
function_definition =
body.expr.type_specifier
> body.expr.declarator
> '('
> -(argument % ',')
> ')'
> body.compound_statement
;
// Debugging and error handling and reporting support.
BOOST_SPIRIT_DEBUG_NODES(
(translation_unit)
(function_definition)
(argument)
);
// Error handling
on_error<qi::fail>(function_definition,
error_handler_function(error)(
"Error! Expecting ", _4, _3));
// Annotation: on success in start, call annotation.
SUCCESS_ANNOTATE(function_definition);
SUCCESS_ANNOTATE(argument);
// on_success(identifier,
// annotation_function(error.iters)(_val, _1));
}
}
#endif // FUNCTION_DEF_H