aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-07-23 21:59:38 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-07-23 21:59:38 -0400
commit596bc33348e2daa5af8a0168f015e850aeccf0fc (patch)
tree498d02eb211e88a43d1e9ceff08d8e56ef94a5b4
parentd8ef3bcc3d410142e359771bbef0ce0bbdc78308 (diff)
Fix node_t is now node
-rw-r--r--node.c16
-rw-r--r--node.h9
-rw-r--r--tree.c6
-rw-r--r--tree.h1
4 files changed, 17 insertions, 15 deletions
diff --git a/node.c b/node.c
index c52b101..e1b7920 100644
--- a/node.c
+++ b/node.c
@@ -6,10 +6,10 @@
#include "node.h"
/*constructor*/
-node_t* mknode(str)
+node* mknode(str)
char *str;
{
- node_t *p = malloc(sizeof(node_t));
+ node *p = malloc(sizeof(node));
assert(p);
p->name = strdup(str);
@@ -19,11 +19,11 @@ char *str;
}
/* helpers */
-node_t* search(root, str)
-node_t *root;
+node* search(root, str)
+node *root;
char *str;
{
- node_t *p = root;
+ node *p = root;
while (p) {
if (!strcmp(p->name, str)) {
return p;
@@ -33,11 +33,11 @@ char *str;
return NULL;
}
-node_t* insert(root, str) /*TODO change to accept double pointer*/
-node_t *root;
+node* insert(root, str) /*TODO change to accept double pointer*/
+node *root;
char * str;
{
- node_t *p = mknode( str );
+ node *p = mknode( str );
p->next = root;
return p;
}
diff --git a/node.h b/node.h
index 97dc29e..5206db4 100644
--- a/node.h
+++ b/node.h
@@ -6,13 +6,14 @@
typedef struct node_s {
char *name;
struct node_s *next;
-} node_t;
+ int var_type;
+} node;
/*constructor*/
-node_t* mknode(char *);
+node* mknode(char *);
/* helpers */
-node_t* search(node_t*, char *);
-node_t* insert(node_t*, char*);
+node* search(node*, char *);
+node* insert(node*, char*);
#endif
diff --git a/tree.c b/tree.c
index eff6285..0301ec3 100644
--- a/tree.c
+++ b/tree.c
@@ -3,10 +3,10 @@
#include <string.h>
#include <assert.h>
+#include "node.h"
#include "tree.h"
#include "y.tab.h"
-
-extern void yyerror(char*);
+#include "pc.h"
/* parse tree funcs */
ptree* mktree(type, l, r)
@@ -47,7 +47,7 @@ float n;
return p;
}
-ptree * mkop(type, sub, l, r)
+ptree* mkop(type, sub, l, r)
int type, sub;
ptree *l, *r;
{
diff --git a/tree.h b/tree.h
index b7349af..b17c276 100644
--- a/tree.h
+++ b/tree.h
@@ -7,6 +7,7 @@ typedef struct parse_tree {
int ival; /* NUM */
float rval; /* RNUM */
char *sval; /* ID */
+ node *nval;
int opval; /* RELOP: LT LE GT GE EQ NE
ADDOP: PLUS MINUS OR
MULOP: MUL DIV