mupp 1.1.0
Loading...
Searching...
No Matches
PExpression.hpp
Go to the documentation of this file.
1/***************************************************************************
2
3 PExpression.hpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8 Based on Joel de Guzman example on calc7,
9 see https://github.com/boostorg/spirit
10
11***************************************************************************/
12
13/***************************************************************************
14 * Copyright (C) 2023 by Andreas Suter *
15 * andreas.suter@psi.ch *
16 * *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
21 * *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
26 * *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the *
29 * Free Software Foundation, Inc., *
30 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
31 ***************************************************************************/
32
33#ifndef _PEXPRESSION_HPP_
34#define _PEXPRESSION_HPP_
35
37// Uncomment this if you want to enable debugging
38// #define BOOST_SPIRIT_X3_DEBUG
40
41#include <boost/spirit/home/x3.hpp>
42#include "PAst.hpp"
43#include "PErrorHandler.hpp"
44#include "PSkipper.hpp"
45#include <vector>
46
47namespace mupp { namespace parser
48{
49 namespace x3 = boost::spirit::x3;
50 namespace ascii = boost::spirit::x3::ascii;
51
53
76
77 // Rule IDs
78 struct expr_class;
79 struct additive_expr_class;
80 struct multiplicative_expr_class;
81 struct unary_expr_class;
82 struct primary_expr_class;
83 struct identifier_class;
84
85 // Rule declarations
86 typedef x3::rule<expr_class, ast::expression> expr_type;
87 typedef x3::rule<additive_expr_class, ast::expression> additive_expr_type;
88 typedef x3::rule<multiplicative_expr_class, ast::expression> multiplicative_expr_type;
89 typedef x3::rule<unary_expr_class, ast::operand> unary_expr_type;
90 typedef x3::rule<primary_expr_class, ast::operand> primary_expr_type;
91 typedef x3::rule<identifier_class, std::string> identifier_type;
92
95}}
96
97#endif // _PEXPRESSION_HPP_
98
99
x3::rule< multiplicative_expr_class, ast::expression > multiplicative_expr_type
x3::rule< primary_expr_class, ast::operand > primary_expr_type
x3::rule< identifier_class, std::string > identifier_type
x3::rule< expr_class, ast::expression > expr_type
x3::rule< unary_expr_class, ast::operand > unary_expr_type
x3::rule< additive_expr_class, ast::expression > additive_expr_type