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/ast.c | 2 ++ sys/cmd/cc/cc.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++------- sys/cmd/cc/cc.h | 10 ++++------ sys/cmd/cc/lex.c | 30 ----------------------------- sys/cmd/cc/pp.c | 2 +- sys/cmd/cc/rules.mk | 1 - 6 files changed, 55 insertions(+), 45 deletions(-) (limited to 'sys') diff --git a/sys/cmd/cc/ast.c b/sys/cmd/cc/ast.c index 184ddaf..825bade 100644 --- a/sys/cmd/cc/ast.c +++ b/sys/cmd/cc/ast.c @@ -48,6 +48,7 @@ closescope(Parser *p) p->sp--; } +#if 0 static void declareobj(Parser *p, Decl *d) @@ -107,6 +108,7 @@ declaretag(Parser *p, Type *t) return define(&p->sp->tags, t->ident, Stype); } +#endif static Sym * 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); } - diff --git a/sys/cmd/cc/cc.h b/sys/cmd/cc/cc.h index 62837c4..7d30360 100644 --- a/sys/cmd/cc/cc.h +++ b/sys/cmd/cc/cc.h @@ -314,13 +314,11 @@ rune getrune(Lexer *); byte ungetbyte(Lexer *); rune ungetrune(Lexer *, rune r); -Io* openio(Lexer *lx, byte *path); -Io* makeio(Lexer *lx, byte *name); -void freeio(Lexer *lx, Io *io); -void pushio(Lexer *lx, Io *new); -void popio(Lexer *lx); +Io* openio(Lexer *lx, byte *path); +void pushio(Lexer *lx, Io *new); +void popio(Lexer *lx); -void puttok(Token); +void puttok(Token); // ----------------------------------------------------------------------- // parsing & type resolution diff --git a/sys/cmd/cc/lex.c b/sys/cmd/cc/lex.c index 1eb269c..dd6b476 100644 --- a/sys/cmd/cc/lex.c +++ b/sys/cmd/cc/lex.c @@ -852,33 +852,3 @@ forgetall(SymTab *tab) { MAP_RESET(tab); } - -// ----------------------------------------------------------------------- -// 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); -} diff --git a/sys/cmd/cc/pp.c b/sys/cmd/cc/pp.c index 5eed4b2..e05958d 100644 --- a/sys/cmd/cc/pp.c +++ b/sys/cmd/cc/pp.c @@ -892,7 +892,7 @@ ppinc(Lexer *lx) goto Bad; } - io = openio(lx->buf); + io = openio(lx, lx->buf); if (io != nil) { pushio(lx, io); } diff --git a/sys/cmd/cc/rules.mk b/sys/cmd/cc/rules.mk index d7a4ac1..b32d5b6 100644 --- a/sys/cmd/cc/rules.mk +++ b/sys/cmd/cc/rules.mk @@ -5,7 +5,6 @@ include share/push.mk SRCS_$(d) := \ $(d)/pp.c \ $(d)/lex.c \ - $(d)/ast.c \ $(d)/cc.c LIBS_$(d) := -- cgit v1.2.1