diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-05-22 17:27:37 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-05-22 17:27:37 -0700 |
commit | 39e4332d45e770dfe684071db4d3427fa2ca6b0c (patch) | |
tree | 839faa275fd916808b4ab6bb00db32012080085c /sys/cmd/cc/cc.c | |
parent | 69487ed29aed49ca0e3481e9783e02e9156258b2 (diff) |
fix: calling signature of popio
Diffstat (limited to 'sys/cmd/cc/cc.c')
-rw-r--r-- | sys/cmd/cc/cc.c | 55 |
1 files changed, 48 insertions, 7 deletions
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 @@ -137,6 +137,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 void @@ -167,7 +197,7 @@ init(void) } void -initl(Lexer *lx) +initlx(Lexer *lx) { int i; @@ -187,12 +217,18 @@ 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) { p->sp = p->spstk; @@ -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); } - |