From 596bc33348e2daa5af8a0168f015e850aeccf0fc Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Tue, 23 Jul 2019 21:59:38 -0400 Subject: Fix node_t is now node --- node.c | 16 ++++++++-------- node.h | 9 +++++---- tree.c | 6 +++--- tree.h | 1 + 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 #include +#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 -- cgit v1.1