-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.h
75 lines (59 loc) · 2.21 KB
/
node.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Copyright (C) 2010-2011, Bruce Ediger
This file is part of acl.
acl is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
acl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with acl; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: node.h,v 1.13 2011/06/12 18:19:11 bediger Exp $ */
enum nodeType { APPLICATION, ATOM };
struct node {
int sn;
enum nodeType typ;
const char *name;
struct node *left;
struct node *right;
struct node **updateable;
struct node **left_addr;
struct node **right_addr;
int refcnt;
struct reduction_rule *rule;
int tree_size;
};
/* struct abs_node: similar data structure created
* when user-input abstraction rules get parsed. */
enum abs_NodeType { abs_APPLICATION, abs_LEAF };
struct abs_node {
enum abs_NodeType typ;
const char *label;
int number;
int node_number;
int abstracted;
struct abs_node *left;
struct abs_node *right;
struct reduction_rule *rule;
};
struct node *new_application(struct node *left_child, struct node *right_child);
struct node *new_term(const char *name);
void preallocate_nodes(int preallocated_count);
void init_node_allocation(void);
void reset_node_allocation(void);
void print_tree(struct node *root, int reduction_node_sn, int current_node_sn);
void free_all_nodes(void);
void free_node(struct node *root);
struct node *arena_copy_graph(struct node *root);
int var_in_tree(struct node *tree, const char *var_name);
int any_var_in_tree(struct node *tree);
void renumber(struct node *node, int *n);
struct abs_node *new_abs_node(const char *label);
struct abs_node *new_abs_application(struct abs_node *lft, struct abs_node *rght);
void free_abs_node(struct abs_node *tree);
void print_abs_node(struct abs_node *n);