1 /*
2  *  Copyright (C) 2010 Erik Edelmann <erik.edelmann@iki.fi>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU Library General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
17  *  USA.
18  */
19 #ifndef __PARSETREE_H__
20 #define __PARSETREE_H__
21 
22 #include "constants.h"
23 
24 typedef enum { NODE_OPERATOR, NODE_NUMBER, NODE_FUNCTION } node_type_t;
25 
26 typedef enum { OP_PLUS, OP_MINUS,
27                OP_UMINUS,
28                OP_TIMES, OP_DIV,
29                OP_MODULO,
30                OP_POW } operator_type_t;
31 
32 typedef struct _node_t {
33     node_type_t type;
34     union {
35         double num;
36         operator_type_t op;
37         double (*fun)(double x);
38     } val;
39    struct _node_t *left, *right;
40 } node_t;
41 
42 void free_parsetree(node_t *parsetree);
43 
44 #endif
45