summaryrefslogtreecommitdiff
path: root/tree.h
blob: 70d2ec0bee892f6eddd56ebb1602f09f7188f1ee (plain)
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
#ifndef TREE_H_HG
#define TREE_H_HG
#include <stdio.h>

enum nodeType {
  BIOP,
  UNOP,
  LTTR
};

typedef struct node {
  enum nodeType type;
  char el;
	union {
		struct node *child[2];
		struct {
			struct node *lhs, *rhs;
		};
		struct node *value;
	};
} node;

node * parse(char *str);
void fprintTree(FILE *stream, node *root, int level);
void printTree(node *root, int level);
void free_node(node *n);

/// Takes an expression and a bitfield of the
/// letters' truthiness values
char eval_tree(node *root, unsigned int alph_bools);

#endif