From 39e4332d45e770dfe684071db4d3427fa2ca6b0c Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 22 May 2020 17:27:37 -0700 Subject: fix: calling signature of popio --- sys/cmd/cc/cc.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) (limited to 'sys/cmd/cc/cc.c') diff --git a/sys/cmd/cc/cc.c b/sys/cmd/cc/cc.c index c06d1c3..16cc6e2 100644 --- a/sys/cmd/cc/cc.c +++ b/sys/cmd/cc/cc.c @@ -136,6 +136,36 @@ Nextdir: } } +// ----------------------------------------------------------------------- +// error reporting + +void +errorat(Pos x, byte *fmt, ...) +{ + va_list args; + va_start(args, fmt); + + printf("error:%s:%d:%d: ", osĀ·basename(x.path), x.line, x.col); + vprintf(fmt, args); + printf("\n"); + + va_end(args); + assert(0); +} + +void +warnat(Pos x, byte *fmt, ...) +{ + va_list args; + va_start(args, fmt); + + printf("warning:%s:%d:%d: ", osĀ·basename(x.path), x.line, x.col); + vprintf(fmt, args); + printf("\n"); + + va_end(args); +} + // ----------------------------------------------------------------------- // main point of entry @@ -167,7 +197,7 @@ init(void) } void -initl(Lexer *lx) +initlx(Lexer *lx) { int i; @@ -187,11 +217,17 @@ initl(Lexer *lx) lx->omit.cap = 100; lx->omit.path = calloc(lx->omit.cap, sizeof(*C.inc.dir)); - lx->io = lx->iostk; - lx->io->link = nil; + lx->new = lx->iostk; + lx->new->link = nil; memset(lx->iostk, 0, sizeof(lx->iostk)); } +void +freelx(Lexer *lx) +{ + free(lx->omit.path); +} + void initp(Parser *p) { @@ -205,6 +241,7 @@ compile(byte *path) { Lexer lx; Parser p; + error err; byte *sep, out[400]; intern(&path); @@ -229,17 +266,22 @@ compile(byte *path) } } - initl(&lx); + initlx(&lx); initp(&p); - lx.io = openio(path); + lx.io = openio(&lx, path); lx.pos = (Pos){ .path = path, .line = 1, .col = 1, }; - return parse(&p, &lx); + Token t; + while (t = lex(&lx), t.kind != Aeof) + ; + // err = parse(&p, &lx); + freelx(&lx); + return err; } error @@ -292,4 +334,3 @@ main(int argc, byte *argv[]) exit(0); } - -- cgit v1.2.1