-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftree.h
59 lines (47 loc) · 1.28 KB
/
ftree.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
#ifndef _FTREE_H
#define _FTREE_H
/**
* A F Tree is an arithmetic tree representing the expression
* with operators, value and variables
*/
typedef struct _FunctionTree FunctionTree;
typedef struct _FunctionNode FunctionNode;
#include "btable.h"
#include "globals.h"
typedef enum {
NodeType_VALUE, NodeType_VARIABLE, NodeType_OPERATOR
} NodeType;
typedef enum {
Op_OR, Op_AND, Op_XOR,
Op_NOT
} Operator;
/**
* create a function tree with a node as root
*/
extern FunctionTree* ftree_createWithNode(FunctionNode* node);
/**
* clone a functiontree
*/
extern FunctionTree* ftree_clone(FunctionTree* node);
/**
* free a function tree
*/
extern void ftree_free(FunctionTree*);
/// Converters
extern TruthTable* ftree_toTruthTable(FunctionTree* ftree, char* vars);
extern char* ftree_toString(FunctionTree*);
/// Printer
extern void ftree_printDot(FunctionTree* ftree, FILE* out);
/**
* get all vars used in the ftree
*/
extern char* ftree_getVars(FunctionTree* ftree);
/**
* create nodes
*/
extern FunctionNode* ftree_newBin(FunctionNode* l, char o, FunctionNode* r);
extern FunctionNode* ftree_newNot(FunctionNode* node);
extern FunctionNode* ftree_newBool(int b);
extern FunctionNode* ftree_newVar(char s);
extern FunctionTree* ftree_createWithNode(FunctionNode* node);
#endif