diff options
-rw-r--r-- | node.c | 16 | ||||
-rw-r--r-- | node.h | 9 | ||||
-rw-r--r-- | tree.c | 6 | ||||
-rw-r--r-- | tree.h | 1 |
4 files changed, 17 insertions, 15 deletions
@@ -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; } @@ -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 @@ -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; { @@ -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 |