-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexpression.hpp
48 lines (37 loc) · 1.64 KB
/
expression.hpp
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
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef EXPRESSION_HPP_
#define EXPRESSION_HPP_
#include "white_space.hpp"
#include "function_info.hpp"
#include "compile_op.hpp"
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <vector>
///////////////////////////////////////////////////////////////////////////////
// Our expression grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct expression : boost::spirit::qi::grammar<Iterator, white_space<Iterator> >
{
expression(
std::vector<int>& code
, boost::spirit::qi::symbols<char, int>& vars
, boost::spirit::qi::symbols<char, function_info>& functions);
typedef white_space<Iterator> white_space_;
boost::spirit::qi::rule<Iterator, white_space_>
expr, equality_expr, relational_expr
, logical_expr, additive_expr, multiplicative_expr
, unary_expr, primary_expr, variable, print
;
boost::spirit::qi::rule<Iterator,
boost::spirit::qi::locals<function_info, int>, white_space_> function_call;
std::vector<int>& code;
boost::spirit::qi::symbols<char, int>& vars;
boost::spirit::qi::symbols<char, function_info>& functions;
boost::phoenix::function<compile_op> op;
};
#endif /* EXPRESSION_HPP_ */