scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 54e92032ca6a63fe2175a9784eaa656e09b03774
parent 3674aab1851afa91ffb0715055c0cf1d0ccc0058
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Aug 2014 14:45:54 +0200

Remove link() and getroot()

These functions only checked the correct state of the stack
and the list of expressions, so it was a non sense to have
these functions that were only used in expression.

Diffstat:
cc2/parser.c | 25+++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -75,14 +75,6 @@ pop(void) return *--stackp; } -static void -link(Node *np) -{ - if (listp == &listexp[NR_EXPRESSIONS]) - error(EEXPROV); - *listp++ = np; -} - static char gettype(char *type) { @@ -163,15 +155,6 @@ label(char *token) push(np); } -static Node * -getroot(void) -{ - Node *np = *--stackp; - if (stackp != stack) - error(EEXPBAL); - return np; -} - static void (*optbl[])(char *) = { ['+'] = operator, ['-'] = operator, @@ -188,6 +171,7 @@ static void (*optbl[])(char *) = { static void expression(char *token) { + Node *np; void (*fun)(char *); do { @@ -196,7 +180,12 @@ expression(char *token) (*fun)(token); } while ((token = strtok(NULL, "\t")) != NULL); - link(getroot()); + np = pop(); + if (stackp != stack) + error(EEXPBAL); + if (listp == &listexp[NR_EXPRESSIONS]) + error(EEXPROV); + *listp++ = np; } static void