scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 3c8406c0b92af281c68ffcf7595fed2ac98a095a
parent cd53c9b23ec34490e3f34a155a6d5bce8fdc53d1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 18 Mar 2014 22:02:41 +0100

Remove non used code about compound and print trees

Diffstat:
Msyntax.h | 7-------
Mtree.c | 110-------------------------------------------------------------------------------
2 files changed, 0 insertions(+), 117 deletions(-)

diff --git a/syntax.h b/syntax.h @@ -24,18 +24,11 @@ struct node; struct symbol; struct ctype; -struct compound { - struct node *tree; - struct node_op2 *last; -}; - extern struct node *expr(void), *extdecl(void), *decl(void), *typename(void), *function(void); extern struct node *node(unsigned char op, struct node *l, struct node *r); extern struct node *nodesym(struct symbol *sym); -extern struct node *addstmt(struct compound *p, struct node *np); extern bool walk(register struct node *np, bool (*fun)(struct node *)); -extern void prtree(register struct node *np); #endif diff --git a/tree.c b/tree.c @@ -45,21 +45,6 @@ node(unsigned char op, struct node *l, struct node *r) return (struct node *) np; } -struct node * -addstmt(struct compound *p, struct node *np) -{ - if (!p->tree) { - p->tree = node(OCOMP, NULL, NULL); - p->last = (struct node_op2 *) p->tree; - p->last->right = np; - } else { - p->last = (struct node_op2 *) - (p->last->left = node(O2EXP, NULL, np)); - } - - return p->tree; -} - bool walk(register struct node *np, bool (*fun)(struct node *)) { @@ -71,98 +56,3 @@ walk(register struct node *np, bool (*fun)(struct node *)) p = (struct node_op2 *) np; return (*fun)(np) && walk(p->left, fun) && walk(p->right, fun); } - -void -prtree(register struct node *np) -{ - static unsigned char indent; - register unsigned char i; - static char *optab[] = { - [OCALL] = "()", - [OARY] = "[]", - [OFIELD] = ".", - [OPTR] = "->", - [OPOSTINC] = ".++", - [OPOSTDEC] = ".--", - [OPREINC] = "++.", - [OPREDEC] = "--.", - [OADDR] = "&.", - [OINDIR] = "[*]", - [OMINUS] = "-.", - [OPLUS] = "+.", - [OCPL] = "~", - [ONEG] = "!", - [OMUL] = "*", - [ODIV] = "/", - [OMOD] = "%", - [OADD] = "+", - [OSUB] = "-", - [OSHL] = "<<", - [OSHR] = ">>", - [OLT] = "<", - [OGT] = ">", - [OGE] = ">=", - [OLE] = "<=", - [OEQ] = "==", - [ONE] = "!=", - [OBAND] = "&", - [OBXOR] = "^", - [OBOR] = "|", - [OAND] = "&&", - [OOR] = "||", - [OTERN] = "?", - [OASSIGN] = "=", - [OA_MUL] = "*=", - [OA_DIV] = "/=", - [OA_MOD] = "%=", - [OA_ADD] = "+=", - [OA_SUB] = "-=", - [OA_SHL] = "<<=", - [OA_SHR] = ">>=", - [OA_AND] = "&=", - [OA_XOR] = "^=", - [OA_OR] = "|=", - [OSYM] = "sym", - [OCOMP] = "comp", - [OSWITCH] = "switch", - [OIF] = "if", - [OFOR] = "for", - [OFEXP] = "efor", - [ODO] = "do", - [OWHILE] = "while", - [OLABEL] = "label", - [OGOTO] = "goto", - [OBREAK] = "break", - [OCONT] = "cont", - [ORETURN] = "return", - [OCASE] = "case", - [ODEFAULT] = "default", - [OFTN] = "function", - [O2EXP] = ":", - [ODEF] = "def" - }; - - if (!np) { - fputs(" nil", stdout); - return; - } - if (np->op == OSYM) { - const char *s = ((struct nodesym *) np)->sym->name; - - printf(" %s", s ? s : "."); - return; - } - - putchar('\n'); - for (i = indent; i != 0; --i) - putchar(' '); - - indent += 2; - assert(np->op < ARRAY_SIZE(optab)); - printf("(%s", optab[np->op]); - prtree(((struct node_op2 *)np)->right); - prtree(((struct node_op2 *)np)->left); - putchar(')'); - indent -= 2; -} -